From: Matthew Wilcox <willy@infradead.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Andrew Bresticker <abrestic@rivosinc.com>,
David Hildenbrand <david@redhat.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] mm/memory: Don't require head page for do_set_pmd()
Date: Tue, 11 Jun 2024 19:38:17 +0100 [thread overview]
Message-ID: <ZmiZmX_yR4wDHR1h@casper.infradead.org> (raw)
In-Reply-To: <20240611112131.25925b8ee5198668b88de35f@linux-foundation.org>
On Tue, Jun 11, 2024 at 11:21:31AM -0700, Andrew Morton wrote:
> On Tue, 11 Jun 2024 19:03:29 +0100 Matthew Wilcox <willy@infradead.org> wrote:
>
> > On Tue, Jun 11, 2024 at 08:32:16AM -0700, Andrew Bresticker wrote:
> > > - if (page != &folio->page || folio_order(folio) != HPAGE_PMD_ORDER)
> > > + if (folio_order(folio) != HPAGE_PMD_ORDER)
> > > return ret;
> > > + page = &folio->page;
> >
> > This works today, but in about six months time it's going to be a pain.
> >
> > + page = folio_page(folio, 0);
> >
> > is the one which works today and in the future.
>
> I was wondering about that.
>
> hp2:/usr/src/25> fgrep "&folio->page" mm/*.c | wc -l
> 84
> hp2:/usr/src/25> fgrep "folio_page(" mm/*.c | wc -l
> 35
>
> Should these all be converted? What's the general rule here?
The rule is ...
- If we haven't thought about it, use &folio->page to indicate that
somebody needs to think about it.
- If the code needs to be modified to split folio and page apart, use
&folio->page.
- If the code is part of compat code which is going to have to be
removed, use &folio->page (eg do_read_cache_page()).
To *think* about it, and use folio_page() or folio_file_page(), don't
just blindly pass 0 as the second argument. Think about which page
within the folio is expected by the function you're working on.
Often that is "the first one!" and so folio_page(folio, 0) is the
right answer. But that should be justified.
It might be the right answer is "Oh, that function should take a folio".
prev parent reply other threads:[~2024-06-11 18:38 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-11 15:32 Andrew Bresticker
2024-06-11 15:33 ` David Hildenbrand
2024-06-11 18:06 ` Andrew Morton
2024-06-11 18:22 ` Matthew Wilcox
2024-06-11 20:07 ` Andrew Morton
2024-06-11 21:18 ` Hugh Dickins
2024-06-12 18:41 ` David Hildenbrand
2024-08-19 8:16 ` Vincent Donnefort
2024-08-20 20:33 ` Hugh Dickins
2024-06-11 18:03 ` Matthew Wilcox
2024-06-11 18:21 ` Andrew Morton
2024-06-11 18:38 ` 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=ZmiZmX_yR4wDHR1h@casper.infradead.org \
--to=willy@infradead.org \
--cc=abrestic@rivosinc.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/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