Re: [PATCHv4 2/6] zram: add writeback batch size device attr

From: Andrew Morton

Date: Thu Nov 20 2025 - 20:17:39 EST


On Tue, 18 Nov 2025 16:29:56 +0900 Sergey Senozhatsky <senozhatsky@xxxxxxxxxxxx> wrote:

> Introduce writeback_batch_size device attribute so that
> the maximum number of in-flight writeback bio requests
> can be configured at run-time per-device. This essentially
> enables batched bio writeback.
>
> ...
>
> --- a/drivers/block/zram/zram_drv.c
> +++ b/drivers/block/zram/zram_drv.c
> @@ -588,6 +588,42 @@ static ssize_t writeback_limit_show(struct device *dev,
> return sysfs_emit(buf, "%llu\n", val);
> }
>
> +static ssize_t writeback_batch_size_store(struct device *dev,
> + struct device_attribute *attr,
> + const char *buf, size_t len)
> +{
> + struct zram *zram = dev_to_zram(dev);
> + u32 val;
> + ssize_t ret = -EINVAL;
> +
> + if (kstrtouint(buf, 10, &val))
> + return ret;
> +
> + if (!val)
> + val = 1;
> +
> + down_read(&zram->init_lock);

down_write()?

> + zram->wb_batch_size = val;
> + up_read(&zram->init_lock);
> + ret = len;
> +
> + return ret;
> +}