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 82D3DC433FE for ; Mon, 7 Nov 2022 19:08:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F39AF8E0001; Mon, 7 Nov 2022 14:08:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EEAA36B007B; Mon, 7 Nov 2022 14:08:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DD8E08E0001; Mon, 7 Nov 2022 14:08:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id CEA926B0078 for ; Mon, 7 Nov 2022 14:08:43 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 876F34081F for ; Mon, 7 Nov 2022 19:08:43 +0000 (UTC) X-FDA: 80107582926.12.03A1FBA Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) by imf25.hostedemail.com (Postfix) with ESMTP id 0502DA0007 for ; Mon, 7 Nov 2022 19:08:42 +0000 (UTC) Received: by mail-pj1-f48.google.com with SMTP id c15-20020a17090a1d0f00b0021365864446so11158220pjd.4 for ; Mon, 07 Nov 2022 11:08:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=jTCNtbX3AF4Smxm3i3nu7Nj8Pslpw4wqg4w1w+kK/J4=; b=MNNfCg/5gVyQM81xzP8VzXC+EvdXULnq7Mb7cNh713opoViar0a21sBz/DLT3DvQ/U EtEG2ovwz3KOGJM0kQFDfuIqIEBm7HoJwq0EAvwaeq0vojP65qiR9VZgRnwUsMHx+Vv/ zxWNVCjVJhFomMCXNwrMdUxXaOgIKqLqS/GQXI4MSblccq6+YW5BgB869PmeuotR2fN4 GWLPB+6MVdEpl1xodsfoSdCf+WsM4uJP71wU1luMAf9DfgTaDU/b3m+DhcQUnr0+dx7o EOluKsh1E0USn4QwPfpVbvxSOT/9IPWcW43Trt8PHk9U7X9t6QucfZcHM+j7sxzne05x iF8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jTCNtbX3AF4Smxm3i3nu7Nj8Pslpw4wqg4w1w+kK/J4=; b=iM8GZBum0c7gBKSl2/6gMJV+8wgxZI91HlE7JXncrjZl9tvzRB/Z3PP/0I8v3NmHVy 8loRp8cuhAIrUgJHIbiBIvzDwBClkd9NmXfv7IWwffKeeLIvHhcgsBjd8NOdScrZhB9M CmAJXHS2xF+hNvEAeIKFBo764l8L54Nn6RWIEImkYPMtT/uBoIE0gAnKOhUNYrOe1mGm S0scvTBE/Xsfg3GbA+C7QoFCtLnaW4FAIUSojlLrRW4Vq3N6h/PbyJkljTG0+eleE+5d lCs0EzKYjVUrZgGv3icdpvAyo5AXiq23y8Jt+2b4evDObEiejki01xF1p478IsS/ILKZ GIyA== X-Gm-Message-State: ACrzQf2Ot5VuQcGS/ko9X/HN32mUHqsr6t9E7li5k5XnoCjSI7Eiu5mg BGbERkraJfSIfab0Nor6PE8= X-Google-Smtp-Source: AMsMyM7qiZMp/mIjtcL9GXHPlUo3MWNaQnB96hUmeqVIY9GZGNQEd9h5lyDvqP9bRVn87eQe8m0LMg== X-Received: by 2002:a17:90b:1c87:b0:20a:e485:4e21 with SMTP id oo7-20020a17090b1c8700b0020ae4854e21mr52941700pjb.194.1667848121820; Mon, 07 Nov 2022 11:08:41 -0800 (PST) Received: from google.com ([2620:15c:211:201:594a:f636:e461:590b]) by smtp.gmail.com with ESMTPSA id m12-20020a17090ab78c00b002132f3e71c6sm4572293pjr.52.2022.11.07.11.08.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Nov 2022 11:08:41 -0800 (PST) Date: Mon, 7 Nov 2022 11:08:39 -0800 From: Minchan Kim To: Sergey Senozhatsky Cc: Andrew Morton , Nitin Gupta , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCHv4 2/9] zram: Add recompression algorithm sysfs knob Message-ID: References: <20221018045533.2396670-1-senozhatsky@chromium.org> <20221018045533.2396670-3-senozhatsky@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667848123; a=rsa-sha256; cv=none; b=3/jo92bjU3FF4t9OQU2MrKTD2HTd427FTm30eiiuLSsbr2F/nIx1mVIC6NubicPPCmcD2+ Vqej47xEL4gIIvjZ5yX9j0O5DuET2J5BfCrf67RwtJrm+29G8fx1dw4BKNtbvM9YVuVQMB fUhOIpvFDknFDyXeUQotFSe0ItElLsQ= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="MNNfCg/5"; spf=pass (imf25.hostedemail.com: domain of minchan.kim@gmail.com designates 209.85.216.48 as permitted sender) smtp.mailfrom=minchan.kim@gmail.com; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667848123; h=from:from:sender: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=jTCNtbX3AF4Smxm3i3nu7Nj8Pslpw4wqg4w1w+kK/J4=; b=CxCcWSB8CUFJwZlf3RRVqcFEMCNJGDyUKNGsl2dz4C6oNxbdRIvGKsYpR/F7srWSuk5LG2 f5pRInZGnJyXMd53rZnwMggLNM/TaxUC3SEtVbcJ3qSTSKinkRLkz3B4LqrOgy3JCXu2mI umJV6CUf8TQnW8u333+8YFP/yy9pqu8= Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="MNNfCg/5"; spf=pass (imf25.hostedemail.com: domain of minchan.kim@gmail.com designates 209.85.216.48 as permitted sender) smtp.mailfrom=minchan.kim@gmail.com; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none) X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 0502DA0007 X-Stat-Signature: 7ia7yd4d7bhj93ncgoqxcpnkf5a99z9g X-HE-Tag: 1667848122-901535 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: On Sat, Nov 05, 2022 at 09:00:33AM +0900, Sergey Senozhatsky wrote: > On (22/11/05 08:41), Sergey Senozhatsky wrote: > > One can be SW one can be HW. So I thought about having flexibility here. > > Instead of doing > > > > for (idx = 1; idx < MAX_IDX; idx++) { > > len = zcomp_compress(zram->comps[idx]); > > if (len <= threshold) > > break; > > } > > > > We would just directly use the suggested algo. > > > > But we probably don't need that param at all and can use > > the loop instead? > > My idea was that recompress does not loop through the algos (what > on the fly recompression can do for instance), but instead > recompress only does one thing. > > Because we can have, for instance, something like this > > algo=zstd priority=1 > algo=deflate priority=2 > > And we recompress with algo=zstd only first. Without going > into the slowest, most CPU and power consuming one. If the > memory pressure keeps increasing then we might do algo=deflate > recompress, as the last resort before we do writeback. But we > may skip algo=deflate altogether and go straight to writeback, > for instance because we have less than 30% of battery left. > > So the reason I suggested algo= in recompress was, basically, > for that for having exact control of what recompression does. I am thinking like this: * Without recomp_algo setup, user can do whatever they want on the fly echo "type=idle threshold=3000 algo=zstd" > recompress Later they could do echo "type=idle threshold=3000 algo=deflate" > recompress or writeback to backing device * With recomp_algo setup like this, echo "algo=zstd priority=1" > recomp_algo echo "algo=deflate priority=2" > recomp_algo .. .. echo "type=idle threshold=3000" > recompress If zstd fails, it will continue to work with deflate transparently. IOW, "algo=" in *recompress* interface will override the global policy in the *recomp_algo* setup. Otherwise, the recomp_algo's set up will work.