linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: David Hildenbrand <david@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org,
	"Vishal Moola (Oracle)" <vishal.moola@gmail.com>
Subject: Re: [PATCH 7/7] khugepaged: Use a folio throughout hpage_collapse_scan_file()
Date: Mon, 8 Apr 2024 21:28:23 +0100	[thread overview]
Message-ID: <ZhRTZwX_4ZtcU2ux@casper.infradead.org> (raw)
In-Reply-To: <b0466b95-d4ac-4742-a3f5-9d76ff68f090@redhat.com>

On Mon, Apr 08, 2024 at 10:07:01PM +0200, David Hildenbrand wrote:
> On 03.04.24 19:18, Matthew Wilcox (Oracle) wrote:
> > Replace the use of pages with folios.  Saves a few calls to
> > compound_head() and removes some uses of obsolete functions.
> > 
> > Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> > ---
> 
> [...]
> 
> > -		if (page_count(page) !=
> > -		    1 + page_mapcount(page) + page_has_private(page)) {
> > +		if (folio_ref_count(folio) !=
> > +		    1 + folio_mapcount(folio) + folio_test_private(folio)) {
> >   			result = SCAN_PAGE_COUNT;
> 
> Just stumbled over that: page_has_private() would have checked PG_private
> and PG_private_2. The corresponding replacement would have been
> folio_has_private(). folio_test_private() only checks PG_private.
> 
> Are we sure that we no longer have to check PG_private_2 here? pagecache ...
> so I have no clue :)

Oh man.  Vishal just asked me about this in our meeting and I struggled
to explain the whole horrid history.  The short answer is that this
almost certainly fixes a bug.

We have a rule (which most filesystem developers don't know about) that
attaching private data to the folio should increase its refcount by one.
This is handled by folio_attach_private().  But there's no corresponding
rule that setting PG_private_2 should also increment the refcount.
So checking PG_private_2 is wrong here because a folio with PG_private_2
set and PG_private clear will not have its refcount increased.

There are longer versions of this answer, and if you keep asking, I'll
give them ;-P


      reply	other threads:[~2024-04-08 20:28 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-03 17:18 [PATCH 0/7] khugepaged folio conversions Matthew Wilcox (Oracle)
2024-04-03 17:18 ` [PATCH 1/7] khugepaged: Inline hpage_collapse_alloc_folio() Matthew Wilcox (Oracle)
2024-04-05 21:13   ` Vishal Moola
2024-04-03 17:18 ` [PATCH 2/7] khugepaged: Convert alloc_charge_hpage to alloc_charge_folio Matthew Wilcox (Oracle)
2024-04-05 21:14   ` Vishal Moola
2024-04-07  3:44     ` Matthew Wilcox
2024-04-03 17:18 ` [PATCH 3/7] khugepaged: Remove hpage from collapse_huge_page() Matthew Wilcox (Oracle)
2024-04-05 21:14   ` Vishal Moola
2024-04-03 17:18 ` [PATCH 4/7] khugepaged: Pass a folio to __collapse_huge_page_copy() Matthew Wilcox (Oracle)
2024-04-05 21:19   ` Vishal Moola
2024-04-07  3:46     ` Matthew Wilcox
2024-04-03 17:18 ` [PATCH 5/7] khugepaged: Remove hpage from collapse_file() Matthew Wilcox (Oracle)
2024-04-05 21:19   ` Vishal Moola
2024-04-03 17:18 ` [PATCH 6/7] khugepaged: Use a folio throughout collapse_file() Matthew Wilcox (Oracle)
2024-04-05 21:20   ` Vishal Moola
2024-04-07  3:43     ` Matthew Wilcox
2024-04-03 17:18 ` [PATCH 7/7] khugepaged: Use a folio throughout hpage_collapse_scan_file() Matthew Wilcox (Oracle)
2024-04-05 21:21   ` Vishal Moola
2024-04-08 20:07   ` David Hildenbrand
2024-04-08 20:28     ` Matthew Wilcox [this message]

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=ZhRTZwX_4ZtcU2ux@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=linux-mm@kvack.org \
    --cc=vishal.moola@gmail.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