From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40E3CC4332F for ; Thu, 10 Nov 2022 13:09:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BB8216B0071; Thu, 10 Nov 2022 08:09:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B668B6B0072; Thu, 10 Nov 2022 08:09:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A559A8E0001; Thu, 10 Nov 2022 08:09:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 9869E6B0071 for ; Thu, 10 Nov 2022 08:09:41 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 733928051C for ; Thu, 10 Nov 2022 13:09:41 +0000 (UTC) X-FDA: 80117564562.18.0509B65 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf03.hostedemail.com (Postfix) with ESMTP id B0F0320011 for ; Thu, 10 Nov 2022 13:09:39 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 7BB0DB821A5; Thu, 10 Nov 2022 13:09:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD582C433D7; Thu, 10 Nov 2022 13:09:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668085776; bh=pKLI4hJQENSG/gSAWyu3k71l5rFZ3bAWEtxR/Q5BjXg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=TKEkrHWT+ZBpJ7NqdmCjGILQA2wXS1Z57Ng+hj4y3MT4/FL0JU8k7vGUEp/giRyjB CWJ2JpcVW3Xj7tPN8JrP6l9OhqOu1swmDS5DUBG/vJhwE0wnpjneY6DyEsgMguqfw+ XZ4B2XlbR47yL0NXFfMh9xaa7LNDTcADywdbb5qri2rPit/1YRKDGp25MsgC0UzeUN do+DpIYRt6+UvOksmk6fAw6laOtNl4Tbqn+kVY7DQVtcvoc7uOm/vLUHXezUWb+Jj1 OI/JSOmSNUNe9K8c0dA52CseMiCxxsScmZUXZlOB6TeCM+CkF0std8gc2h4iRuRAV7 SAoTWqzOwpbUQ== Date: Thu, 10 Nov 2022 06:09:33 -0700 From: Nathan Chancellor To: Sergey Senozhatsky Cc: Minchan Kim , Andrew Morton , Nitin Gupta , Suleiman Souhlal , linux-kernel@vger.kernel.org, linux-mm@kvack.org, llvm@lists.linux.dev Subject: Re: [PATCHv5 04/13] zram: Introduce recompress sysfs knob Message-ID: References: <20221109115047.2921851-1-senozhatsky@chromium.org> <20221109115047.2921851-5-senozhatsky@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221109115047.2921851-5-senozhatsky@chromium.org> ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668085780; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=VcGSJzTLxkwzE/RlbPlPbHtd4x9G5C9dv74ugc5b4Z8=; b=verUytMuBbvTJNgPs4+SLxK5Mv315llatMZ8EsVeMq1s3yJSTyITYNU4WFVjLGSTef+o9q ZKr5XpZgOoHSmYk23QqkbpfRvlXbjM3elTuLfvztuoRkPkVEQzpW970rohIjTBS910KSQ7 lQt8136o0bgNYw/8898jUrTB/zXS3AY= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=TKEkrHWT; spf=pass (imf03.hostedemail.com: domain of nathan@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=nathan@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668085780; a=rsa-sha256; cv=none; b=5Gh05VhhJsYZPr4IhDOtqZ0fwVj3+X09MwNM58NWN56PHD1ZcynfkD+Og4JIfVLmNv2JiF 20dzFABmal6AWlX52hAgyN80UH0ZbTZBHe4symmRgRdCa6zxrNX6+aSu8y/xwbwKfxrvYk +/Ah6jB4jl7hEMjnLtIUTUKMbseha1Q= X-Rspam-User: X-Stat-Signature: ykkzgitzbogti7pw5nafi6nnt8czkffx X-Rspamd-Queue-Id: B0F0320011 Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=TKEkrHWT; spf=pass (imf03.hostedemail.com: domain of nathan@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=nathan@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspamd-Server: rspam07 X-HE-Tag: 1668085779-712537 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 ... > 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