Subject: Re: [BUG -next] "memcg: charge before adding to swapcache on swapin" broken

From: Minchan Kim <[email-masked]>
Date: Thu, 18 Mar 2021 08:19:12 -0700

On Wed, Mar 17, 2021 at 06:49:27PM -0700, Shakeel Butt wrote:
> On Wed, Mar 17, 2021 at 6:31 PM Minchan Kim <[email-masked]> wrote:
> >
> [...]
> > >
> > > The simplest solution I can think of is to do set_page_private(page,
> > > entry.val) before swap_readpage(page, true) and set_page_private(page,
> > > 0) after.
> >
> > Since I did't read the bug in detail, I couldn't come up with how the
> > missing reset is connected the problem while missing set_page_private
> > with entry.val is clear.
> 
> This particular bug is about missing set_page_private(page,
> entry.val). I was wondering if we should always reset page->private or
> just leave it as is? I think it is safer to reset.

For safeness point of view, I couldn't find something wrong since
page_private will be used once the page turns out PageSwapCache.
(please chime in if someone found)

Having said, I agree it would be more consistent and safer.