From: Ryan Roberts <ryan.roberts@arm.com>
To: Yu Zhao <yuzhao@google.com>, Matthew Wilcox <willy@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Yin Fengwei <fengwei.yin@intel.com>,
David Hildenbrand <david@redhat.com>,
Yang Shi <shy828301@gmail.com>,
"Huang, Ying" <ying.huang@intel.com>, Zi Yan <ziy@nvidia.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH v3 2/3] mm: Implement folio_remove_rmap_range()
Date: Wed, 26 Jul 2023 07:42:25 +0100 [thread overview]
Message-ID: <4ae1b75e-8e9b-c4f5-a50c-9fbeca245cee@arm.com> (raw)
In-Reply-To: <CAOUHufamqn0b8tN1DppfPi7FRnENzYwcSOVcAKNxkj=CYa+OwQ@mail.gmail.com>
On 26/07/2023 06:53, Yu Zhao wrote:
> On Thu, Jul 20, 2023 at 5:30 AM Ryan Roberts <ryan.roberts@arm.com> wrote:
>>
>> Like page_remove_rmap() but batch-removes the rmap for a range of pages
>> belonging to a folio. This can provide a small speedup due to less
>> manipuation of the various counters. But more crucially, if removing the
>> rmap for all pages of a folio in a batch, there is no need to
>> (spuriously) add it to the deferred split list, which saves significant
>> cost when there is contention for the split queue lock.
>>
>> All contained pages are accounted using the order-0 folio (or base page)
>> scheme.
>>
>> page_remove_rmap() is refactored so that it forwards to
>> folio_remove_rmap_range() for !compound cases, and both functions now
>> share a common epilogue function. The intention here is to avoid
>> duplication of code.
>>
>> Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
>> ---
>> include/linux/rmap.h | 2 +
>> mm/rmap.c | 125 ++++++++++++++++++++++++++++++++-----------
>> 2 files changed, 97 insertions(+), 30 deletions(-)
>>
>> diff --git a/include/linux/rmap.h b/include/linux/rmap.h
>> index b87d01660412..f578975c12c0 100644
>> --- a/include/linux/rmap.h
>> +++ b/include/linux/rmap.h
>> @@ -200,6 +200,8 @@ void page_add_file_rmap(struct page *, struct vm_area_struct *,
>> bool compound);
>> void page_remove_rmap(struct page *, struct vm_area_struct *,
>> bool compound);
>> +void folio_remove_rmap_range(struct folio *folio, struct page *page,
>> + int nr, struct vm_area_struct *vma);
>
> I prefer folio_remove_rmap_range(page, nr, vma). Passing both the
> folio and the starting page seems redundant to me.
I prefer to pass folio explicitly because it makes it clear that all pages in
the range must belong to the same folio.
>
> Matthew, is there a convention (function names, parameters, etc.) for
> operations on a range of pages within a folio?
>
> And regarding the refactor, what I have in mind is that
> folio_remove_rmap_range() is the core API and page_remove_rmap() is
> just a wrapper around it, i.e., folio_remove_rmap_range(page, 1, vma).
I tried to do it that way, but the existing page_remove_rmap() also takes a
'compound' parameter; it can operate on compound, thp pages and uses the
alternative accounting scheme in this case.
I could add a compound parameter to folio_remove_rmap_range() but in that case
the range parameters don't make sense - when compound is true we are implicitly
operating on the whole folio due to the way the accounting is done. So I felt it
was clearer for folio_remove_rmap_range() to deal with small page accounting
only. page_remove_rmap() forwards to folio_remove_rmap_range() when
compound=false and page_remove_rmap() directly deals with the thp accounting
when compound=true.
>
> Let me post a diff later and see if it makes sense to you.
next prev parent reply other threads:[~2023-07-26 6:42 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-20 11:29 [PATCH v3 0/3] Optimize large folio interaction with deferred split Ryan Roberts
2023-07-20 11:29 ` [PATCH v3 1/3] mm: Allow deferred splitting of arbitrary large anon folios Ryan Roberts
2023-07-20 11:29 ` [PATCH v3 2/3] mm: Implement folio_remove_rmap_range() Ryan Roberts
2023-07-26 5:53 ` Yu Zhao
2023-07-26 6:42 ` Ryan Roberts [this message]
2023-07-26 16:44 ` Matthew Wilcox
2023-07-27 1:29 ` Huang, Ying
2023-07-27 2:35 ` Matthew Wilcox
2023-07-27 7:26 ` Ryan Roberts
2023-07-27 16:38 ` Yu Zhao
2023-07-28 9:00 ` Ryan Roberts
2023-08-01 7:40 ` Yu Zhao
2023-07-20 11:29 ` [PATCH v3 3/3] mm: Batch-zap large anonymous folio PTE mappings Ryan Roberts
2023-07-26 16:19 ` Nathan Chancellor
2023-07-26 16:32 ` Ryan Roberts
2023-07-26 16:35 ` Nathan Chancellor
2023-07-26 19:38 ` Ryan Roberts
2023-07-26 19:50 ` Nathan Chancellor
2023-07-26 21:17 ` Ryan Roberts
2023-07-26 21:23 ` Nathan Chancellor
2023-07-26 21:28 ` Ryan Roberts
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4ae1b75e-8e9b-c4f5-a50c-9fbeca245cee@arm.com \
--to=ryan.roberts@arm.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=fengwei.yin@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=shy828301@gmail.com \
--cc=willy@infradead.org \
--cc=ying.huang@intel.com \
--cc=yuzhao@google.com \
--cc=ziy@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).