Re: Fixed buffers have out-dated content

Linus Torvalds
2021-01-17T20:15:41Z

On Sun, Jan 17, 2021 at 12:07 PM Martin Raiber <martin@urbackup.org> wrote:
>
> Thanks! With the patch (skip swapping pinned pages) the problem doesn't
> occur anymore, so it seems to fix it.

Heh, this email came in just as I had committed it to my tree and was
actively writing an email about how you likely wouldn't test it before
I did rc4 because it's a weekend ;)

But since I hadn't pushed it out yet (or done some of the pulls I have
pending), I amended the commit message with your tested-by as well.
Thanks.

It's commit feb889fb40fa ("mm: don't put pinned pages into the swap cache").

I was pretty sure that was the cause from the symptoms you saw, and
the commit explains the whole chain (and explains why the "simple and
stupid" two-liner is actually the right thing to do).

I was very tempted to make the condition for "don't put it into the
swap cache" be much more aggressive, to handle the "GUP with write"
case too, something like

/* Single mapper, more references than us and the map? */
if (page_mapcount(page) == 1 && page_count(page) > 2)
goto keep_locked;

but just using page_maybe_dma_pinned() is the more targeted one for now.

(Added Peter to the cc so that he sees this).

Linus