[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAJD7tkZZSgHMFVWw3cnLjvCzw56BL6NW5FCzQ2dKh_sO9yoeiw@mail.gmail.com>
Date: Sat, 17 Jun 2023 22:31:39 -0700
From: Yosry Ahmed <yosryahmed@...gle.com>
To: Sergey Senozhatsky <senozhatsky@...omium.org>
Cc: Domenico Cerasuolo <cerasuolodomenico@...il.com>,
vitaly.wool@...sulko.com, minchan@...nel.org, linux-mm@...ck.org,
ddstreet@...e.org, sjenning@...hat.com, nphamcs@...il.com,
hannes@...xchg.org, akpm@...ux-foundation.org,
linux-kernel@...r.kernel.org, kernel-team@...a.com
Subject: Re: [PATCH v3 1/7] mm: zswap: add pool shrinking mechanism
On Sat, Jun 17, 2023 at 10:30 PM Sergey Senozhatsky
<senozhatsky@...omium.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 :)
Powered by blists - more mailing lists