From patchwork Sun Oct 9 09:07:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 13001944 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 228CAC433FE for ; Sun, 9 Oct 2022 09:07:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4219F6B0071; Sun, 9 Oct 2022 05:07:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3D2B16B0073; Sun, 9 Oct 2022 05:07:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 272006B0074; Sun, 9 Oct 2022 05:07:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 12BE66B0071 for ; Sun, 9 Oct 2022 05:07:28 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D2563AB271 for ; Sun, 9 Oct 2022 09:07:27 +0000 (UTC) X-FDA: 80000832534.11.5477998 Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) by imf08.hostedemail.com (Postfix) with ESMTP id 724AC16001B for ; Sun, 9 Oct 2022 09:07:27 +0000 (UTC) Received: by mail-pg1-f172.google.com with SMTP id 128so360344pga.1 for ; Sun, 09 Oct 2022 02:07:27 -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=OmNZ7Fvou49eeIhvfz5hM/EsgwFjPxztP9XU1GE9RsE=; b=FexyzJTrCIszuDKNIyZmrwHuOIeMpJ2NrZxAGtH8ix/tVqOAo8HGuSefr2oSApIHns vskIoS7yhfRz4RxCpIaU6cfjkMvun80zZuoPJi7BjV6129r0CzUu3Gee8cgfFBrhnCZn f26mrzo6T62wBh+UPbUO11ZTcQ0jlCSuXu55M= 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=OmNZ7Fvou49eeIhvfz5hM/EsgwFjPxztP9XU1GE9RsE=; b=M60afWJUPrH8drsDmdfn2OJjQiW36tHTDZbT71G2w1t8WYYUxnX5g7lXnrfgNXVBeL qX8VlMj0fDYgh+5PBvrWCiUExV3YOUYFPgFbAA+vAIYkRm7HG0plxmIKXbyqoqdiLUfV XNnxhIwzce19qKpVDL3F4xLDO+8Ky2sxGPFQp54CJeVgD9fcQX7Hn+2VQJljmkFWDcm9 ZMCzD4me38mX39g15jLys+9W6JJwwO+fPpm2h0vMOKsfz/hnl3oYWJ9k4cGB3dRyb+qw eq/AtqDIIoM+xnZuxMOQZs7ES8flw/hKyCDi6DK9GCcpjtWMTc98Sz0tfXBtwtPSXYuc +MQA== X-Gm-Message-State: ACrzQf06tSM+sMduOdjSi/Pgdqic95n4aQpz201gKP0dxepyC5Um532g fC62vlMpNMxhkD3M2phUpF1Eiw== X-Google-Smtp-Source: AMsMyM6i0znQqZ8p7YT6afOgbTg5EelaP7ZkWjPWVpm3n6Jk5WRvk6lpR70aeaG4k8u8dn6EmCDNxg== X-Received: by 2002:a63:5656:0:b0:446:8eb5:a2c5 with SMTP id g22-20020a635656000000b004468eb5a2c5mr12032763pgm.336.1665306446391; Sun, 09 Oct 2022 02:07:26 -0700 (PDT) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:8517:d51e:5fe9:9be7]) by smtp.gmail.com with ESMTPSA id q194-20020a632acb000000b00439d071c110sm4335148pgq.43.2022.10.09.02.07.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Oct 2022 02:07:25 -0700 (PDT) From: Sergey Senozhatsky To: Minchan Kim , Andrew Morton Cc: Nitin Gupta , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Sergey Senozhatsky Subject: [PATCHv3 0/8] zram: Support multiple compression streams Date: Sun, 9 Oct 2022 18:07:12 +0900 Message-Id: <20221009090720.1040633-1-senozhatsky@chromium.org> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1665306447; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=OmNZ7Fvou49eeIhvfz5hM/EsgwFjPxztP9XU1GE9RsE=; b=abYjnUn2WD8QQoj9MkQ6cNKbj9jvkKdY3I/+aFYVCxTxL0rd1aaeGKIz5L9DOh1OioMa1m OJkURFW0zrhFjiALnYt++vihagU8+AEz2++ZdjsiUVV/4RAYxbuyUQXt3uhdiGUGKNBI5H fBCwsDp/Lb41Pi7+kWO3wbkq++4fFJw= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=FexyzJTr; spf=pass (imf08.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.215.172 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1665306447; a=rsa-sha256; cv=none; b=54KOninCwmwIVOFmQkS28/qPDoGWNLqGCVk67V4P4iMuLatkEUVM2ZQZLGBSjzLYobwGM+ JuC9hPotAov0UlD04Lvq3rNjcVlORm08BfzIssWSQ2yMdxbLRfsgfmhJivMIRVOvsw7jfO L9lRL2a/DAvKQSQ4fJgW8MZdrekCado= X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 724AC16001B X-Stat-Signature: tx1a1k7hnmc6wrprqspedn57kr1c6wnj Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=FexyzJTr; spf=pass (imf08.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.215.172 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org X-HE-Tag: 1665306447-877665 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: 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. 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 (8): 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: correct typos Documentation/admin-guide/blockdev/zram.rst | 64 ++- drivers/block/zram/Kconfig | 52 +++ drivers/block/zram/zcomp.c | 6 +- drivers/block/zram/zcomp.h | 2 +- drivers/block/zram/zram_drv.c | 441 +++++++++++++++++--- drivers/block/zram/zram_drv.h | 16 +- 6 files changed, 510 insertions(+), 71 deletions(-)