[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y2Mv4l+V9iCv9EMg@google.com>
Date: Thu, 3 Nov 2022 12:05:06 +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>,
Nitin Gupta <ngupta@...are.org>, linux-kernel@...r.kernel.org,
linux-mm@...ck.org
Subject: Re: [PATCHv4 2/9] zram: Add recompression algorithm sysfs knob
On (22/11/02 13:15), Minchan Kim wrote:
[..]
> > /* Module params (documentation at end) */
> > static unsigned int num_devices = 1;
> > @@ -1000,31 +1005,37 @@ static ssize_t max_comp_streams_store(struct device *dev,
> > return len;
> > }
> >
> > -static ssize_t comp_algorithm_show(struct device *dev,
> > - struct device_attribute *attr, char *buf)
>
> Do you have any reason to change show and set placement? Otherwise,
> please keep the function order to reduce unnecesssary churns.
I don't change their placement. It's just show and store for primary and
secondary algorithms use the same __store and __show functions, which
are static and are placed ahead of store and show.
[..]
> Just open question(I might be too paranoid?)
>
> I am thinking someone want to add third comp algorithm in future
> to balance decompression and memory efficiency.
>
> If it's not too crazy idea, let's think about the interface.
> Maybe, could we make the recomp knobs works like list?
>
> # A primary comp
> echo "A" > /zram/comp_algo
>
> # Multiple secondary comps
> echo "B threshold" > /zram/add_recomp_algo
> echo "C threshold" > /zram/add_recomp_algo
> echo "D threshold" > /zram/add_recomp_algo
What is the threshold here? My design approach is that ZRAM doesn't do
recompression on its own, so no magic is happening automatically. It's
the user-space that triggers recompression for selected pages when
user-space thinks it's time to. This allows us to have various flexible
policies and consider things that ZRAM is not even aware of: battery level,
free memory, CPU load average, etc. E.g. no recompression when all CPUs
are busy rendering video game, or when we are draining battery too fast,
etc.
> "cat /zram/recomp_algo" shows the list
>
> echo "C" > /zram/remove_recomp_algo
> will remove the C algorithm in stack.
What is the use case for removal of a secondary algorithm?
> My point is that we don't need to implement it atm but makes the
> interface to open the possibility for future extension.
>
> What do you think?
So, as far as I understand, we don't have reason to add remove_recomp_algo
right now. And existing recomp_algo does not enforce any particular format,
it can be extended. Right now we accept "$name" but can do something like
"$name:$priority". The only thing that we probably need to do is rename
recomp_algo to either add_recomp_algo or register_recomp_algo?
> > +static ssize_t recomp_algorithm_store(struct device *dev,
> > + struct device_attribute *attr,
> > + const char *buf,
> > + size_t len)
> > +{
> > + struct zram *zram = dev_to_zram(dev);
> > + int ret;
> > +
> > + ret = __comp_algorithm_store(zram, ZRAM_SECONDARY_ZCOMP, buf);
> > + return ret ? ret : len;
> > +}
> > +#endif
> > +
> > static ssize_t compact_store(struct device *dev,
> > struct device_attribute *attr, const char *buf, size_t len)
> > {
> > @@ -1762,7 +1817,11 @@ static void zram_reset_device(struct zram *zram)
> > memset(&zram->stats, 0, sizeof(zram->stats));
> > reset_bdev(zram);
> >
> > - comp_algorithm_set(zram, ZRAM_PRIMARY_ZCOMP, default_compressor);
> > + comp_algorithm_set(zram, ZRAM_PRIMARY_ZCOMP,
> > + default_comp_algs[ZRAM_PRIMARY_ZCOMP]);
> > + if (IS_ENABLED(CONFIG_ZRAM_MULTI_COMP))
>
> Dumb question:
>
> Why do you use IS_ENABLED instead of ifdef?
#ifdef-s are banned in the new C-code, as far as I know. IS_ENABLED is
what we should use.
Powered by blists - more mailing lists