linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: John Hubbard <jhubbard@nvidia.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: David Hildenbrand <david@redhat.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	linux-doc@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Jonathan Corbet <corbet@lwn.net>,
	"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>,
	Zi Yan <ziy@nvidia.com>, Yang Shi <yang.shi@linux.alibaba.com>,
	Ryan Roberts <ryan.roberts@arm.com>
Subject: Re: [PATCH v1] mm/khugepaged: replace page_mapcount() check by folio_likely_mapped_shared()
Date: Wed, 24 Apr 2024 22:40:21 -0700	[thread overview]
Message-ID: <18b9acc9-9dc8-4857-83d1-952c94b69e01@nvidia.com> (raw)
In-Reply-To: <ZinZSDTMXjPjAHLe@casper.infradead.org>

On 4/24/24 9:17 PM, Matthew Wilcox wrote:
> On Wed, Apr 24, 2024 at 09:00:50PM -0700, John Hubbard wrote:
>>> We want to limit the use of page_mapcount() to places where absolutely
>>> required, to prepare for kernel configs where we won't keep track of
>>> per-page mapcounts in large folios.
>>
>>
>> Just curious, can you elaborate on the motivation? I probably missed
>> the discussions that explained why page_mapcount() in large folios
>> is not desirable. Are we getting rid of a field in struct page/folio?
>> Some other reason?
> 
> Two reasons.  One is that, regardless of anything else, folio_mapcount()
> is expensive on large folios as it has to walk every page in the folio
> summing the mapcounts.  The more important reason is that when we move
> to separately allocated folios, we don't want to allocate an array of
> mapcounts in order to maintain a per-page mapcount.
> 
> So we're looking for a more compact scheme to avoid maintaining a
> per-page mapcount.
>

I see. Thanks for explaining the story.

>>> The khugepage MM selftests keep working as expected, including:
>>>
>>> 	Run test: collapse_max_ptes_shared (khugepaged:anon)
>>> 	Allocate huge page... OK
>>> 	Share huge page over fork()... OK
>>> 	Trigger CoW on page 255 of 512... OK
>>> 	Maybe collapse with max_ptes_shared exceeded.... OK
>>> 	Trigger CoW on page 256 of 512... OK
>>> 	Collapse with max_ptes_shared PTEs shared.... OK
>>> 	Check if parent still has huge page... OK
>>
>> Well, a word of caution! These tests do not (yet) cover either of
>> the interesting new cases that folio_likely_mapped_shared() presents:
>> KSM or hugetlbfs interactions. In other words, false positives.
> 
> Hmm ... KSM never uses large folios and hugetlbfs is disjoint from
> khugepaged?
> 

Oh good. I thought we might have had a testing hole, but no.



thanks,
-- 
John Hubbard
NVIDIA



  reply	other threads:[~2024-04-25  5:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-24 12:26 [PATCH v1] mm/khugepaged: replace page_mapcount() check by folio_likely_mapped_shared() David Hildenbrand
2024-04-24 16:28 ` Yang Shi
2024-04-24 16:36   ` David Hildenbrand
2024-04-25  4:00 ` John Hubbard
2024-04-25  4:17   ` Matthew Wilcox
2024-04-25  5:40     ` John Hubbard [this message]
     [not found]       ` <7273b0d6-06e7-4741-b77b-b49949c46d63@redhat.com>
2024-04-26  1:23         ` John Hubbard
2024-04-26  6:57           ` David Hildenbrand

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=18b9acc9-9dc8-4857-83d1-952c94b69e01@nvidia.com \
    --to=jhubbard@nvidia.com \
    --cc=akpm@linux-foundation.org \
    --cc=corbet@lwn.net \
    --cc=david@redhat.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ryan.roberts@arm.com \
    --cc=willy@infradead.org \
    --cc=yang.shi@linux.alibaba.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).