Re: [GIT PULL] MM updates for 6.5-rc1

From: Linus Torvalds
Date: Wed Jun 28 2023 - 13:29:19 EST


On Mon, 26 Jun 2023 at 08:50, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> Linus, please merge the MM updates for the 6.5-rc cycle.
> [...]
> merge conflict in mm/gup.c, vs block tree:
> https://lkml.kernel.org/r/20230616115856.3ce7682c@xxxxxxxxxxxxxxxx

Hmm. I think this merge resolution in -next is wrong.

It now does a common

folio = try_get_folio(page, refs);
if (flags & FOLL_GET)
return folio;

for both FOLL_GET and FOLL_PIN, and then *after* that for the FOLL_PIN
case it does that

/*
* Don't take a pin on the zero page - it's not going anywhere
* and it is used in a *lot* of places.
*/
if (is_zero_page(page))
return page_folio(page);

but by then it has already done the try_get_folio().

End result: it has already updated refcounts, despite the comment
saying not to do that.

So I think it needs to match the comment (and the try_grab_page()
logic), and just basically

if (flags & FOLL_GET)
return try_get_folio(page, refs);

if (is_zero_page(page))
return page_folio(page);

folio = try_get_folio(page, refs);
if (!folio)
return NULL;

instead.

That's what my resolution is going to do, but let's add others to the
participants list just in case somebody goes "No, Linus, the reason
-next does that is XYZ"...

Linus