Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2321819rwb; Mon, 7 Nov 2022 11:52:55 -0800 (PST) X-Google-Smtp-Source: AMsMyM4khLSMva1ftEtumMRwUmPQHDDstLxbFSD1fotaE7JAo+kYe/lsB9ohmgfrfX7DGBqFJP5A X-Received: by 2002:a17:907:6d25:b0:7aa:f5a4:5f66 with SMTP id sa37-20020a1709076d2500b007aaf5a45f66mr48299104ejc.216.1667850774981; Mon, 07 Nov 2022 11:52:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667850774; cv=none; d=google.com; s=arc-20160816; b=d0abaZbNzadfpOJIFBO9quSeMIXcT22rkECeNNEgV3K88T9s6s1mQ0Z08CWs339lUq dADtfNUeaDz3cOf9CWsfiW8vLfUTdEZYqFkkv4I865brdpYk8IEvLo73QWuv3pgfl43O qyOpNTj3vZaoV3EtPK2ZkL5yuR/vdeAbhAz+FkflDKW90CN4rer/5bdF5uf01eJcXzZO DkwhGD+FgxDcnoQoWVqZZt9dsD3gvzdh9jXDul38Z+YNOvrXcZyB5RHdKKuR6iwu4FWI CzuOzyIiOmqGPqof1tADewKs7IVjLFYPou8PCPLIyz+Ub0Q8Yio69xPcopDEbqGiBlyV WeYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:sender:dkim-signature; bh=jTCNtbX3AF4Smxm3i3nu7Nj8Pslpw4wqg4w1w+kK/J4=; b=O2XyfkMqomISyNJlKreFn677BSLkGHpyTEmPnK6XIQD9UrWQv1w3J1pbQfzC9WuseE 1MLhq0OKgv8zPSdl2pA2MrQNQdEI1hXMHidfKHT1667yCTZftUC6VFxXqnio/XFRmRaC ma+CdfzunR3EDSztdbpWCiXsa3jwmAhGXJU59Hw/LEGP5DV21HoSYH/ZZ0rFjEE1NWhd odnTBZGu/9j9nL9VlobqKNXJMunYZSHL6CUGdtf9MD6TVcCliotU1zsVpI1qcXwsjsWa +obmhvXiRHWrJn3yPY3WNonnUyjnX6SpDKHwBlWL+Rc9PcGOevrmTEq/dJ9/D+S2ln0e oobQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="MNNfCg/5"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gn39-20020a1709070d2700b007aaf5a45f5asi10065522ejc.47.2022.11.07.11.52.26; Mon, 07 Nov 2022 11:52:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="MNNfCg/5"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232288AbiKGTIo (ORCPT + 92 others); Mon, 7 Nov 2022 14:08:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229912AbiKGTIn (ORCPT ); Mon, 7 Nov 2022 14:08:43 -0500 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 687E8DEB7 for ; Mon, 7 Nov 2022 11:08:42 -0800 (PST) Received: by mail-pj1-x1033.google.com with SMTP id m6-20020a17090a5a4600b00212f8dffec9so11205172pji.0 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=Kzq3xrft/DdsvplNVEz7ThlUcAlAKv4h6K3sx2fceu22//OcSUL8jTWw5VTAhWiIZg eshjSKgUelMdikFcIQngsR/dds3wQlUq78ndCqw8P6bkth2q3eOQjgGY3joDPiGaTuh0 w/63TkOk5GBG4trDRpiL3NCrhveGjnzp3d8wCwbqfs3EuoYPqGuISiuDQdJUVyKype2W TTceSaGQGRpUlWoUT0/TmMeNCZxSugZ94GIPAsfvJAVLOddwifeyE2MCYg1N9NNE/5JL 3MdHSNmjYa7D0K7vnhsDadHaCUkfAqZYdAivDOGjB2CUkJaVfQk4Ym2PCn63LaCTCk/8 U6Dw== X-Gm-Message-State: ACrzQf15crOVqXp7CJxBS5i/Ui8VIC7TXUUX5qkIvm93y/8owODow3ml mvQ2C8nUJH6N06GXxKBefxI= 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) Sender: Minchan Kim 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: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.