From patchwork Wed Nov 9 11:50:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 13037459 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 8518CC4332F for ; Wed, 9 Nov 2022 11:51:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2B8836B0073; Wed, 9 Nov 2022 06:51:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 269F08E0006; Wed, 9 Nov 2022 06:51:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1306F8E0005; Wed, 9 Nov 2022 06:51:57 -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 056F66B0073 for ; Wed, 9 Nov 2022 06:51:57 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id DBBD216144D for ; Wed, 9 Nov 2022 11:51:56 +0000 (UTC) X-FDA: 80113739832.02.AA5943E Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by imf28.hostedemail.com (Postfix) with ESMTP id 7C642C0026 for ; Wed, 9 Nov 2022 11:51:51 +0000 (UTC) Received: by mail-pj1-f45.google.com with SMTP id b11so16491329pjp.2 for ; Wed, 09 Nov 2022 03:51:51 -0800 (PST) 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=fD/HQF6HxapCqTpoXXzXl5JbbzI2VtbNVLVtgj7Z2vQ=; b=RhShf17fILimFsOPFe+/KrLFpCALNSEahDTJ3X6S5NNNdXcCWnSJrZME7yfGuEkQxZ gd5950jwzhQoG7mJKQjm3hha/ceoQVuR9jNntXiJBAr237RL5WdN9ZHj2W1MjXie495H hnriGG70Q53DtIUIphbDQ6l6eKnlqCtmKv1aE= 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=fD/HQF6HxapCqTpoXXzXl5JbbzI2VtbNVLVtgj7Z2vQ=; b=e+BaoJjmHmM5StNb2H2e6yu49cdmiVuKCDRRjZdA1cghkHscztJIKhyV5oAu4xvyGF xBTfRD8sPrv9ivbikkByiVGvu3ZRIDT2rJq25ipWmL+D0VTtS0CAhprnwAkeoiWEk13h AjckC55NN5hoZK5XygNI/c7+e/a/qjm72s8dDFOWp0zaW5pPBasCS6ZPKEM9/Z+mKABW R610GIoNIu+hObwuWHCPZo9M8rmLvP5P3GC0w9FMUzxcdifXHTDec/rP6y1/QPiFyqMq MJOz8MIeeRYWVTJUaVF8bf4UOrLCBrO1ttzrVC5P/opC66hNDatWB1v7zL7c/eh3NgMk i1cQ== X-Gm-Message-State: ACrzQf1dyr5W+1Tymy5ACVCUYGRMAnkf5gOGb49LqbtnnMprw5GzIRZl iGTD0uXHxVasw9x8A9ehOdcfhw== X-Google-Smtp-Source: AMsMyM5mwzK8guwIbu0zULgXWDM56Ayuz8XmyTNVrreNEf9XtB6ON2f2dC/7sWjGZ0eRkGUKUX2K5w== X-Received: by 2002:a17:902:ef51:b0:180:7922:ce40 with SMTP id e17-20020a170902ef5100b001807922ce40mr60060435plx.8.1667994654359; Wed, 09 Nov 2022 03:50:54 -0800 (PST) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:61f1:44d3:3f47:2cdb]) by smtp.gmail.com with ESMTPSA id f5-20020a655505000000b00434760ee36asm7292311pgr.16.2022.11.09.03.50.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 03:50:53 -0800 (PST) From: Sergey Senozhatsky To: Minchan Kim , Andrew Morton Cc: Nitin Gupta , Suleiman Souhlal , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Sergey Senozhatsky Subject: [PATCHv5 00/13] zram: Support multiple compression streams Date: Wed, 9 Nov 2022 20:50:34 +0900 Message-Id: <20221109115047.2921851-1-senozhatsky@chromium.org> X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667994711; 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=fD/HQF6HxapCqTpoXXzXl5JbbzI2VtbNVLVtgj7Z2vQ=; b=dRPefe0N8wCEsVlnJZLWLsdYs6XPSUFXDvcLfSyvBojiygrT20qODfBVHX+Aj1UeTGxdn5 6ns6aMgUU69gpnEaQDIr770JchYoNgxTPbwSP6QNyOjsp43Eoi1YdRPF/HgJumzyew5+WD SI5gf1WHciDN9C3MwzrZhRtmeQdenuo= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=RhShf17f; spf=pass (imf28.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.216.45 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=1667994711; a=rsa-sha256; cv=none; b=rQN7PdZN6c0/ogK+rXVei4+eoyemQBHD2Zj1026nw0JZKkPn6uijogCVxVDa7uib8DBzNa aqDyi7/iShCjIfQo70SyxJIH73/JVZ2SIimLMrWlyuB1Axz1sc/Gal/e24B29wlGiRk3KE TgazI7CKCi35rMIGMY0KtWAU+Zh4v0c= X-Rspam-User: X-Stat-Signature: kp7rdu8x3p7bu3ahu37hw7fahjj881o1 X-Rspamd-Queue-Id: 7C642C0026 Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=RhShf17f; spf=pass (imf28.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.216.45 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org X-Rspamd-Server: rspam07 X-HE-Tag: 1667994711-445653 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, 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 compression streams. 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. v5: -- Addressed (very valuable) review feedback from Minchan -- Extended documentation -- We now do chain recompression, tryin algos in order of their priority -- Support up to 4 compression streams -- Added named parameters to recomp_algorithm and recompress sysfs knobs -- Cherry-picked patch from Alexey -- Store algo priority in mete flags -- Renamed some fo the flags -- Added incompressible bit to block state output -- Added incompressible writeback -- etc. 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 Alexey Romanov (1): zram: add size class equals check into recompression Sergey Senozhatsky (12): 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 zram: Add recompress flag to read_block_state() zram: Clarify writeback_store() comment zram: Use IS_ERR_VALUE() to check for zs_malloc() errors zram: remove redundant checks from zram_recompress() zram: Add algo parameter support to zram_recompress() documentation: Add zram recompression documentation zram: add incompressible writeback zram: Add incompressible flag to read_block_state() Documentation/admin-guide/blockdev/zram.rst | 100 +++- drivers/block/zram/Kconfig | 9 + drivers/block/zram/zcomp.c | 6 +- drivers/block/zram/zcomp.h | 2 +- drivers/block/zram/zram_drv.c | 604 +++++++++++++++++--- drivers/block/zram/zram_drv.h | 22 +- include/linux/zsmalloc.h | 2 + mm/zsmalloc.c | 21 + 8 files changed, 685 insertions(+), 81 deletions(-) Acked-by: Minchan Kim