linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Nhat Pham <nphamcs@gmail.com>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: Minchan Kim <minchan@kernel.org>,
	Sergey Senozhatsky <senozhatsky@chromium.org>,
	 akpm@linux-foundation.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org,  ngupta@vflare.org,
	sjenning@redhat.com, ddstreet@ieee.org,
	 vitaly.wool@konsulko.com, kernel-team@meta.com
Subject: Re: [PATCH] zsmalloc: move LRU update from zs_map_object() to zs_malloc()
Date: Tue, 9 May 2023 15:04:29 -0700	[thread overview]
Message-ID: <CAKEwX=OOuGa808JHYamhRrg+zE8d=pRLCqPz-4T0B2aNvsMLSA@mail.gmail.com> (raw)
In-Reply-To: <20230509192401.GC18828@cmpxchg.org>

On Tue, May 9, 2023 at 12:24 PM Johannes Weiner <hannes@cmpxchg.org> wrote:
>
> On Tue, May 09, 2023 at 11:20:02AM -0700, Minchan Kim wrote:
> > Hi Folks,
> >
> > On Tue, May 09, 2023 at 01:44:01PM -0400, Johannes Weiner wrote:
> > > On Tue, May 09, 2023 at 12:00:30PM +0900, Sergey Senozhatsky wrote:
> > > > On (23/05/08 09:00), Nhat Pham wrote:
> > > > > > The deeper bug here is that zs_map_object() tries to add the page to
> > > > > > the LRU list while the shrinker has it isolated for reclaim. This is
> > > > > > way too sutble and error prone. Even if it worked now, it'll cause
> > > > > > corruption issues down the line.
> > > > > >
> > > > > > For example, Nhat is adding a secondary entry point to reclaim.
> > > > > > Reclaim expects that a page that's on the LRU is also on the fullness
> > > > > > list, so this would lead to a double remove_zspage() and BUG_ON().
> > > > > >
> > > > > > This patch doesn't just fix the crash, it eliminates the deeper LRU
> > > > > > isolation issue and makes the code more robust and simple.
> > > > >
> > > > > I agree. IMO, less unnecessary concurrent interaction is always a
> > > > > win for developers' and maintainers' cognitive load.
> > > >
> > > > Thanks for all the explanations.
> > > >
> > > > > As a side benefit - this also gets rid of the inelegant check
> > > > > (mm == ZS_MM_WO). The fact that we had to include a
> > > > > a multi-paragraph explanation for a 3-line piece of code
> > > > > should have been a red flag.
> > > >
> > > > Minchan had some strong opinion on that, so we need to hear from him
> > > > before we decide how do we fix it.
> > >
> > > I'd be happy if he could validate the fix. But this fixes a crash, so
> > > the clock is ticking.
> > >
> > > I will also say, his was a design preference. One we agreed to only
> > > very reluctantly: https://lore.kernel.org/lkml/Y3f6habiVuV9LMcu@google.com/
> > >
> > > Now we have a crash that is a direct result of it, and which cost us
> > > (and apparently is still costing us) time and energy to resolve.
> > >
> > > Unless somebody surfaces a real technical problem with the fix, I'd
> > > say let's do it our way this time.
> > >
> >
> > Sorry for being too late to review. The reason I insisted on it was
> > I overlookeded the bug and thought it was trivial change but better
> > semantic since zsmalloc provides separate API between allocation and
> > access unlike other allocators. Now, Nhat and Johannes provided it's
> > more error prone, I am totally fine with this fix and will live it
> > until the LRU writeback will move out of allocator.
> >
> > Sorry for wasting your time to hunt this bug down and thank you for fix!
> >
> > Acked-by: Minchan Kim <minchan@kernel.org>
>
> Thanks Minchan!
>
> Domenico is working on the LRU refactor right now, and should have
> patches for review soon. This will indeed get rid of all the zsmalloc
> warts and make our lives much easier going forward!

That's the dream! I look forward to Domenico's patches.
And thanks for the ack, Minchan!


  reply	other threads:[~2023-05-09 22:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-05 18:50 Nhat Pham
2023-05-05 19:14 ` Andrew Morton
2023-05-05 19:26   ` Nhat Pham
2023-05-05 19:29   ` Johannes Weiner
2023-05-06  3:01 ` Sergey Senozhatsky
2023-05-08 14:06   ` Johannes Weiner
2023-05-08 16:00     ` Nhat Pham
2023-05-09  3:00       ` Sergey Senozhatsky
2023-05-09 17:44         ` Johannes Weiner
2023-05-09 18:20           ` Minchan Kim
2023-05-09 19:24             ` Johannes Weiner
2023-05-09 22:04               ` Nhat Pham [this message]
2023-05-10  0:39 ` Sergey Senozhatsky

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='CAKEwX=OOuGa808JHYamhRrg+zE8d=pRLCqPz-4T0B2aNvsMLSA@mail.gmail.com' \
    --to=nphamcs@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=ddstreet@ieee.org \
    --cc=hannes@cmpxchg.org \
    --cc=kernel-team@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=minchan@kernel.org \
    --cc=ngupta@vflare.org \
    --cc=senozhatsky@chromium.org \
    --cc=sjenning@redhat.com \
    --cc=vitaly.wool@konsulko.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