From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6BE9C433F5 for ; Wed, 13 Apr 2022 16:20:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1873B6B0074; Wed, 13 Apr 2022 12:20:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1388D6B0075; Wed, 13 Apr 2022 12:20:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F1A196B0078; Wed, 13 Apr 2022 12:20:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id E1CF96B0074 for ; Wed, 13 Apr 2022 12:20:33 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 98F39257F0 for ; Wed, 13 Apr 2022 16:20:33 +0000 (UTC) X-FDA: 79352368746.06.DF6BEC5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf24.hostedemail.com (Postfix) with ESMTP id 0A8D3180002 for ; Wed, 13 Apr 2022 16:20:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649866832; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dQ64bLtEVZ+APpRlTSXSaScluxess+bMVBlFs6Kt68A=; b=bqIjedFfOyKMk7pUW6H2cxY7SkdVNtnOd+F8U343oCR+YXC7CWf3bWEyGyx2/aIPTUKESD pnIi4jBApAerXAeRmVcNVW9jApw4Dkim2Y07k3BU+s8rgNZ2Y6b/WdoKlMwBEAP9QG9iI+ ZRr0sgqBQukMh8Ge/satS8unI8ecVtE= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-669-UxG6MTPiPTGHgCmZ8GC5SQ-1; Wed, 13 Apr 2022 12:20:31 -0400 X-MC-Unique: UxG6MTPiPTGHgCmZ8GC5SQ-1 Received: by mail-wm1-f72.google.com with SMTP id n21-20020a05600c4f9500b0038e3b0aa367so2076026wmq.1 for ; Wed, 13 Apr 2022 09:20:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent :content-language:to:cc:references:from:organization:subject :in-reply-to:content-transfer-encoding; bh=dQ64bLtEVZ+APpRlTSXSaScluxess+bMVBlFs6Kt68A=; b=b6CKoogdlGnqKqyZRQHGl5dtkiFxiOEcwOmKWyK6JbNKvDceaPq7I/Cv05CFy+DKwA aDeeROj1Pz9hC0m4UoyXTBqYattOHwA4LPALPA1aPuKLSqYNZ11lLKr27JL57xoJRg00 XmP3CpWLcKQYiODZwMbWpigatggrAdMTSNYroxkjcykD0P3vhSw6ksOqBY4nTLYY0ZW5 GPOVhF/qEUF8d4L2t7fHuSS9UXxRXQGL16qxQjCv9xdPYg7tO/wB7pA5HBwr9l14t0jw KuwHQDqtASKxN7baa63NjDjNJOEiXJHd2ihgzfHuoV7UQ1MMcT8LWMy3CE4lySp1Ox29 av9w== X-Gm-Message-State: AOAM531NIlas5hpzWxTkZORqxDQxBAD6AqC/K4rjyxWmZK3mumd/cAcL ya9637741n+31lLVTw66moXYc1U+3u5i2+AmGMTeNzjaNkgi+AUfAhU3+2kiNXZhwd23GUkO0OK vNiRA7k8HQBg= X-Received: by 2002:a7b:c350:0:b0:38c:6d3c:6c8 with SMTP id l16-20020a7bc350000000b0038c6d3c06c8mr9082275wmj.45.1649866830211; Wed, 13 Apr 2022 09:20:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbrrSYAH6xBT3EvIXb/61ZOGSr7pOKzCt5GDKiyQdvREB4rw53ZUTMAhXOGOzlf05bfV7LKQ== X-Received: by 2002:a7b:c350:0:b0:38c:6d3c:6c8 with SMTP id l16-20020a7bc350000000b0038c6d3c06c8mr9082233wmj.45.1649866829941; Wed, 13 Apr 2022 09:20:29 -0700 (PDT) Received: from ?IPV6:2003:cb:c704:5800:1078:ebb9:e2c3:ea8c? (p200300cbc70458001078ebb9e2c3ea8c.dip0.t-ipconnect.de. [2003:cb:c704:5800:1078:ebb9:e2c3:ea8c]) by smtp.gmail.com with ESMTPSA id v188-20020a1cacc5000000b0038e9c60f0e7sm2845408wme.28.2022.04.13.09.20.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 13 Apr 2022 09:20:29 -0700 (PDT) Message-ID: Date: Wed, 13 Apr 2022 18:20:27 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.2 To: Matthew Wilcox Cc: Vlastimil Babka , linux-kernel@vger.kernel.org, Andrew Morton , Hugh Dickins , Linus Torvalds , David Rientjes , Shakeel Butt , John Hubbard , Jason Gunthorpe , Mike Kravetz , Mike Rapoport , Yang Shi , "Kirill A . Shutemov" , Jann Horn , Michal Hocko , Nadav Amit , Rik van Riel , Roman Gushchin , Andrea Arcangeli , Peter Xu , Donald Dutile , Christoph Hellwig , Oleg Nesterov , Jan Kara , Liang Zhang , Pedro Gomes , Oded Gabbay , linux-mm@kvack.org References: <20220329160440.193848-1-david@redhat.com> <20220329160440.193848-9-david@redhat.com> <4cb92b41-95e1-1666-321e-96ff9e6095bb@suse.cz> <368902ab-8d3f-5d62-581e-1ff930bcefa0@redhat.com> <0c9d2c39-5080-a855-8ecd-e2c1bd1179fa@redhat.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH v3 08/16] mm/rmap: drop "compound" parameter from page_add_new_anon_rmap() In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=bqIjedFf; spf=none (imf24.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Stat-Signature: zja8g6juurmkzuf5xuu94mxocorpiub3 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 0A8D3180002 X-HE-Tag: 1649866832-305472 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 13.04.22 14:48, Matthew Wilcox wrote: > On Wed, Apr 13, 2022 at 02:28:38PM +0200, David Hildenbrand wrote: >> On 13.04.22 14:26, Matthew Wilcox wrote: >>> On Tue, Apr 12, 2022 at 11:37:09AM +0200, David Hildenbrand wrote: >>>> On 12.04.22 10:47, Vlastimil Babka wrote: >>>>> There's a VM_BUG_ON_PAGE(PageTransCompound(page), page); later in a >>>>> !compound branch. Since compound is now determined by the same check, could >>>>> be deleted. >>>> >>>> Yes, eventually we could get rid of both VM_BUG_ON_PAGE() on both >>>> branches and add a single VM_BUG_ON_PAGE(PageTail(page), page) check on >>>> the compound branch. (we could also make sure that we're not given a >>>> hugetlb page) >>> >>> As a rule of thumb, if you find yourself wanting to add >>> VM_BUG_ON_PAGE(PageTail(page), page), you probably want to change the >>> interface to take a folio. >> >> Yeah, I had the same in mind. Might be a reasonable addon on top -- >> although it would stick out in the rmap code a bit because most >> functions deal with both, folios and subpages. > > I have the start of a series which starts looking at the fault path > to see where it makes sense to use folios and where it makes sense to > use pages. > > We're (generally) faulting on a PTE, so we need the precise page to > be returned in vmf->page. However vmf->cow_page can/should be a > folio (because it's definitely not a tail page). That trickles > down into copy_present_page() (new_page and prealloc both become folios) > and so page_add_new_anon_rmap() then looks like a good target to > take a folio. > > The finish_fault() -> do_set_pte() -> page_add_new_anon_rmap() looks > like the only kind of strange place where we don't necessarily have a > folio (all the others we just allocated it). > That's an interesting point. In this patch I'm assuming that we don't have a compound page here (see below). Which makes sense, because as the interface states "Same as page_add_anon_rmap but must only be called on *new* pages.". At least to me it would be weird to allocate a new compound page to then pass a subpage to do_set_pte() page_add_new_anon_rmap(). And in fact, inside page_add_new_anon_rmap(compound=false) we have /* Anon THP always mapped first with PMD */ VM_BUG_ON_PAGE(PageTransCompound(page), page); which makes sure that we cannot have a compound page here, but in fact a folio. So unless I am missing something, do_set_pte() should in fact have a folio here unless BUG? -- Thanks, David / dhildenb