[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y2z4DbuYgDJ/v8u+@dev-arch.thelio-3990X>
Date: Thu, 10 Nov 2022 06:09:33 -0700
From: Nathan Chancellor <nathan@...nel.org>
To: Sergey Senozhatsky <senozhatsky@...omium.org>
Cc: Minchan Kim <minchan@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Nitin Gupta <ngupta@...are.org>,
Suleiman Souhlal <suleiman@...gle.com>,
linux-kernel@...r.kernel.org, linux-mm@...ck.org,
llvm@...ts.linux.dev
Subject: Re: [PATCHv5 04/13] zram: Introduce recompress sysfs knob
Hi Sergey,
On Wed, Nov 09, 2022 at 08:50:38PM +0900, Sergey Senozhatsky wrote:
> Allow zram to recompress (using secondary compression streams)
> pages.
>
> Re-compression algorithms (we support up to 3 at this stage)
> are selected via recomp_algorithm:
>
> echo "algo=zstd priority=1" > /sys/block/zramX/recomp_algorithm
>
> Please read documentation for more details.
>
> We support several recompression modes:
>
> 1) IDLE pages recompression is activated by `idle` mode
>
> echo "type=idle" > /sys/block/zram0/recompress
>
> 2) Since there may be many idle pages user-space may pass a size
> threshold value (in bytes) and we will recompress pages only
> of equal or greater size:
>
> echo "threshold=888" > /sys/block/zram0/recompress
>
> 3) HUGE pages recompression is activated by `huge` mode
>
> echo "type=huge" > /sys/block/zram0/recompress
>
> 4) HUGE_IDLE pages recompression is activated by `huge_idle` mode
>
> echo "type=huge_idle" > /sys/block/zram0/recompress
>
> Signed-off-by: Sergey Senozhatsky <senozhatsky@...omium.org>
...
> diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
> index a6a5fd2474d7..749e4266dd72 100644
> --- a/drivers/block/zram/zram_drv.c
> +++ b/drivers/block/zram/zram_drv.c
...
> + for (index = 0; index < nr_pages; index++) {
> + int err;
> +
> + zram_slot_lock(zram, index);
> +
> + if (!zram_allocated(zram, index))
> + goto next;
> +
> + if (mode & RECOMPRESS_IDLE &&
> + !zram_test_flag(zram, index, ZRAM_IDLE))
> + goto next;
> +
> + if (mode & RECOMPRESS_HUGE &&
> + !zram_test_flag(zram, index, ZRAM_HUGE))
> + goto next;
> +
> + if (zram_test_flag(zram, index, ZRAM_WB) ||
> + zram_test_flag(zram, index, ZRAM_UNDER_WB) ||
> + zram_test_flag(zram, index, ZRAM_SAME) ||
> + zram_test_flag(zram, index, ZRAM_INCOMPRESSIBLE))
> + goto next;
> +
> + err = zram_recompress(zram, index, page, threshold,
> + prio, ZRAM_MAX_COMPS);
> +next:
> + zram_slot_unlock(zram, index);
> + if (err) {
> + ret = err;
> + break;
> + }
> +
> + cond_resched();
> + }
This commit is now in -next as commit 03e6c729aa64 ("zram: introduce
recompress sysfs knob"), where it introduces the following clang
warnings:
drivers/block/zram/zram_drv.c:1909:7: error: variable 'err' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
if (zram_test_flag(zram, index, ZRAM_WB) ||
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/block/zram/zram_drv.c:1919:7: note: uninitialized use occurs here
if (err) {
^~~
drivers/block/zram/zram_drv.c:1909:3: note: remove the 'if' if its condition is always false
if (zram_test_flag(zram, index, ZRAM_WB) ||
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/block/zram/zram_drv.c:1909:7: error: variable 'err' is used uninitialized whenever '||' condition is true [-Werror,-Wsometimes-uninitialized]
if (zram_test_flag(zram, index, ZRAM_WB) ||
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/block/zram/zram_drv.c:1919:7: note: uninitialized use occurs here
if (err) {
^~~
drivers/block/zram/zram_drv.c:1909:7: note: remove the '||' if its condition is always false
if (zram_test_flag(zram, index, ZRAM_WB) ||
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/block/zram/zram_drv.c:1909:7: error: variable 'err' is used uninitialized whenever '||' condition is true [-Werror,-Wsometimes-uninitialized]
if (zram_test_flag(zram, index, ZRAM_WB) ||
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/block/zram/zram_drv.c:1919:7: note: uninitialized use occurs here
if (err) {
^~~
drivers/block/zram/zram_drv.c:1909:7: note: remove the '||' if its condition is always false
if (zram_test_flag(zram, index, ZRAM_WB) ||
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/block/zram/zram_drv.c:1909:7: error: variable 'err' is used uninitialized whenever '||' condition is true [-Werror,-Wsometimes-uninitialized]
if (zram_test_flag(zram, index, ZRAM_WB) ||
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/block/zram/zram_drv.c:1919:7: note: uninitialized use occurs here
if (err) {
^~~
drivers/block/zram/zram_drv.c:1909:7: note: remove the '||' if its condition is always false
if (zram_test_flag(zram, index, ZRAM_WB) ||
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/block/zram/zram_drv.c:1905:7: error: variable 'err' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
if (mode & RECOMPRESS_HUGE &&
^~~~~~~~~~~~~~~~~~~~~~~~~
drivers/block/zram/zram_drv.c:1919:7: note: uninitialized use occurs here
if (err) {
^~~
drivers/block/zram/zram_drv.c:1905:3: note: remove the 'if' if its condition is always false
if (mode & RECOMPRESS_HUGE &&
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/block/zram/zram_drv.c:1901:7: error: variable 'err' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
if (mode & RECOMPRESS_IDLE &&
^~~~~~~~~~~~~~~~~~~~~~~~~
drivers/block/zram/zram_drv.c:1919:7: note: uninitialized use occurs here
if (err) {
^~~
drivers/block/zram/zram_drv.c:1901:3: note: remove the 'if' if its condition is always false
if (mode & RECOMPRESS_IDLE &&
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/block/zram/zram_drv.c:1898:7: error: variable 'err' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
if (!zram_allocated(zram, index))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/block/zram/zram_drv.c:1919:7: note: uninitialized use occurs here
if (err) {
^~~
drivers/block/zram/zram_drv.c:1898:3: note: remove the 'if' if its condition is always false
if (!zram_allocated(zram, index))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/block/zram/zram_drv.c:1894:10: note: initialize the variable 'err' to silence this warning
int err;
^
= 0
7 errors generated.
Is the fix just to initialize err to 0 as it suggests or should there be
a different fix?
Cheers,
Nathan
Powered by blists - more mailing lists