Re: [PATCH] zram: modernize writeback interface

From: Richard Chang
Date: Wed Mar 26 2025 - 03:08:04 EST


Hi Sergey,

On Wed, Mar 26, 2025 at 12:16 PM Sergey Senozhatsky
<senozhatsky@xxxxxxxxxxxx> wrote:
>
> Hi,
>
> On (25/03/26 12:03), Richard Chang wrote:
> > Hi Sergey,
> > Since the input buffer length is only PAGE_SIZE long, can we reduce
> > the duplicated "page_index_range=" strings?
> > Eg:
> > Turn
> > echo page_index_range=100-200 \
> > page_index_range=500-700 > zram0/writeback
> > To:
> > echo page_index_range=100-200,500-700 > zram0/writeback
>
> Do you expect to ever have so many ranges that PAGE_SIZE buffer
> would be too small? I didn't want to put a list parser into
> the kernel, I wanted to keep arguments parsing as simple as
> possible. But if you really need to writeback that many pages
> then I guess I can implement it as a list of ranges.
>
> Alternatively:
> We don't necessarily need to use page_index_range key, which is a
> little long, but can use page_indices=/page_indexes= or just pages=?

I am just counting how many pages we could writeback per syscall.
In a worst case, page_index_range with several two-adjacent indices:
Assume PAGE_SIZE is 4k and index range is around 10000,

page_index_range allows 272 pages per syscall:
page_index_range=10000-10001 page_index_range=10003-10004...

List_range allows 678 pages per syscall:
page_index_range=10000-10001,10003-10004...

page_indices allows 314 pages per syscall:
page_indices=10000-10001 page_indices=10003-10004...

It's the worst case so the actual world might not be that bad.

Another alternative thought, how about page_index supporting both
single instance and ranges?
The key is shorter and the parser is relatively simpler.
Eg: page_index=500 page_index=10000-10001