[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6yyispyqlczqeu2jjiwb5ypg26jq6gbnyxnmibtztl5ivzw6qa@h7abf3e5twqn>
Date: Fri, 21 Nov 2025 16:47:05 +0900
From: Sergey Senozhatsky <senozhatsky@...omium.org>
To: Hannes Reinecke <hare@...e.de>
Cc: Sergey Senozhatsky <senozhatsky@...omium.org>,
Andrew Morton <akpm@...ux-foundation.org>, Minchan Kim <minchan@...nel.org>,
Yuwen Chen <ywen.chen@...mail.com>, Richard Chang <richardycc@...gle.com>,
Brian Geffon <bgeffon@...gle.com>, Fengyu Lian <licayy@...look.com>, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, linux-block@...r.kernel.org, Minchan Kim <minchan@...gle.com>
Subject: Re: [RFC PATCHv5 1/6] zram: introduce writeback bio batching
On (25/11/21 08:40), Hannes Reinecke wrote:
> > +static int zram_complete_done_reqs(struct zram *zram,
> > + struct zram_wb_ctl *wb_ctl)
> > +{
> > + struct zram_wb_req *req;
> > + unsigned long flags;
> > int ret = 0, err;
> > - u32 index;
> > - page = alloc_page(GFP_KERNEL);
> > - if (!page)
> > - return -ENOMEM;
> > + while (1) {
> > + spin_lock_irqsave(&wb_ctl->done_lock, flags);
> > + req = list_first_entry_or_null(&wb_ctl->done_reqs,
> > + struct zram_wb_req, entry);
> > + if (req)
> > + list_del(&req->entry);
> > + spin_unlock_irqrestore(&wb_ctl->done_lock, flags);
> > +
> > + if (!req)
> > + break;
> > +
> > + err = zram_writeback_complete(zram, req);
> > + if (err)
> > + ret = err;
> > +
> > + atomic_dec(&wb_ctl->num_inflight);
> > + release_pp_slot(zram, req->pps);
> > + req->pps = NULL;
> > +
> > + list_add(&req->entry, &wb_ctl->idle_reqs);
>
> Shouldn't this be locked?
See below.
> > + }
> > +
> > + return ret;
> > +}
> > +
> > +static struct zram_wb_req *zram_select_idle_req(struct zram_wb_ctl *wb_ctl)
> > +{
> > + struct zram_wb_req *req;
> > +
> > + req = list_first_entry_or_null(&wb_ctl->idle_reqs,
> > + struct zram_wb_req, entry);
> > + if (req)
> > + list_del(&req->entry);
>
> See above. I think you need to lock this to avoid someone stepping in
> here an modify the element under you.
->idle_reqs list is mutated by one and one task only: the one that
does writeback. ->done_reqs list, on the other hand, is accessed
both from IRQ (bio completion) and from the writeback task.
Powered by blists - more mailing lists