Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp5436488rwi; Mon, 17 Oct 2022 21:58:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4fOxoeQUO54ABv6CZ6ivNUHLp7h8ySH3LbanuuOu5TbLdoZl22MNYhw57/BcE35COHbiZL X-Received: by 2002:a17:907:31ca:b0:780:2170:e08c with SMTP id xf10-20020a17090731ca00b007802170e08cmr874006ejb.145.1666069094368; Mon, 17 Oct 2022 21:58:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666069094; cv=none; d=google.com; s=arc-20160816; b=uslEOs+FLNLt9AvRMqEc00yAIkb5Gn4v/7IfRkEzR1c8+BguRoIHeCJp5ZzQaT/DW3 V1yo3lKVrM/eNVUTuoxgHk+AggOTiRwmMkFccdcBrHJldSVYenvCr15h9CsyHhML4d1h ZXeCW/nCRMWoE7WIAqGR3nwbZXi4kiMkUARPyN3Q+y0jHjz1ZpcetqMaQbRuKt9yB6cA i9qYjCaiGQsQv+98dZ2ol6F0E8SjNyrvDAS5MYwDgDr1ySI8mN4W9i2dnkk9dLKS8Dsz N3emTEWHvqZpfg4wiqzMPsaVpZOVdA1bmnZMpJLe3p0gDieHymomTKWuklz2Z8k+JcIN c1lQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=w5tX9Wl81PhQGUCZyqodqMuBbo62lHvN02l/1DnN1CY=; b=G1Ves+q5dLaXkfupBnf9G122B4iEGmGJp/PaQ/HVyiO2akcrSBjjMzTQPXs71WNsFz ZZgFJXLMm+658DB8U9quFeaURUBnXOVB4fYUunSzqIZSSuHyc1VyLaWE73kQkjXnrL9a GnJNH+Cfzdq9MH3HqbjYQR5PsgCeTxHVjzj98RGaHaYH8VdNNuBhT3e3y9TZFt3QNNAr RkTebx8SI7d3HbWO9bz2Iazr75DfCZiEG2GvQr4bKysOVG54fh6+bnwF8ti7XuxwZ6ts rLB/hUgEkRqtVl5rvtCL/I3Qp/UP1xfCdcogUQGz1YoSFh5YQCisWeCbLdO+gapxnht5 yx0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=lBUzF0qS; 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=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hh6-20020a170906a94600b00781b67df7f6si10839095ejb.167.2022.10.17.21.57.49; Mon, 17 Oct 2022 21:58:14 -0700 (PDT) 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=@chromium.org header.s=google header.b=lBUzF0qS; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229935AbiJREzy (ORCPT + 99 others); Tue, 18 Oct 2022 00:55:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229491AbiJREzo (ORCPT ); Tue, 18 Oct 2022 00:55:44 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C6384F68F for ; Mon, 17 Oct 2022 21:55:42 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id g28so13018843pfk.8 for ; Mon, 17 Oct 2022 21:55:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=w5tX9Wl81PhQGUCZyqodqMuBbo62lHvN02l/1DnN1CY=; b=lBUzF0qSP6OCY8LpeWHglSg+CFL48y3RuTSeZ1O4eOctBVERnsUQPOZCfSaOXx2FFe 6sXFlLoCtPEmPSWnC9OsSS7FGu07HJG4ZRp6Z/t+un8YwAf3mWQ24BeJySA9IYqkIhzd xhKQv/2Dn1DIJGGN9jrRpHKuODXVuDYHvsqdQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=w5tX9Wl81PhQGUCZyqodqMuBbo62lHvN02l/1DnN1CY=; b=cb71AgFt4IeLROthQfQTiKDxgUaQY2nzavwrZfBIjrH5dIgZ+OQ15UkjgOiHqG+GGS 9xvmg88bTrDRC/2YNXk0SDg3t762X+4/ktH5Lo8MNIlNzy+8bTjJo7Tmg8zVsn2UQmEZ UHo7nSE9Z2xvQVQf2gh4DYzWsII0p9l7SgLsPJevfAElQuIdwkzDGmNg9CcW0Lpdn1G6 kbWYFXCQN9285SM28XdrQ6RH9IVIG1BgwKYmsi8sduYpIMG+Ia7hEpA3CkLEyWpdGIYR 7CLmrncLmxZXzzqoERxP8hOJsUtCkoXeb9YbUnx9SH8E8VxjO8V1CTCVvmmQ5FJREnMh V+oQ== X-Gm-Message-State: ACrzQf08AXuyUmiO2LJW8RDzpLKZzJRAAPNFMoDGQp98TAAmlbSYq/my 2Z3vD+4MypHaCDzFhcN2hiwemCPhrguo/A== X-Received: by 2002:a05:6a00:1406:b0:565:dc13:bb36 with SMTP id l6-20020a056a00140600b00565dc13bb36mr1386294pfu.46.1666068941843; Mon, 17 Oct 2022 21:55:41 -0700 (PDT) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:17a9:73b0:c262:eccd]) by smtp.gmail.com with ESMTPSA id p4-20020a170902e74400b0017b69f99321sm7549220plf.219.2022.10.17.21.55.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 21:55:41 -0700 (PDT) From: Sergey Senozhatsky To: Andrew Morton , Minchan Kim Cc: Nitin Gupta , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Sergey Senozhatsky Subject: [PATCHv4 0/9] zram: Support multiple compression streams Date: Tue, 18 Oct 2022 13:55:24 +0900 Message-Id: <20221018045533.2396670-1-senozhatsky@chromium.org> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 Hello, This series adds support for multiple (per-CPU) compression streams (at point only 2). The main idea is that different compression algorithms have different characteristics and zram may benefit when it uses a combination of algorithms: a default algorithm that is faster but have lower compression rate and a secondary algorithm that can use higher compression rate at a price of slower compression/decompression. There are several use-case for this functionality: - huge pages re-compression: zstd or deflate can successfully compress huge pages (~50% of huge pages on my synthetic ChromeOS tests), IOW pages that lzo was not able to compress. - idle pages re-compression: idle/cold pages sit in the memory and we may reduce zsmalloc memory usage if we recompress those idle pages. User-space has a number of ways to control the behavior and impact of zram recompression: what type of pages should be recompressed, size watermarks, etc. Please refer to documentation patch. v4: -- added IS_ERR_VALUE patch (Andrew) -- documented SIZE units (bytes) (Andrew) -- re-phrased writeback BIO error comment (Andrew) -- return zs_malloc() error code from zram_recompress() -- do not lose zram_recompress() error in recompress_store() -- corrected a typo -- fixed previous rebase errors -- rebased the series v3: -- conditionally reschedule during recompression loop so that we don't stall RCU grace periods -- fixed a false-positive WARN_ON v2: -- rebased -- mark completely incompressible pages (neither default nor secondary algorithm can compress them) with a new flag so that we don't attempt to recompress them all the time Sergey Senozhatsky (9): zram: Preparation for multi-zcomp support zram: Add recompression algorithm sysfs knob zram: Factor out WB and non-WB zram read functions zram: Introduce recompress sysfs knob documentation: Add recompression documentation zram: Add recompression algorithm choice to Kconfig zram: Add recompress flag to read_block_state() zram: Clarify writeback_store() comment zram: Use IS_ERR_VALUE() to check for zs_malloc() errors Documentation/admin-guide/blockdev/zram.rst | 64 ++- drivers/block/zram/Kconfig | 55 +++ drivers/block/zram/zcomp.c | 6 +- drivers/block/zram/zcomp.h | 2 +- drivers/block/zram/zram_drv.c | 458 +++++++++++++++++--- drivers/block/zram/zram_drv.h | 16 +- 6 files changed, 526 insertions(+), 75 deletions(-) -- 2.38.0.413.g74048e4d9e-goog