[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <rjowf2hdk7pkmqpslj6jaqm6y4mhvr726dxpjyz7jtcjixv3hi@jyah654foky4>
Date: Fri, 14 Nov 2025 10:53:23 +0900
From: Sergey Senozhatsky <senozhatsky@...omium.org>
To: Minchan Kim <minchan@...nel.org>
Cc: Sergey Senozhatsky <senozhatsky@...omium.org>,
Andrew Morton <akpm@...ux-foundation.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
Subject: Re: [PATCHv2 1/4] zram: introduce writeback bio batching support
On (25/11/13 15:45), Minchan Kim wrote:
[..]
> > +struct zram_wb_req {
> > + unsigned long blk_idx;
> > + struct page *page;
> > struct zram_pp_slot *pps;
> > struct bio_vec bio_vec;
> > struct bio bio;
> > - int ret = 0, err;
> > +
> > + struct list_head entry;
> > +};
>
> How about moving structure definition to the upper part of the C file?
> Not only readability to put together data types but also better diff
> for reviewer to know what we changed in this patch.
This still needs to be under #ifdef CONFIG_ZRAM_WRITEBACK so readability
is not significantly better. Do you still prefer moving it up?
[..]
> > +/* XXX: should be a per-device sysfs attr */
> > +#define ZRAM_WB_REQ_CNT 1
>
> Understand you will create the knob for the tune but at least,
> let's introduce default number for that here.
>
> How about 32 since it's general queue depth for modern storage?
So this is tricky. I don't know what number is a good default for
all, given the variety of devices out there, variety of specs and
hardware, on both sides of price range. I don't know if 32 is safe
wrt to performance/throughput (I may be wrong and 32 is safe for
everyone). On the other hand, 1 was our baseline for ages, so I
wanted to minimize the risks and just keep the baseline behavior.
Do you still prefer 32 as default? (here and in the next patch)
[..]
> > + for (i = 0; i < ZRAM_WB_REQ_CNT; i++) {
> > + struct zram_wb_req *req;
> > +
> > + /*
> > + * This is fatal condition only if we couldn't allocate
> > + * any requests at all. Otherwise we just work with the
> > + * requests that we have successfully allocated, so that
> > + * writeback can still proceed, even if there is only one
> > + * request on the idle list.
> > + */
> > + req = kzalloc(sizeof(*req), GFP_NOIO | __GFP_NOWARN);
>
> Why GFP_NOIO?
>
> > + if (!req)
> > + break;
> > +
> > + req->page = alloc_page(GFP_NOIO | __GFP_NOWARN);
>
> Ditto
So we do this for post-processing, which allocates a bunch of memory
for post-processing (not only requests lists with physical pages, but
also candidate slots buckets). The thing is that post-processing can
be called under memory pressure and we don't really want to block and
reclaim memory from the path that is called to relive memory pressure
(by doing writeback or recompression).
> > + if (!req->page) {
> > + kfree(req);
> > + break;
> > + }
> > +
> > + INIT_LIST_HEAD(&req->entry);
>
> Do we need this reset?
Let me take a look.
> > +static void zram_account_writeback_rollback(struct zram *zram)
> > +{
> > + spin_lock(&zram->wb_limit_lock);
> > + if (zram->wb_limit_enable)
> > + zram->bd_wb_limit += 1UL << (PAGE_SHIFT - 12);
> > + spin_unlock(&zram->wb_limit_lock);
> > +}
> > +
> > +static void zram_account_writeback_submit(struct zram *zram)
> > +{
> > + spin_lock(&zram->wb_limit_lock);
> > + if (zram->wb_limit_enable && zram->bd_wb_limit > 0)
> > + zram->bd_wb_limit -= 1UL << (PAGE_SHIFT - 12);
> > + spin_unlock(&zram->wb_limit_lock);
> > +}
>
> I didn't think about much about this that we really need to be
> accurate like this. Maybe, next time after coffee.
Sorry, not sure I understand this comment.
[..]
> > +static int zram_writeback_slots(struct zram *zram,
> > + struct zram_pp_ctl *ctl,
> > + struct zram_wb_ctl *wb_ctl)
> > +{
> > + struct zram_wb_req *req = NULL;
> > + unsigned long blk_idx = 0;
> > + struct zram_pp_slot *pps;
> > + int ret = 0, err;
> > + u32 index = 0;
> > +
> > + blk_start_plug(&wb_ctl->plug);
>
> Why is the plug part of wb_ctl?
>
> The scope of plug is in this function and the purpose is for
> this writeback batch in this function so the plug can be local
> variable in this function.
ACK, that's a leftover from when I manipulated plugs outside of this
function. Now it's completely local.
[..]
> > + bio_init(&req->bio, zram->bdev, &req->bio_vec, 1,
> > + REQ_OP_WRITE | REQ_SYNC);
>
> Can't we drop the REQ_SYNC now?
Good catch, I suppose we can.
Powered by blists - more mailing lists