From: Yosry Ahmed <yosryahmed@google.com>
To: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Domenico Cerasuolo <cerasuolodomenico@gmail.com>,
vitaly.wool@konsulko.com, minchan@kernel.org,
linux-mm@kvack.org, ddstreet@ieee.org, sjenning@redhat.com,
nphamcs@gmail.com, hannes@cmpxchg.org,
akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
kernel-team@meta.com
Subject: Re: [PATCH v3 1/7] mm: zswap: add pool shrinking mechanism
Date: Sat, 17 Jun 2023 22:31:39 -0700 [thread overview]
Message-ID: <CAJD7tkZZSgHMFVWw3cnLjvCzw56BL6NW5FCzQ2dKh_sO9yoeiw@mail.gmail.com> (raw)
In-Reply-To: <20230618053048.GC2417524@google.com>
On Sat, Jun 17, 2023 at 10:30 PM Sergey Senozhatsky
<senozhatsky@chromium.org> wrote:
>
> On (23/06/17 22:28), Yosry Ahmed wrote:
> > > On (23/06/17 21:48), Yosry Ahmed wrote:
> > > > > On (23/06/12 11:38), Domenico Cerasuolo wrote:
> > > > > > +static int zswap_reclaim_entry(struct zswap_pool *pool)
> > > > > > +{
> > > > > > + struct zswap_header *zhdr;
> > > > > > + struct zswap_entry *entry;
> > > > > > + struct zswap_tree *tree;
> > > > > > + pgoff_t swpoffset;
> > > > > > + int ret;
> > > > > > +
> > > > > > + /* Get an entry off the LRU */
> > > > > > + spin_lock(&pool->lru_lock);
> > > > > > + if (list_empty(&pool->lru)) {
> > > > > > + spin_unlock(&pool->lru_lock);
> > > > > > + return -EINVAL;
> > > > > > + }
> > > > > > + entry = list_last_entry(&pool->lru, struct zswap_entry, lru);
> > > > > > + list_del_init(&entry->lru);
> > > > >
> > > > > A quick question: should we zswap_entry_get() here?
> > > >
> > > > We need to hold the tree lock for that, and the lock ordering is tree
> > > > lock -> lru lock. If we try to grab the tree lock here we may
> > > > deadlock.
> > >
> > > We can deadlock doing this?
> > >
> > > lock tree_lock
> > > lock lru_lock
> > > list_del_init
> > > unlock lru_lock
> > > entry_get
> > > unlock tree_lock
> > > writeback
> >
> > We don't know which tree the zswap entry belongs to
>
> Oh... I must be blind. You are right. Sorry for the noise.
Don't blame yourself, it is fairly convoluted :)
next prev parent reply other threads:[~2023-06-18 5:32 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-12 9:38 [PATCH v3 0/7] mm: zswap: move writeback LRU from zpool to zswap Domenico Cerasuolo
2023-06-12 9:38 ` [PATCH v3 1/7] mm: zswap: add pool shrinking mechanism Domenico Cerasuolo
2023-06-12 13:34 ` Johannes Weiner
2023-06-12 18:18 ` Yosry Ahmed
2023-06-18 4:38 ` Sergey Senozhatsky
2023-06-18 4:48 ` Yosry Ahmed
2023-06-18 5:25 ` Sergey Senozhatsky
2023-06-18 5:28 ` Yosry Ahmed
2023-06-18 5:30 ` Sergey Senozhatsky
2023-06-18 5:31 ` Yosry Ahmed [this message]
2023-06-12 9:38 ` [PATCH v3 2/7] mm: zswap: remove page reclaim logic from zbud Domenico Cerasuolo
2023-06-12 9:38 ` [PATCH v3 3/7] mm: zswap: remove page reclaim logic from z3fold Domenico Cerasuolo
2023-06-12 9:38 ` [PATCH v3 4/7] mm: zswap: remove page reclaim logic from zsmalloc Domenico Cerasuolo
2023-06-12 9:38 ` [PATCH v3 5/7] mm: zswap: remove shrink from zpool interface Domenico Cerasuolo
2023-06-12 9:38 ` [PATCH v3 6/7] mm: zswap: simplify writeback function Domenico Cerasuolo
2023-06-12 13:38 ` Johannes Weiner
2023-06-12 9:38 ` [PATCH v3 7/7] mm: zswap: remove zswap_header Domenico Cerasuolo
2023-06-12 18:47 ` Johannes Weiner
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=CAJD7tkZZSgHMFVWw3cnLjvCzw56BL6NW5FCzQ2dKh_sO9yoeiw@mail.gmail.com \
--to=yosryahmed@google.com \
--cc=akpm@linux-foundation.org \
--cc=cerasuolodomenico@gmail.com \
--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=nphamcs@gmail.com \
--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