From patchwork Mon Dec 18 08:21:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengming Zhou X-Patchwork-Id: 13496349 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 DF401C35274 for ; Mon, 18 Dec 2023 08:22:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7CE6D8D0005; Mon, 18 Dec 2023 03:22:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 77EFC8D0001; Mon, 18 Dec 2023 03:22:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6207A8D0005; Mon, 18 Dec 2023 03:22:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 4FE398D0001 for ; Mon, 18 Dec 2023 03:22:33 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 1D07040988 for ; Mon, 18 Dec 2023 08:22:33 +0000 (UTC) X-FDA: 81579247386.03.04375EB Received: from out-182.mta1.migadu.com (out-182.mta1.migadu.com [95.215.58.182]) by imf10.hostedemail.com (Postfix) with ESMTP id F0315C0002 for ; Mon, 18 Dec 2023 08:22:30 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of chengming.zhou@linux.dev designates 95.215.58.182 as permitted sender) smtp.mailfrom=chengming.zhou@linux.dev; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=bytedance.com (policy=quarantine) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702887751; a=rsa-sha256; cv=none; b=AUxdAaXrusKt8MA0yYvPbGn+JiRdOvAPvKOdxM5QvovcQn7WBlF+mP4yOfzbmhZJ2Ru2Oy oElBBQ47ml4jiIU8mm+YUUotlHYAqhGYT3fHob03SRmR0WgBNGW9PPmDiJ6Gm/S1mMl9Vm pD/p7+XMih8wS3S24V7VaqHqoA/SH4E= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; spf=pass (imf10.hostedemail.com: domain of chengming.zhou@linux.dev designates 95.215.58.182 as permitted sender) smtp.mailfrom=chengming.zhou@linux.dev; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=bytedance.com (policy=quarantine) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1702887751; 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-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=dQj4aG31vHJRNCn+xACAmLOGZ/r5uNCxwBeg7JUz5ak=; b=PU9JD7a09RXQQMm9R/MOGMVTIR+ye1vi+DcJoncFchZJXTuxp3ECpwbuSlDnpDn6rdV326 pX448rbLMtMIcH4J+486TVaGQ78QrPfd8/e1WmHNLGkeil7VCnl/hYtLnyVv192dlxggQU ZfO3vWEvtNZhEgvFRJDeO1hZxYw9uKI= Subject: [PATCH v2 0/6] mm/zswap: dstmem reuse optimizations and cleanups MIME-Version: 1.0 X-b4-tracking: H4sIACcBgGUC/3WNzQ6CMBCEX4Xs2TX9UQRPvofxUNpVmkAxXcQg6bu78e5pMpN832zAlCMxnKsNMi 2R45SkmF0FvnfpQRiDdDDKWG20xQ+/3RMDzyONGBrT3I+1tcoGEKRzTNhll3wvUHoNg4x95HnK6+9i 0RLXP7ZFo8KmrU8irNugDpdunSmIjfZ+GuFWSvkC3W9trbEAAAA= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Chengming Zhou Date: Mon, 18 Dec 2023 08:21:59 +0000 Message-Id: <20231213-zswap-dstmem-v2-0-daa5d9ae41a7@bytedance.com> To: Seth Jennings , Dan Streetman , Chris Li , Nhat Pham , Vitaly Wool , Yosry Ahmed , Andrew Morton , Johannes Weiner Cc: linux-kernel@vger.kernel.org, Nhat Pham , linux-mm@kvack.org, Yosry Ahmed , Chengming Zhou , Chris Li X-Developer-Signature: v=1; a=ed25519-sha256; t=1702887745; l=1896; i=zhouchengming@bytedance.com; s=20231204; h=from:subject:message-id; bh=Mu7ono3rVOiRvaWdrV6EMpa/OwOeYsHxuqPojm+9aLA=; b=JWBO6A0V6VuLg5sz5Q4yvYA+UXolzYahLAQhdz616kPZHGOMj0NiIYW2r/lhMmDSxhYBYz+vh LajKKANM38uCcNVGAEUv4iplO4uoo6ake1uKSvkLGCbLqYo2wtgx20U X-Developer-Key: i=zhouchengming@bytedance.com; a=ed25519; pk=xFTmRtMG3vELGJBUiml7OYNdM393WOMv0iWWeQEVVdA= X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: F0315C0002 X-Stat-Signature: ggu56qf4ty1r4j3irz769rificub39ry X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Rspam: Yes X-HE-Tag: 1702887750-434373 X-HE-Meta: U2FsdGVkX186MH1yHCGzL44Fq7uSNHIHtdQuazOdAfHO7PmmBcoKrvGYLIQg2JzAqLFggo3UsQ8Cpv/HvP13MigC7rDBwVkBloLNz1Ah7TbeSJkwJjzcUFIS3iBrJU9JNNcHSFMqtj7caL651Gq4kbQHgx1SvZPPaaLycpmndKG+72wE4/ol03vTJMBYm+X+uqgQkwkekkl9XqS/3/iorCfr7wZ+wByJ7K5Zo6M8nsbiE0kx300iatv6AWO9T/fxDGi78H6F4QZm2wn3TtMcSz0V7QhGO0Pmssd63D/AIPHgt8EUxgiP8mQoFGpYi/zLLPwlzzeVB8Rrv2QemwY6f9WRqPnqVNIJYdxENj88O4l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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: List-Subscribe: List-Unsubscribe: Hi everyone, Changes in v2: - Add more changelog and test data about changing dstmem to one page. - Reorder patches to put dstmem reusing and __zswap_load() refactoring together, still refactor after dstmem reusing since we don't want to handle __zswap_load() failure due to memory allocation failure in zswap_writeback_entry(). - Append a patch to directly use percpu mutex and buffer in load/store and refactor out __zswap_store() to simplify zswap_store(). - Link to v1: https://lore.kernel.org/r/20231213-zswap-dstmem-v1-0-896763369d04@bytedance.com This series is split from [1] to only include zswap dstmem reuse optimizations and cleanups, the other part of rbtree breakdown will be deferred to retest after the rbtree converted to xarray. And the problem this series tries to optimize is that zswap_load() and zswap_writeback_entry() have to malloc a temporary memory to support !zpool_can_sleep_mapped(). We can avoid it by reusing the percpu crypto_acomp_ctx->dstmem, which is also used by zswap_store() and protected by the same percpu crypto_acomp_ctx->mutex. [1] https://lore.kernel.org/all/20231206-zswap-lock-optimize-v1-0-e25b059f9c3a@bytedance.com/ Signed-off-by: Chengming Zhou --- Chengming Zhou (6): mm/zswap: change dstmem size to one page mm/zswap: reuse dstmem when decompress mm/zswap: refactor out __zswap_load() mm/zswap: cleanup zswap_load() mm/zswap: cleanup zswap_writeback_entry() mm/zswap: directly use percpu mutex and buffer in load/store mm/zswap.c | 331 ++++++++++++++++++++++++++----------------------------------- 1 file changed, 143 insertions(+), 188 deletions(-) --- base-commit: 1f242c1964cf9b8d663a2fd72159b296205a8126 change-id: 20231213-zswap-dstmem-d828f563303d Best regards,