From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Nhat Pham <nphamcs@gmail.com>
Cc: akpm@linux-foundation.org, hannes@cmpxchg.org,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
minchan@kernel.org, ngupta@vflare.org, senozhatsky@chromium.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: Wed, 10 May 2023 09:39:22 +0900 [thread overview]
Message-ID: <20230510003922.GF11511@google.com> (raw)
In-Reply-To: <20230505185054.2417128-1-nphamcs@gmail.com>
On (23/05/05 11:50), Nhat Pham wrote:
[..]
> zswap_frontswap_store() shrink_worker()
> zs_malloc() zs_zpool_shrink()
> spin_lock(&pool->lock) zs_reclaim_page()
> zspage = find_get_zspage()
> spin_unlock(&pool->lock)
> spin_lock(&pool->lock)
> zspage = list_first_entry(&pool->lru)
> list_del(&zspage->lru)
> zspage->lru.next = LIST_POISON1
> zspage->lru.prev = LIST_POISON2
> spin_unlock(&pool->lock)
> zs_map_object()
> spin_lock(&pool->lock)
> if (!list_empty(&zspage->lru))
> list_del(&zspage->lru)
> CHECK_DATA_CORRUPTION(next == LIST_POISON1) /* BOOM */
>
> With the current upstream code, this issue rarely happens. zswap only
> triggers writeback when the pool is already full, at which point all
> further store attempts are short-circuited. This creates an implicit
> pseudo-serialization between reclaim and store. I am working on a new
> zswap shrinking mechanism, which makes interleaving reclaim and store
> more likely, exposing this bug.
>
> zbud and z3fold do not have this problem, because they perform the LRU
> list update in the alloc function, while still holding the pool's lock.
> This patch fixes the aforementioned bug by moving the LRU update back to
> zs_malloc(), analogous to zbud and z3fold.
>
> Suggested-by: Johannes Weiner <hannes@cmpxchg.org>
> Acked-by: Johannes Weiner <hannes@cmpxchg.org>
> Signed-off-by: Nhat Pham <nphamcs@gmail.com>
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
prev parent reply other threads:[~2023-05-10 0:39 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-05 18:50 [PATCH] zsmalloc: move LRU update from zs_map_object() to zs_malloc() 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
2023-05-10 0:39 ` Sergey Senozhatsky [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=20230510003922.GF11511@google.com \
--to=senozhatsky@chromium.org \
--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=nphamcs@gmail.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.