From patchwork Tue Oct 1 05:32:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sridhar, Kanchana P" X-Patchwork-Id: 13817480 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 A902ECEB2FD for ; Tue, 1 Oct 2024 05:37:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 51F346B00BB; Tue, 1 Oct 2024 01:37:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4CEDD6B00C4; Tue, 1 Oct 2024 01:37:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 396186B00C5; Tue, 1 Oct 2024 01:37:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 1C59C6B00BB for ; Tue, 1 Oct 2024 01:37:12 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id BB234AC2EC for ; Tue, 1 Oct 2024 05:37:11 +0000 (UTC) X-FDA: 82623925062.15.027A75A Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) by imf20.hostedemail.com (Postfix) with ESMTP id AB1481C0008 for ; Tue, 1 Oct 2024 05:37:09 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=PdAW3Ghn; spf=pass (imf20.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.11 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727760902; 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:in-reply-to:references:references:dkim-signature; bh=gZv4LykG9QLKvMczgn2ESTNiDzzsQysM39q/qNvh7tc=; b=L9KRv5cYIpcHGga9B5CG3FI9yK0N0fFQS7z31pN87vaMZrQOW7JyJfFjpnaWSo+A63NAbi 4LjdHKe9SQxyEp/RAuDarXj4Tct3FUjGh+7tSzBGKotZN8E1J8GaleD8sINYXw5FY7Vjz5 nNKx7xemx3c85i/4a2q6M05+C0mYJEY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727760902; a=rsa-sha256; cv=none; b=e1CeHpkpSUkfV0X+nZAEUpIDOYtMdpbVp2QySCNYWSXhGy4gLEai3p5pkEWFUtMcyucYei OxKo2b7MyzGJEtOuY7Hg6Hu31uJzNA4CCNuABLQBFRbECl5B+nq+OvLgJIgR5HAjad8Dyw D7jXjKefK1fTypcdNmAcWTTCNCZCzik= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=PdAW3Ghn; spf=pass (imf20.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.11 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com; dmarc=pass (policy=none) header.from=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1727761030; x=1759297030; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HXPnxaS0BG2kkNkoIrCoeh8TspMXuNCwKniqdIZtWWM=; b=PdAW3GhnOLvk2XPIf6D6k5j/YPsAoY/BoZfnjgLktOZ/Y5veBu1w7xZo zn0ezpMWLj9ZRwMT2kYbIXScKjCXuL4/VhAl8SMz/f3nkGmjkOP5hhRHG Rvwg8l+DmwMmPOkeUl6iB4rjHt9GaHedxnKddF1xN/i+mBeGPFflfNl9S +IvubEDDbK+ENkYwdgaBOBvcX6nqffD9NT17iDdWzFO3mVJHSjJTYzoZz 5CPnArL299fZAQnqLRWU7U+EtyGBVl3aUQEo+ReUcmzn6148qahD9RBgt hi8mbU3bdjga1i8uIA6Oq3TbbvfPfb7E1WIFp/EGOpBtAW0s1JToQg76g w==; X-CSE-ConnectionGUID: KDPDi6kKSlKOQritbz2PCQ== X-CSE-MsgGUID: HX+Oz8ejRsmvp07QIEWGcg== X-IronPort-AV: E=McAfee;i="6700,10204,11211"; a="37465068" X-IronPort-AV: E=Sophos;i="6.11,167,1725346800"; d="scan'208";a="37465068" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2024 22:32:23 -0700 X-CSE-ConnectionGUID: 5FyCjXUQQY2zJJxclxHnuw== X-CSE-MsgGUID: 4DdRtYD0TvK3eIsp+yhRmA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,167,1725346800"; d="scan'208";a="73205793" Received: from jf5300-b11a338t.jf.intel.com ([10.242.51.6]) by fmviesa007.fm.intel.com with ESMTP; 30 Sep 2024 22:32:23 -0700 From: Kanchana P Sridhar To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, hannes@cmpxchg.org, yosryahmed@google.com, nphamcs@gmail.com, chengming.zhou@linux.dev, usamaarif642@gmail.com, shakeel.butt@linux.dev, ryan.roberts@arm.com, ying.huang@intel.com, 21cnbao@gmail.com, akpm@linux-foundation.org, willy@infradead.org Cc: nanhai.zou@intel.com, wajdi.k.feghali@intel.com, vinodh.gopal@intel.com, kanchana.p.sridhar@intel.com Subject: [PATCH v10 1/7] mm: Define obj_cgroup_get() if CONFIG_MEMCG is not defined. Date: Mon, 30 Sep 2024 22:32:16 -0700 Message-Id: <20241001053222.6944-2-kanchana.p.sridhar@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20241001053222.6944-1-kanchana.p.sridhar@intel.com> References: <20241001053222.6944-1-kanchana.p.sridhar@intel.com> MIME-Version: 1.0 X-Stat-Signature: a4x5tga7byntsc79n53rzhy61nis8t33 X-Rspamd-Queue-Id: AB1481C0008 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1727761029-149368 X-HE-Meta: U2FsdGVkX1/8qQuIwq8MDDvsuzAFevmdWEFUt6W05NfphI2VWZxEI1ugxY0lSLy8aq+py/EJS//s0ukFkLO/ooWOB/v0kt4RykSGi/Q9dKFq8jCRCsSKJHJhu3igQg9YYo5dDP8Oi3mLevCdX2NVXHJj456qWuj6atZ5sWQYz4klyCUl//wUqhfpvC4xgJB4FCxbzl/uCDTFd1wwwO40dYO6BCK9ka2pL9jbs5F9KrNVjcKJM1n/7YM1LXNOAU7YwtbNsf+jwpUJPIrMf1DTlc+5U+tKFHDUXI6A0zGl4OaVJUvEg/AgTCcqpSiphQcna746AUrlShJOWnwGTLMDRL/5rjHuyC5hLvR2i0vV0jNuzyfmDSsjWEzfd5hJ3lelCjaBa0PGa0OeYSix0+qYOB67iRO1FxUfZOVBvJM9eE978uAoBKWQK86vkcKComtuStwFK9gHEeApBOWrb3r6JdE788gTBIqrpU2Zl9Y4TSfn+8UUleqtl34c1owqVxw3oSm0KAicb9PqfIPnIhVya/QA4bYJjPtvwB3TPVljLPmeV2G2uA2FTNSZ/GZrSirMmFnp3Vgo8RkvK+73dVEAoPatq/qvZrIqMhgJOjweFaf1FietO56jxgceqZz5N83NU6r4c3dyR1ahZS5b1WVebGySmQCCvg9qTZ4rQOVxxXIzUJButkLpmy5ZG2r06B2bmqkPX9f5JJSxiFcSWbA/L5TemUHyKzcCF6WaMPplldUyMa8hWjPi1ZIlRnuxQu66qn68NC46xVEkzapGz2YYAt5vTFYcnPScS+5gwhIoktZ2Cw9FAu9pYR15CT2RdMaZ3zL0Lu4frfibK1eXdYNqpJIwheEX1QWU5Lkv2UNtBoJ9TRNuBXsmaAlT+i1QNMHvfuELu/h/ZdMi2C5XZxrVArh4JlV2W6jLn9FoQvXpizSofZzVAwBkMcfnxm0yBX0P+BHCCY5VGOhts0tGDPv 0wuPWEhZ WJpmNakZjWbD3wlCvBdn6tEPcbK772e+BmwnKGcWPfPoEXbYPmswuJDnDSDE3DZvmjIkUlarKYa14HyAlfCCQjY6TAmxaud39sgLtIf192vJEZi83eLiAbKT/MWlBGfGC6szUnw91C1RzwMUZp4Y1h5SpefRIX61CwFJfBvEI/zBYco3j0kASqk2KfCZmj7seGbpUdXNZ5KUYo0bis7OIxBUR3ydp58LaG2xIpVIsEAqa1iA234WURoHSpLdhaDXZfrUAdZmL0O68k2lETCL1CBU0TvBfA51hkydTGwmus9ec8yejNUcT7CcujlSjKDEsWwxbUUkDFABDmkOF+6GdKj7dpQ== 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: List-Subscribe: List-Unsubscribe: This resolves an issue with obj_cgroup_get() not being defined if CONFIG_MEMCG is not defined. Before this patch, we would see build errors if obj_cgroup_get() is called from code that is agnostic of CONFIG_MEMCG. The zswap_store() changes for large folios in subsequent commits will require the use of obj_cgroup_get() in zswap code that falls into this category. Signed-off-by: Kanchana P Sridhar Reviewed-by: Nhat Pham Reviewed-by: Yosry Ahmed Reviewed-by: Chengming Zhou Acked-by: Johannes Weiner --- include/linux/memcontrol.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 34d2da05f2f1..15c2716f9aa3 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -1282,6 +1282,10 @@ struct mem_cgroup *mem_cgroup_from_css(struct cgroup_subsys_state *css) return NULL; } +static inline void obj_cgroup_get(struct obj_cgroup *objcg) +{ +} + static inline void obj_cgroup_put(struct obj_cgroup *objcg) { } From patchwork Tue Oct 1 05:32:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sridhar, Kanchana P" X-Patchwork-Id: 13817482 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 6E272CEB2FD for ; Tue, 1 Oct 2024 05:37:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 101106B00C4; Tue, 1 Oct 2024 01:37:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 013FC6B00C5; Tue, 1 Oct 2024 01:37:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DFB5A6B00CC; Tue, 1 Oct 2024 01:37:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id C1B236B00C4 for ; Tue, 1 Oct 2024 01:37:13 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 7CDFE40C84 for ; Tue, 1 Oct 2024 05:37:13 +0000 (UTC) X-FDA: 82623925146.21.E326DBA Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) by imf05.hostedemail.com (Postfix) with ESMTP id 072D6100006 for ; Tue, 1 Oct 2024 05:37:10 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=WGbGidHP; spf=pass (imf05.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.11 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727760904; 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:in-reply-to:references:references:dkim-signature; bh=22u3xN6mg06byfZK8t7nFX35eMVdhAnR4N1qjCNuJIE=; b=32Mrc05vVcEtW7OeR3q1mtKmAvyLnRV3k54fCiqQmXqd180x3WhsCf6yRkYZOIdnGpyXDz Dun9xdX/xzcQrAUL8SKbTaVhozx3b9eRCvSlM1cG3DVkXC5ZUDfnHKp0Mlr4rHry5e7y38 YLxEjAUIo6cF0xwYFR3ilSsMvjnsn5s= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727760904; a=rsa-sha256; cv=none; b=TMfaaVCO/IzLWVf/BQLxejG7lYjL4t+WntvAFwoXN2hYlVuUMNNlMKNq/X5d2MBIDVAGyu 8Rtf9IUmDGRtDQY1h6tVYKsPbJBgOeh18XCLll5d8k5X+d1sdvXwYjiWq//vsaqwOhqk86 bUW3quStWklvTjruMg2td9zSPSaE4A0= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=WGbGidHP; spf=pass (imf05.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.11 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com; dmarc=pass (policy=none) header.from=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1727761031; x=1759297031; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=efGW2zzH8VCItzcrEw7X5/h61cbLWY8/tK2pA3rWPZo=; b=WGbGidHPsdCy4HetmUxJ/jmBtQlS82EvUlXps4gy2jqxqwTcsgMWpCye PyIPny4eEEst33WL44d9PAYAZ1Fp/uZf8JmNeAx8W00ZThOSdlQwRT8aT ZSV1DB8rmJoCq8cK5mCM4577XdHzL1kd2A3YAp53L5r7KfyKKTH69bAB/ CwvfSiZF38L2s+TC6/8lUTHByMl6l19/KeUYLSp9Ldpl6/prTyeQ2GAVa Q7nhBXbAuLO3G3FhGt8TwT5pXBPjhLssJej8Sj2R644GtNpxpOKT8InnW kQCNoYIITb8Fy1mtOpxQHprO+x3SLhVtny8MR/pYbML15kvt3041i446Y A==; X-CSE-ConnectionGUID: EjlLjs5zQlGQJnPx8FtzWg== X-CSE-MsgGUID: hj8LwCaaT4WshtYVzIKLVw== X-IronPort-AV: E=McAfee;i="6700,10204,11211"; a="37465081" X-IronPort-AV: E=Sophos;i="6.11,167,1725346800"; d="scan'208";a="37465081" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2024 22:32:24 -0700 X-CSE-ConnectionGUID: w49pgGxrSHOs/Gotpi9JWA== X-CSE-MsgGUID: AyNh3wxhT7C8wmJiQpdeOg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,167,1725346800"; d="scan'208";a="73205798" Received: from jf5300-b11a338t.jf.intel.com ([10.242.51.6]) by fmviesa007.fm.intel.com with ESMTP; 30 Sep 2024 22:32:24 -0700 From: Kanchana P Sridhar To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, hannes@cmpxchg.org, yosryahmed@google.com, nphamcs@gmail.com, chengming.zhou@linux.dev, usamaarif642@gmail.com, shakeel.butt@linux.dev, ryan.roberts@arm.com, ying.huang@intel.com, 21cnbao@gmail.com, akpm@linux-foundation.org, willy@infradead.org Cc: nanhai.zou@intel.com, wajdi.k.feghali@intel.com, vinodh.gopal@intel.com, kanchana.p.sridhar@intel.com Subject: [PATCH v10 2/7] mm: zswap: Modify zswap_compress() to accept a page instead of a folio. Date: Mon, 30 Sep 2024 22:32:17 -0700 Message-Id: <20241001053222.6944-3-kanchana.p.sridhar@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20241001053222.6944-1-kanchana.p.sridhar@intel.com> References: <20241001053222.6944-1-kanchana.p.sridhar@intel.com> MIME-Version: 1.0 X-Stat-Signature: qfugxpjh6gfopmcehiibrtuxnzn1ek1u X-Rspamd-Queue-Id: 072D6100006 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1727761030-760771 X-HE-Meta: U2FsdGVkX18KM3BcZH+KEehx8yWCLO8JCiMWoEi6uxg7K2q5DnqWqSfCk4D8JDHbRIwdCrh8pF9IOeygMmPc1tqIfvYR9ZRXiQTXIS08n7lgpM6JuLwc3xf3VWWHyNd03HTmX8decGLbWb+xWvfPjvHjfwZD6RJxuFmS2y3fwqDUTJxs0bhY/LK68gGILi2oTfWsCs56PGOFgOozuXHv37lyG5w9OKPMA8taim4Eo49vzdyh10Stt7gdNVC4wKixMtPd35Uf7wbB7tBrlh2LgC3O5dSvAirEyyjkDJv2gcSnos5cYh+FQTW7iOc3SKNPmB1svyP3HARd4riJppOa8sFsl8C6Aus/+94jj8uZ4j6j9/cFMxC1zndsjENazP0N28C1GoWo4em3BUWPqmvQGtrTQeRH9TU88hCHu88DNUybOtvoXaDFfHxa0yQrp+CTr4YKh61UQCZcPiuSTq1qDQtAK18iAz7IUMBd2KaVZYhMj4+Mi4/L6uMGcsST4NJdWcWN3HN9I13W0Hl8lU7NWZwzgcPn0hVsPH+Q0bh4np9pecdCcR6kZXcdcSRQyp5o+DrFybqX7xC14gE41WVvs1sZcELN8SEuguIw6MMa3zBzekeOxz77nwUp/CwOkEOVnYrWQogjvZ9YR3LT4rMRGybqTXzE1l5JRnWWhFRrdyDZg6oktmrf+dHOD57BFZli45yjx4QcOf7vo/0XzzzKdanbNoiHTF10SaJ3eIfPUMDgP7j7//4YqQm2l4SfuBuXjGM0R9ms2SUWi+JRzpi/Es6E0gVS6VrhRwoKAfTUHRsZZmjIzJPmqLR9/slnAp4v6lICZiBXTfWYTEJ0Rq/iOK5X/Yb2b6rL40ZUqD0dyDbFXNjoeeNhboU43oVh3NDH7pVSxRB+SCZQrLJGWjodM0Vt5cPzO5s/FPTpBSClSg5TAhP+jKjGL7f7Jt+ADRz7jHYYDTVtnffeeYWW2C0 tx2BTP5y Fjq9I9FCaZ1NIWS2jKJ27JjPGBEUK7I/bsBST5cSDawEs6ja3+UALiCKKs7P9idHNEtRc7tUeVPMGYRbjA7HrEe6j5HND/UfdayK35D25OSc5QyrZ10kRECfrKnPgADLQBVkjWotkxkzGdCLAwTALIVAqIeyCof3aBw0XiCbA9h8wnj0hj3htWXM3wcv516c5rO7bQr/5EEY/DqpBRfXYGR/Ubl5LenH1moNqy22Rj/pYNuBQvs+mO9aOUZxNGNzfyuzXZjOLQ+qtzttWwfXyQJxufzYOXzf1t0Kpw6xCubDZsNVdfl3ibF5kHi12fCKhNNhgnzTkICgZMNdmOGoZoy/chVpH5CI+MbF6jQUM2Sl2HLw= 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: List-Subscribe: List-Unsubscribe: For zswap_store() to be able to store a large folio by compressing it one page at a time, zswap_compress() needs to accept a page as input. This will allow us to iterate through each page in the folio in zswap_store(), compress it and store it in the zpool. Signed-off-by: Kanchana P Sridhar Reviewed-by: Nhat Pham Reviewed-by: Chengming Zhou Acked-by: Johannes Weiner Acked-by: Yosry Ahmed --- mm/zswap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/zswap.c b/mm/zswap.c index efad4e941e44..fd7a8c14457a 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -875,7 +875,7 @@ static int zswap_cpu_comp_dead(unsigned int cpu, struct hlist_node *node) return 0; } -static bool zswap_compress(struct folio *folio, struct zswap_entry *entry) +static bool zswap_compress(struct page *page, struct zswap_entry *entry) { struct crypto_acomp_ctx *acomp_ctx; struct scatterlist input, output; @@ -893,7 +893,7 @@ static bool zswap_compress(struct folio *folio, struct zswap_entry *entry) dst = acomp_ctx->buffer; sg_init_table(&input, 1); - sg_set_folio(&input, folio, PAGE_SIZE, 0); + sg_set_page(&input, page, PAGE_SIZE, 0); /* * We need PAGE_SIZE * 2 here since there maybe over-compression case, @@ -1456,7 +1456,7 @@ bool zswap_store(struct folio *folio) mem_cgroup_put(memcg); } - if (!zswap_compress(folio, entry)) + if (!zswap_compress(&folio->page, entry)) goto put_pool; entry->swpentry = swp; From patchwork Tue Oct 1 05:32:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sridhar, Kanchana P" X-Patchwork-Id: 13817484 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 88657CEB2FE for ; Tue, 1 Oct 2024 05:37:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1778F6B00CC; Tue, 1 Oct 2024 01:37:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F2F386B00D6; Tue, 1 Oct 2024 01:37:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D30C76B00CD; Tue, 1 Oct 2024 01:37:14 -0400 (EDT) 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 A838D6B00CC for ; Tue, 1 Oct 2024 01:37:14 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2369C80E09 for ; Tue, 1 Oct 2024 05:37:14 +0000 (UTC) X-FDA: 82623925188.04.E9FD941 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) by imf20.hostedemail.com (Postfix) with ESMTP id 08E621C0008 for ; Tue, 1 Oct 2024 05:37:11 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=Ab4QoyS9; spf=pass (imf20.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.11 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727760905; 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:in-reply-to:references:references:dkim-signature; bh=5EdKqjOL7o3kOjKhQvu2azcBBD6RrwG0Yp5W/R+zxPE=; b=6/MWetLdCFM6ERid1snUP1cnqSxvt4l2vZYRaNl3OVCICcJfb+XQ6vfT7KUBD/4MupAz/K cU5K1OczTkcvJeF6ZsA7nhB1SkZ/7XYylsUC9lYCP0j0JJqSfoah1Yo9bBmFoHZpjoiU4e NJkATj9ZxtijOMqWaizinIzkwhkKRls= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727760905; a=rsa-sha256; cv=none; b=OfV3IlKQxHybEICwN+0ibXm7c5IBYqaY7M74lFcGjy5MzWtWbYLbtqko/FJtpoNep500x5 T0k5p6qKL9JvCmfDUxzalk0muputV/0fD8wRQxJmtQ69TLmYoMRCqbq1D4W2f6AIPoXICd iCS4oZFcC8N8mz9uq/2qvcAP35w7ZFo= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=Ab4QoyS9; spf=pass (imf20.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.11 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com; dmarc=pass (policy=none) header.from=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1727761032; x=1759297032; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RXFigHVvqX66h0CgnEPMdbPUVdZNL13x+vDE/BJrhj8=; b=Ab4QoyS9DT9Q5YqFN2G1PMCR6adPH4hjn+NLZyEakM8fH33rbjxNvLd2 6n3Bt8CgkR4BxnsljeWLeb/TjzybWDvFs/Y6NjjgsMUABqCbjv0jc5NtJ xvUHYlkURHdWNRnsySLnY4ri7Php+GR8p/7YYCH9CUEFJt1upqYLPTYbv l3bwQsUxy408gg+n2N6k/AbqEWENsiVTHSH/E5zUT+RnqfoW6ZJLEYCBE Q9WjyEFgU2apnnwcRlokMOgvXg15aGUDk8/6EwjcZL4710Ie3HQST7V8l ngqeuq6HzuyW8Bkh0ilP5Z6zJv+4cwwZSYehKxnLDUUvs6zEePKiLc6xM w==; X-CSE-ConnectionGUID: eVKhq27bQFqbx4L/avhHxA== X-CSE-MsgGUID: lgFcRjdIS5C4mga3A82AcA== X-IronPort-AV: E=McAfee;i="6700,10204,11211"; a="37465094" X-IronPort-AV: E=Sophos;i="6.11,167,1725346800"; d="scan'208";a="37465094" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2024 22:32:25 -0700 X-CSE-ConnectionGUID: 8AwPM96ESfa4/3bCeF/HBQ== X-CSE-MsgGUID: +JTWy565Q2O8jcvuOpSgUA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,167,1725346800"; d="scan'208";a="73205801" Received: from jf5300-b11a338t.jf.intel.com ([10.242.51.6]) by fmviesa007.fm.intel.com with ESMTP; 30 Sep 2024 22:32:24 -0700 From: Kanchana P Sridhar To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, hannes@cmpxchg.org, yosryahmed@google.com, nphamcs@gmail.com, chengming.zhou@linux.dev, usamaarif642@gmail.com, shakeel.butt@linux.dev, ryan.roberts@arm.com, ying.huang@intel.com, 21cnbao@gmail.com, akpm@linux-foundation.org, willy@infradead.org Cc: nanhai.zou@intel.com, wajdi.k.feghali@intel.com, vinodh.gopal@intel.com, kanchana.p.sridhar@intel.com Subject: [PATCH v10 3/7] mm: zswap: Rename zswap_pool_get() to zswap_pool_tryget(). Date: Mon, 30 Sep 2024 22:32:18 -0700 Message-Id: <20241001053222.6944-4-kanchana.p.sridhar@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20241001053222.6944-1-kanchana.p.sridhar@intel.com> References: <20241001053222.6944-1-kanchana.p.sridhar@intel.com> MIME-Version: 1.0 X-Stat-Signature: 1n3k3b86kgqpdw7ozok3uqdtcz3sbp5a X-Rspamd-Queue-Id: 08E621C0008 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1727761031-719065 X-HE-Meta: U2FsdGVkX19eviJGc3VyWuZEntXBhaXNDvORYo+mqL89wGw4614pcdCiybraXRsBZrdv4OD25chroaqCBpX8ylApYO6auL6++Cmjxasdi4Na9MfGxRggS6kyKYFL6ydoGdur3whDcmpxeUXTtU9ID98vDGN15KpQmGZGHxFFpX60dHfonxM10oR1L5aTawbX9NVqpluLams/nwES1mwl9eiT+XOkZBh3d4t0CU6FKE+F8Axzeoz6Eevs/eBFPvL9murKn/x8A2NuzlPIfERnQCQZHIqMWuJWWpalUf1/cD0SwSctxenUVLv2bOzo1Bkcof0ohqt7LZuTSI0EnXrQ15Bp6R800Wdb3OkI5Mwdcp+99ghEE+GQGPMqWLvdTFc/MeNSobk+NIei3sknXJMDzfM7cCM8pfXUu418ggujI0CmvyBTsaOvVI0+2WdDsixYhiA6/fOl1Rb1+oGSTVErlzmeE8YjS0HvY6l49gB31t6VqE6vLep9xWgGAmKeT7ZOw1GljtU+dPWcJND7tuz2+GQPO8TJGjBmy5q+qfsOwL9CPKADAkaNDk5jCVKcvI1ShfeAap8M35r8Rnh3E4M6cEmwNMDtovSnD6ywvZdJTZCubmf47Q9eSAkSoDvChyPeZqZTr4XHvRhAxSWxbRxt0ezVnMM0OEt0KFVA23LvmG6RUA03mjvYEksLgszzn8Md+4HDMlEvhBycv70NZVQyJMiPWYPJehgaHOaWRRQZg3QNDwRE9YSQkaFTldRZNbqLFgqIqkfMAiRGJg/4TbhpCp0YPEYZLOw7DcbUqe5jxKLfZXBDSVY/2Rjv17bP6ZfJaSaAPK1wd9dh+FGJzhkDe405wbg39sMp0QeKph+G3E9dtcNtr+DaBCX8a82uQetAXaRmvfKlH4gVMURQjD8DVJ8SNutJTqEbP3V/JOAOQgddlYZ60zHY2N227K4IqgDEgW3N5Kd93BI2RhDh9b4 DC425xHI olVV8UPlRHpKdakjZNffClgVRJaS3Uo76T4Dy7e5rZlS7bdxGnKJI4dinXJNDEVS7+DjEr1Spqdp1g64CYu8WYWb9HSNFzmtTdewyqGpKb5cOb0/4OwCTB0ub/wQ9ghVxn9fk+9xoMTG02Q1NxpCPRYgp4rf32drt4VgcWXN45UdHVZLue7cfY9/bLKStz+Dkc2j8hYJ2PyfOzKUN2L5XZg3Vh4xAnWuq9AL0zmnU91DsOdxtTYaW7h6YCo1cNJN23y296N6sC3X7qxMwPzJgQL/nddUHAxx28a5j/Uer7lnWtv7pCYTs3PTqNv2WdYA/7MmKP9nWB1kPxJkEBqVnfnzXYQ== 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: List-Subscribe: List-Unsubscribe: Modify the name of the existing zswap_pool_get() to zswap_pool_tryget() to be representative of the call it makes to percpu_ref_tryget(). A subsequent patch will introduce a new zswap_pool_get() that calls percpu_ref_get(). The intent behind this change is for higher level zswap API such as zswap_store() to call zswap_pool_tryget() to check upfront if the pool's refcount is "0" (which means it could be getting destroyed) and to handle this as an error condition. zswap_store() would proceed only if zswap_pool_tryget() returns success, and any additional pool refcounts that need to be obtained for compressing sub-pages in a large folio could simply call zswap_pool_get(). Signed-off-by: Kanchana P Sridhar Acked-by: Yosry Ahmed Reviewed-by: Chengming Zhou Acked-by: Johannes Weiner Reviewed-by: Nhat Pham --- mm/zswap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/zswap.c b/mm/zswap.c index fd7a8c14457a..0f281e50a034 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -403,7 +403,7 @@ static void __zswap_pool_empty(struct percpu_ref *ref) spin_unlock_bh(&zswap_pools_lock); } -static int __must_check zswap_pool_get(struct zswap_pool *pool) +static int __must_check zswap_pool_tryget(struct zswap_pool *pool) { if (!pool) return 0; @@ -441,7 +441,7 @@ static struct zswap_pool *zswap_pool_current_get(void) rcu_read_lock(); pool = __zswap_pool_current(); - if (!zswap_pool_get(pool)) + if (!zswap_pool_tryget(pool)) pool = NULL; rcu_read_unlock(); @@ -462,7 +462,7 @@ static struct zswap_pool *zswap_pool_find_get(char *type, char *compressor) if (strcmp(zpool_get_type(pool->zpool), type)) continue; /* if we can't get it, it's about to be destroyed */ - if (!zswap_pool_get(pool)) + if (!zswap_pool_tryget(pool)) continue; return pool; } From patchwork Tue Oct 1 05:32:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sridhar, Kanchana P" X-Patchwork-Id: 13817483 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 B4D79CEB2FF for ; Tue, 1 Oct 2024 05:37:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E497C6B00C5; Tue, 1 Oct 2024 01:37:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DA7F26B00CC; Tue, 1 Oct 2024 01:37:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C96AC6B00D4; Tue, 1 Oct 2024 01:37:14 -0400 (EDT) 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 A75006B00C5 for ; Tue, 1 Oct 2024 01:37:14 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 54837A043F for ; Tue, 1 Oct 2024 05:37:14 +0000 (UTC) X-FDA: 82623925188.30.C826ACF Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) by imf18.hostedemail.com (Postfix) with ESMTP id 265521C0003 for ; Tue, 1 Oct 2024 05:37:11 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=d5co79sR; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf18.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.11 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727761012; a=rsa-sha256; cv=none; b=8osLFkCImOpeKBN74IeUvopJlXArcgccakpHGWL74YHc4Y6mm1WMZGL3i/styRauGWCp0J rlqDK9VIqqyHCODVNXDGN/65pNj7wqU4spz6GUbUPjFztMYH3NlmfuxA7GnpdnGVGkQo5N wzoy64EQxA9YHqZiAc2Ly/NviinHhlM= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=d5co79sR; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf18.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.11 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727761012; 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:in-reply-to:references:references:dkim-signature; bh=M730LVfFwW6rpjl4uQCMiFS0gVBAbwK2DJXQPTJxn6Y=; b=TfT6YDdzR5PswmZRr+Z9Lsjr4cgPIiK/bi/WUP/w6jught3ow/17r4dlW3OiMqsRD/JymL ldDFUiD1h6QOq1fQqdgweGlAqeyRjaR3pgwMc00fl0l7PrMkMDnpk79ovNEImBXuiVRYVq c6B4Oa39nSjQPrbDTU29lvoqTvFtyd4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1727761032; x=1759297032; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lB+hvyf3yxepm5Kmd6XwZLQVvnN7/oVBqCxfq4eIzGU=; b=d5co79sRGjt+rFkh5L5AIdlXqcm3LQysmgr0M8mUNI678Fb3Jx2X5Ryg mrEbVjVn7vdleK+SmoFlmbzm9ZOMjD6dVR1zwAllY1jcvYDZ8TvtsHamN 2CT2INorqY6PqtUIAWutep12FWQsKHuV2yDWpaXBvMDFKhO2L2gT01hqB nO9t/begAppUDtZJZ4hBQqWPBF+4vgskp0bKpdtwrkhIlwv0gmG1q1smh USe4Q4tA2JAGSXkpHuDGGTrRfDkjUYtEegiUVtVBDqp1096C2wI4rXIg/ bxpLuESAJnB9hEwG3XKy/HGcD3bElfohnjEMTRIT2DraztB/0Ac6zhUrh w==; X-CSE-ConnectionGUID: iNQD7SPRQpa6gsX9HApv2g== X-CSE-MsgGUID: 67ATNNtKRWW24+LHNzMzIA== X-IronPort-AV: E=McAfee;i="6700,10204,11211"; a="37465105" X-IronPort-AV: E=Sophos;i="6.11,167,1725346800"; d="scan'208";a="37465105" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2024 22:32:25 -0700 X-CSE-ConnectionGUID: PKBxrDh5Qx2Gv53SQPU5uQ== X-CSE-MsgGUID: wtC/7FAEQlSZaTIPojmcow== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,167,1725346800"; d="scan'208";a="73205804" Received: from jf5300-b11a338t.jf.intel.com ([10.242.51.6]) by fmviesa007.fm.intel.com with ESMTP; 30 Sep 2024 22:32:25 -0700 From: Kanchana P Sridhar To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, hannes@cmpxchg.org, yosryahmed@google.com, nphamcs@gmail.com, chengming.zhou@linux.dev, usamaarif642@gmail.com, shakeel.butt@linux.dev, ryan.roberts@arm.com, ying.huang@intel.com, 21cnbao@gmail.com, akpm@linux-foundation.org, willy@infradead.org Cc: nanhai.zou@intel.com, wajdi.k.feghali@intel.com, vinodh.gopal@intel.com, kanchana.p.sridhar@intel.com Subject: [PATCH v10 4/7] mm: Change count_objcg_event() to count_objcg_events() for batch event updates. Date: Mon, 30 Sep 2024 22:32:19 -0700 Message-Id: <20241001053222.6944-5-kanchana.p.sridhar@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20241001053222.6944-1-kanchana.p.sridhar@intel.com> References: <20241001053222.6944-1-kanchana.p.sridhar@intel.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: ajku9ms5cescd3gn1ibpp8sjsbohnbkw X-Rspamd-Queue-Id: 265521C0003 X-Rspamd-Server: rspam02 X-HE-Tag: 1727761031-294131 X-HE-Meta: U2FsdGVkX1/EVndA4LNZzArBKSNtq4pXRP/vSXfnYy//pE4+Oj1nefv9w9C2+3RrrTiOFWG7reEBm0C27sApEmPPERPJT69gcSMVr6gzBIkz0hqkoAmRbbcQuEQJAumkw64quA25BId6q5kJ+RnytNi6OD431TPnVIuHLOoObq/IXw4XMigpbLa83PfvTS5tPxFIF/tx5UNk9qGmVRFbX9ktBRek3gSfj6PFVP963mKHRXMwAqah2mNnUrkD7WND50z7CecAeTd6JRR9Wv3VtFc69JgADVVbpqKwVvSqt/RTcxjD2IZvdm+ONwOc/uwvdeKCW/RKAFlkfZDZW3aVc12DUKAqR/8UvBHrJm9aCs8Py5pZ74FuqH9Su2BdBdAFA5t0WhNdIPL6UJ4WluAK6WUizjHoUsEYIrl4j8IRvI3LrRQz5g8HY501z1Cq/r3JNXtBk0X+dkJNLkVwrx9x1K1ShxkADG/gcDc9wZkuh7QR4gvPAAmsISyan76rDVTNssrovvKvj7YigSm5G5yMjH9zOXJKxcdrlJuoXRvMNhFHmjybWDcpaQYfFuuKhAuApPobjP9hn3jlhJtwGSjXBA4Vdcid64aF00TMqpSWy9pSAjyoVGa8cxkGfEkjIylseSrd8FX1PU2z7FaqnoVggrzj8XJhQ0KLnBuAXhvldYR8oMUagtq4D/PFVrg5QU2YiRWm2njXHfr3fBCZbF0qxWZ1hbNg4UciBf6gx+Rwzb1bS6WjkddkE/EPNQUk0m0vQ6s0vM1SmT94raGHqDdhkZwf3rkEJOrOvzEzgwevBQfAisu5jbH+FNeORtL54I/6cesPBYpalWL/qC8D4VFDaXYe4uCn3HApXMW7CnPr1Bc45UudAW4Hw38X4dAZGVN51dwjzL3sNBcnvs1mTCMRCSs+5PshPPhTwpcHuJ/WSNd2BqMWi0GHQOO5iMKDMQniEPlHyL0XdjzcKgUwd7H qMUPQ23x XwK+w13X+cJb5pz01QmbQeXLWe8U6KGEvJsLCPkElMKmFvQUChEU0Yws48VKaVUEm8oqrQZQpkWs/lqvlRt1xJw39/0Cmkr0B55P2PqWANvDgI7PfPpH8vPzkgA8mx80MRBq61/C3cZVNoVHEvz1C/TPNJZNhgXrIPm+hFT7oIo1UGvEV69Z5w0JEq3LrkvjeTW2j14y1dnGTUNLaz45QS6lsv0oAlu9zg6Th7GAVIiyQVIWW3kDUAdhhZR/cepAR0kTijw9jNjjGFb509pBlmlpdllx6u/VYHRfnU7T/JPJoO04NiFz/dt6IYZdlFWMeMfo6HJoLgH84g5A= 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: List-Subscribe: List-Unsubscribe: With the introduction of zswap_store() swapping out large folios, we need to efficiently update the objcg's memcg events once per successfully stored folio. For instance, the 'ZSWPOUT' event needs to be incremented by folio_nr_pages(). To facilitate this, the existing count_objcg_event() API is modified to be count_objcg_events() that additionally accepts a count parameter. The only existing calls to count_objcg_event() are in zswap.c - these have been modified to call count_objcg_events() with a count of 1. Signed-off-by: Kanchana P Sridhar Acked-by: Yosry Ahmed Reviewed-by: Nhat Pham Acked-by: Johannes Weiner --- include/linux/memcontrol.h | 12 +++++++----- mm/zswap.c | 6 +++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 15c2716f9aa3..524006313b0d 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -1764,8 +1764,9 @@ static inline int memcg_kmem_id(struct mem_cgroup *memcg) struct mem_cgroup *mem_cgroup_from_slab_obj(void *p); -static inline void count_objcg_event(struct obj_cgroup *objcg, - enum vm_event_item idx) +static inline void count_objcg_events(struct obj_cgroup *objcg, + enum vm_event_item idx, + unsigned long count) { struct mem_cgroup *memcg; @@ -1774,7 +1775,7 @@ static inline void count_objcg_event(struct obj_cgroup *objcg, rcu_read_lock(); memcg = obj_cgroup_memcg(objcg); - count_memcg_events(memcg, idx, 1); + count_memcg_events(memcg, idx, count); rcu_read_unlock(); } @@ -1829,8 +1830,9 @@ static inline struct mem_cgroup *mem_cgroup_from_slab_obj(void *p) return NULL; } -static inline void count_objcg_event(struct obj_cgroup *objcg, - enum vm_event_item idx) +static inline void count_objcg_events(struct obj_cgroup *objcg, + enum vm_event_item idx, + unsigned long count) { } diff --git a/mm/zswap.c b/mm/zswap.c index 0f281e50a034..69b9c025fd47 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -1053,7 +1053,7 @@ static int zswap_writeback_entry(struct zswap_entry *entry, count_vm_event(ZSWPWB); if (entry->objcg) - count_objcg_event(entry->objcg, ZSWPWB); + count_objcg_events(entry->objcg, ZSWPWB, 1); zswap_entry_free(entry); @@ -1482,7 +1482,7 @@ bool zswap_store(struct folio *folio) if (objcg) { obj_cgroup_charge_zswap(objcg, entry->length); - count_objcg_event(objcg, ZSWPOUT); + count_objcg_events(objcg, ZSWPOUT, 1); } /* @@ -1576,7 +1576,7 @@ bool zswap_load(struct folio *folio) count_vm_event(ZSWPIN); if (entry->objcg) - count_objcg_event(entry->objcg, ZSWPIN); + count_objcg_events(entry->objcg, ZSWPIN, 1); if (swapcache) { zswap_entry_free(entry); From patchwork Tue Oct 1 05:32:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sridhar, Kanchana P" X-Patchwork-Id: 13817485 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 5E0C0CEB2FE for ; Tue, 1 Oct 2024 05:37:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 854786B00F5; Tue, 1 Oct 2024 01:37:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 803576B0100; Tue, 1 Oct 2024 01:37:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6300C6B00F7; Tue, 1 Oct 2024 01:37:16 -0400 (EDT) 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 33B406B00EA for ; Tue, 1 Oct 2024 01:37:16 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id CBB401607A0 for ; Tue, 1 Oct 2024 05:37:15 +0000 (UTC) X-FDA: 82623925230.21.81DF3C1 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) by imf05.hostedemail.com (Postfix) with ESMTP id 9BE48100006 for ; Tue, 1 Oct 2024 05:37:13 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=bmsupbOl; spf=pass (imf05.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.11 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727760906; 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:in-reply-to:references:references:dkim-signature; bh=n3lpT5wzGF+b1pa3hoTUzlSMa9Vzwo4wZdujvqkC3ms=; b=tGjRmnSgyY1tyw6cVv4dgmuOL+lLdj0uTEOq/CzAqDNh3XVPr71UW6HKbNk75k1qt9gmf7 ViYpLjF5CEqFyB2uQc0wY6YErOWIJ2ihYffPhxMJfa3DtoEgj8oy/THVdAvKZXPash/eeU TLxFl1FLRQY3CxL7Dg6POXuQH/B9mbg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727760906; a=rsa-sha256; cv=none; b=1bkaEuRdAg8PNJ2kZPe4eDDnqx6rgvdcK7eMSXOiljn8GX4d5DuYd/qjDTtgPS81qEzmuE SQgWdoGsHWTyEFRO+PVdjvwJF/018V3Hi+LUB01nFxMpuF4IFaHnfIisb1rzbs6GZzTWb9 5dDUcMQjJfjXC4CGOJVODPU/ivzZ78M= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=bmsupbOl; spf=pass (imf05.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.11 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com; dmarc=pass (policy=none) header.from=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1727761034; x=1759297034; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fh13koWj73Qksnj2l+56lXO4bpj9lkhBiLj2Y16CgXI=; b=bmsupbOlmhe+qPfK0jwF3tShAtINmP2ZSu8wGrNQJGOdV9ur4ykju5mr 274P7bhydRfV8Aec2ynvdV2qqfPuTGnKLrnQPNU2om4aWOVXzzO8t6j1G exqfcJ/VtYFodOOu4QV1HAETeCJ6k9vz6roF5qqV53RBc5Ej+QaDDiluN T+iCrxgFPGEPydJxV2D4k0DLV86pruAdKJu8MFb2hHYxc1mHp/MLrTN+0 LxjZD+R/tsC/Nto0RfMl7M7L/ZmoVzQ5twfk5WwptoVxZ3LSA8aQ2Rh7i 4AG0PZfgSvBY6DmcojnwJ6/D9abzWZ5bKkME+q996WwvdD6eW+2o/4rnq A==; X-CSE-ConnectionGUID: DXX/k+OiSa6HQU/0fPDz/A== X-CSE-MsgGUID: OKu7FXetRz2FY65aq5q+hg== X-IronPort-AV: E=McAfee;i="6700,10204,11211"; a="37465117" X-IronPort-AV: E=Sophos;i="6.11,167,1725346800"; d="scan'208";a="37465117" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2024 22:32:26 -0700 X-CSE-ConnectionGUID: kM2GQueiQaqyj/KDhjFPcA== X-CSE-MsgGUID: kqT1lRAiTy6kXLW9DrzM5g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,167,1725346800"; d="scan'208";a="73205808" Received: from jf5300-b11a338t.jf.intel.com ([10.242.51.6]) by fmviesa007.fm.intel.com with ESMTP; 30 Sep 2024 22:32:25 -0700 From: Kanchana P Sridhar To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, hannes@cmpxchg.org, yosryahmed@google.com, nphamcs@gmail.com, chengming.zhou@linux.dev, usamaarif642@gmail.com, shakeel.butt@linux.dev, ryan.roberts@arm.com, ying.huang@intel.com, 21cnbao@gmail.com, akpm@linux-foundation.org, willy@infradead.org Cc: nanhai.zou@intel.com, wajdi.k.feghali@intel.com, vinodh.gopal@intel.com, kanchana.p.sridhar@intel.com Subject: [PATCH v10 5/7] mm: zswap: Modify zswap_stored_pages to be atomic_long_t. Date: Mon, 30 Sep 2024 22:32:20 -0700 Message-Id: <20241001053222.6944-6-kanchana.p.sridhar@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20241001053222.6944-1-kanchana.p.sridhar@intel.com> References: <20241001053222.6944-1-kanchana.p.sridhar@intel.com> MIME-Version: 1.0 X-Stat-Signature: 8s1ok8ai7eobqgjx73uo1tc1xn5gcuty X-Rspamd-Queue-Id: 9BE48100006 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1727761033-821236 X-HE-Meta: U2FsdGVkX19OD/ld+8MgISjJq+a9poEhWmRSSfbxIfIp+FwvVdlzm5zi7pppXmDMyr6tiMoNBZTCoH8b5zgi8qLORbY8Oy/VfQ7vK7KmBGpbhY3jk1pknC/ueLJsz9S+S7LpHMHo5/VT3D8Nelhk80AkhOvrXaWTNOzOz+wmVLTPyo9NY+AKbZ9CCyr/Vp4hyG8nRqtst88PnBVYxW1QYHMBc+VpSbBwSHHPV6xEfbnIIpGNyCPiUhNFf2uwtQJGDpUWorSV9CM9EnJSgnkOQRLhqUC0InRHrhhAJEZkpMgOPzMHSkH4eTdhqINK1SxqC+RP/zZec4YU9NC53Dxbx8mjl1vpgEjcMyN5hojRzbsVAL+E0Ae1hiMN0AX/WlDbhJ7sRZkk1BwEeeOxKOyoIgQo2EGD5aztqd85PJ8ZCJp43YYNTrje1LHzIUxCKRQfiIkLeqdIO64+2bTS1Vobiba5dKowdZDZXqVdEizNWAJKoYhcG3Ms5FktnB9QZ8SWiO1HOe7R6uRmQXsuaypq4jL/BhRDCTdCdIOsB0Tq0aAiiYrnegv1ybGmepp/jgpakzC50uVlmK9teP1Hbvsr9jB+Uj3to+Wb8FC9fzWgsRoRIXDWHx/Wa8UhTKnGhHEHWH7o2CqbuqBDPRlhulRcIJfEXCtqZcM9SKKPYVtIlT3r5A3Cenzt97mcD6ix+kkss47xApkY9m5/ehecBiTyE4YfifovprWHulpqut0FyXNSHE9bRWN1IvDY6uAOQGtj6qBdJ+HomUaBWezvj+G8nXeQslYLDIFBSC73d3ZwrD18F9odmjPIBApr0cdKswn+eYmf9xfkXdbt3ERv2IootwAOuzUUxK0ca4aR8nG4ZQJHcwA0LyS6eoEXJweM6/lKwRiwNa0/8rBj9fvI6wP24kw49UOtbNi60aEfdSwMOwmUQEL5vZzaRFDc97vHfY7nGGmd97AJjdsjlj3MqZg XcLxWdsL imZEAKfDY/OkmFw7a9yYar9cHyj9po/GCQxjLZ8Jj5UyIJ5qqnDjsYalhN998vuM1gM7DFIwYW4LK3HWQDUawm73xGDsnUKulRuuwrrfLLtHGo5ZUCYtRQhDFibA3wq+qTrAmdYyG6Gp0C8rGEnTNs05k2ElVzIBVnp3PT3Ts7w8T0bC0n5Z3n+cL/RdfQEEQ0qTNmlktn++fzGNt8aphU637sEPzRUTxZu3m0VpRVw+hB7DRYtxjfQAgnPC8kYLyWiVwdxCf6BMOLANRvYr+ZY9rBwBnXfToRdWfQ5o1zUFqfVSddPCedCAjBbaV9suFxgZ0oBcNIig+jU600oZuObXIAw== 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: List-Subscribe: List-Unsubscribe: For zswap_store() to support large folios, we need to be able to do a batch update of zswap_stored_pages upon successful store of all pages in the folio. For this, we need to add folio_nr_pages(), which returns a long, to zswap_stored_pages. Signed-off-by: Kanchana P Sridhar Acked-by: Yosry Ahmed Acked-by: Johannes Weiner Reviewed-by: Nhat Pham --- fs/proc/meminfo.c | 2 +- include/linux/zswap.h | 2 +- mm/zswap.c | 19 +++++++++++++------ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c index 245171d9164b..8ba9b1472390 100644 --- a/fs/proc/meminfo.c +++ b/fs/proc/meminfo.c @@ -91,7 +91,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v) #ifdef CONFIG_ZSWAP show_val_kb(m, "Zswap: ", zswap_total_pages()); seq_printf(m, "Zswapped: %8lu kB\n", - (unsigned long)atomic_read(&zswap_stored_pages) << + (unsigned long)atomic_long_read(&zswap_stored_pages) << (PAGE_SHIFT - 10)); #endif show_val_kb(m, "Dirty: ", diff --git a/include/linux/zswap.h b/include/linux/zswap.h index 9cd1beef0654..d961ead91bf1 100644 --- a/include/linux/zswap.h +++ b/include/linux/zswap.h @@ -7,7 +7,7 @@ struct lruvec; -extern atomic_t zswap_stored_pages; +extern atomic_long_t zswap_stored_pages; #ifdef CONFIG_ZSWAP diff --git a/mm/zswap.c b/mm/zswap.c index 69b9c025fd47..2b8da50f6322 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -43,7 +43,7 @@ * statistics **********************************/ /* The number of compressed pages currently stored in zswap */ -atomic_t zswap_stored_pages = ATOMIC_INIT(0); +atomic_long_t zswap_stored_pages = ATOMIC_INIT(0); /* * The statistics below are not protected from concurrent access for @@ -802,7 +802,7 @@ static void zswap_entry_free(struct zswap_entry *entry) obj_cgroup_put(entry->objcg); } zswap_entry_cache_free(entry); - atomic_dec(&zswap_stored_pages); + atomic_long_dec(&zswap_stored_pages); } /********************************* @@ -1232,7 +1232,7 @@ static unsigned long zswap_shrinker_count(struct shrinker *shrinker, nr_stored = memcg_page_state(memcg, MEMCG_ZSWAPPED); } else { nr_backing = zswap_total_pages(); - nr_stored = atomic_read(&zswap_stored_pages); + nr_stored = atomic_long_read(&zswap_stored_pages); } if (!nr_stored) @@ -1501,7 +1501,7 @@ bool zswap_store(struct folio *folio) } /* update stats */ - atomic_inc(&zswap_stored_pages); + atomic_long_inc(&zswap_stored_pages); count_vm_event(ZSWPOUT); return true; @@ -1650,6 +1650,13 @@ static int debugfs_get_total_size(void *data, u64 *val) } DEFINE_DEBUGFS_ATTRIBUTE(total_size_fops, debugfs_get_total_size, NULL, "%llu\n"); +static int debugfs_get_stored_pages(void *data, u64 *val) +{ + *val = atomic_long_read(&zswap_stored_pages); + return 0; +} +DEFINE_DEBUGFS_ATTRIBUTE(stored_pages_fops, debugfs_get_stored_pages, NULL, "%llu\n"); + static int zswap_debugfs_init(void) { if (!debugfs_initialized()) @@ -1673,8 +1680,8 @@ static int zswap_debugfs_init(void) zswap_debugfs_root, &zswap_written_back_pages); debugfs_create_file("pool_total_size", 0444, zswap_debugfs_root, NULL, &total_size_fops); - debugfs_create_atomic_t("stored_pages", 0444, - zswap_debugfs_root, &zswap_stored_pages); + debugfs_create_file("stored_pages", 0444, + zswap_debugfs_root, NULL, &stored_pages_fops); return 0; } From patchwork Tue Oct 1 05:32:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sridhar, Kanchana P" X-Patchwork-Id: 13817486 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 0533CCEB2FD for ; Tue, 1 Oct 2024 05:37:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 155AE280050; Tue, 1 Oct 2024 01:37:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F34BD6B01FC; Tue, 1 Oct 2024 01:37:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CBE9C6B01AB; Tue, 1 Oct 2024 01:37:16 -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 A9F856B0117 for ; Tue, 1 Oct 2024 01:37:16 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 6529E1607A0 for ; Tue, 1 Oct 2024 05:37:16 +0000 (UTC) X-FDA: 82623925272.01.C9E52B0 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) by imf20.hostedemail.com (Postfix) with ESMTP id 46CC51C0008 for ; Tue, 1 Oct 2024 05:37:14 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=lrEDS9CS; spf=pass (imf20.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.11 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727760907; 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:in-reply-to:references:references:dkim-signature; bh=8zMVJkZztE4XRAtOofTluJRZbGUYTdnwE6zdaFu+s54=; b=ZP/U6XrLG5pBnhfCMu6nu53e/Yqhtr3H9GcasEBrlG0DPY6H6QNlXiAGXAMAmjVZR7bq6J BilE+EGU9IvEFMgmMnHQHTp7G5dqwLnQrCfezVlBScNmFLclr5CUCu5dpPKpMPFNL5BpdT rvTdFfQkoB3R+E4DBDWMig13stnJCzg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727760907; a=rsa-sha256; cv=none; b=i56uo53LoKIIIKHXeVmxvXZaz6sOYkkYHloTvsSWcS8DOZXPtk8cOubSOgPK0nLdj2G714 nOtTMWVREJe3i2vaQAqXIUCO3AFgQAbWQIMdOEwU8rCENQ7bPkUaxtm9PdPyX/Qa1b1F1i KeBWw+c14OhaV0k79OZMbADuAQIifek= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=lrEDS9CS; spf=pass (imf20.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.11 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com; dmarc=pass (policy=none) header.from=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1727761034; x=1759297034; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZqA5lLeXDY0x6sdJphTljhIJY7azBNvVtOD2DnEXQcU=; b=lrEDS9CSOLxMjvD/+R+Nc2PhlUWE7qGxvYYVD1N9GfzMDlTnMlGkx1DI +inlceYXkGbXyxFLaIxjXsgbRWqkMTBHOmZ0ObAp4o8hQ8r4lFzN1Ac/A +IJ19GFDoC+hDtUcBr8NOqT080vOoyrm10xg36jXd6VAoc1GyU1/lgA77 locj4Sor86YPkr2JT3PAYef6iO80sRCqgw5sdkztS28+OpuZeFVgA4Nq/ MjOsr9m9O1X6TVhY+c+mZ04eGN9cxnfwL/xWark6ZXlTLoGI+vVjb6UTW 7m1o9ko1miCqNSuvhcC89R008ljegaZoie21JVggYBP5B+QM5fnG0qF6i g==; X-CSE-ConnectionGUID: 3NtlLURYQZW+rS2q/ZoIJg== X-CSE-MsgGUID: vRJfCd3FTuKxoe22fkR5ig== X-IronPort-AV: E=McAfee;i="6700,10204,11211"; a="37465130" X-IronPort-AV: E=Sophos;i="6.11,167,1725346800"; d="scan'208";a="37465130" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2024 22:32:27 -0700 X-CSE-ConnectionGUID: fGhzmQz2RFu8X+pw/8tNSA== X-CSE-MsgGUID: 7dEULFhAQP6ZmQjTLj2l8A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,167,1725346800"; d="scan'208";a="73205815" Received: from jf5300-b11a338t.jf.intel.com ([10.242.51.6]) by fmviesa007.fm.intel.com with ESMTP; 30 Sep 2024 22:32:26 -0700 From: Kanchana P Sridhar To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, hannes@cmpxchg.org, yosryahmed@google.com, nphamcs@gmail.com, chengming.zhou@linux.dev, usamaarif642@gmail.com, shakeel.butt@linux.dev, ryan.roberts@arm.com, ying.huang@intel.com, 21cnbao@gmail.com, akpm@linux-foundation.org, willy@infradead.org Cc: nanhai.zou@intel.com, wajdi.k.feghali@intel.com, vinodh.gopal@intel.com, kanchana.p.sridhar@intel.com Subject: [PATCH v10 6/7] mm: zswap: Support large folios in zswap_store(). Date: Mon, 30 Sep 2024 22:32:21 -0700 Message-Id: <20241001053222.6944-7-kanchana.p.sridhar@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20241001053222.6944-1-kanchana.p.sridhar@intel.com> References: <20241001053222.6944-1-kanchana.p.sridhar@intel.com> MIME-Version: 1.0 X-Stat-Signature: hcyahjca15hata4rderj9np1u9efbgph X-Rspamd-Queue-Id: 46CC51C0008 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1727761034-548274 X-HE-Meta: U2FsdGVkX1/R54yqq7Ap0xqgcyfO4flDDbInRnqdh6e8CyGj8QutN99cqxPyodIF4VopSPx3dD0q8/Sre7gZZkjYCr7T9SStx3EHGwkGnLSABbc44ZLKLQ2u7Y9KSCosxF6zd+9ZqJeehCSOxWL+IXS1VvMjntgSXNHRodlHsF4/AYypwEJVnokgI8dHsKgf4NtD5SXuNjki6nDAAZOhU0bQIkrmlSYkgfXZmGp8djXmYaUXBKr43OwaEIrGWvlcL5LFVgTsTdIiNxT4YJaE/oBi78ZIKnXi2HZHZ9JdM7HIhQ+ZVax8+g2r33g6b4jpi3phOwc+i3ws+J0oK74MObR6oJ1AHa/aP6mNctvl/G+suChYg2tDjhQbZUZXS0xeS6X8YLYzbS+X9EL9enDsGcsCrW/ENIuhm/SVCHXeWkxYuZQRvgzjp8MWbi2NI1Ddo9OheOQaDNrWSmfun3PK+AXBMKEgH2EwCxbE3KeXjLQQEPLyDLNucgeIMlf6Lv5uX8V6f8XD4wFDdt+i5hT0foijeH0g/KrN1db165qur/EXzOOvALAb0Bf3NtFBis9M8oK35rp2cj8817fO0LD8hgOzu+G5+QysZ3X+DpOPsCthV0i8NUQCZvt0Da2glVDEuZU+oeU3Zg0VaU5Tp7UWJKfFHefqnmavWqmQDmT4xr1tqIBapIVLJKBadP7Xnsq9rRUd2pGqOZxxidjB4xcFarVrJ7zqsMIQTd7HFFET4eQOXqLV47OzK0fo3PgdQpChBSM1fTSE6f+okz/smQzA2PLIYUm04q3DbBBuQ58IBe9y0mjuTJHBAWZmChuvm0u8fBnOJosF6Ub5og9vbVr3nsIQBF0/RBSEe2RguTTUqNG0YcCG6Y4bMB0UnyIKrSen7iagaB7i5bZh1lfTDq0kR3ITzXJsyumQBoZrZP7dKLnXe3Blh4Do53PjfnpdsKtxX48RqyYGROyl6IMvoG6 HKTXkomE UywJbg0u7LoXlS0PMV0bJPUtsLGDEbwv4dIg7+ZOJsk1mM+xf2uIWkGhVPHIXVrhEhP16cIK+np+W97/sCgbqRyx4bS/FPK7cSi3nVfZN/1EQU2Y7z7Z1CNkL/XYUw29fri1JkZ9jq/d0OWneP2eVk4YAR4t3xgcasovD0myU4ByN/tyVbm+iLW74abfPWiFpxwu6NRq9H+y2bkG/9GQ3uvDjyw6OBui8TA3nzvuFOzGCAvw6/b7Sami5eu7VvPx/ebnlEV9lutMPRbn23NiD8dEvrgl0ALQThGOjAjCIFwdFkaFIchZCehKjYQ== 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: List-Subscribe: List-Unsubscribe: zswap_store() will store large folios by compressing them page by page. This patch provides a sequential implementation of storing a large folio in zswap_store() by iterating through each page in the folio to compress and store it in the zswap zpool. zswap_store() calls the newly added zswap_store_page() function for each page in the folio. zswap_store_page() handles compressing and storing each page. We check the global and per-cgroup limits once at the beginning of zswap_store(), and only check that the limit is not reached yet. This is racy and inaccurate, but it should be sufficient for now. We also obtain initial references to the relevant objcg and pool to guarantee that subsequent references can be acquired by zswap_store_page(). A new function zswap_pool_get() is added to facilitate this. If these one-time checks pass, we compress the pages of the folio, while maintaining a running count of compressed bytes for all the folio's pages. If all pages are successfully compressed and stored, we do the cgroup zswap charging with the total compressed bytes, and batch update the zswap_stored_pages atomic/zswpout event stats with folio_nr_pages() once, before returning from zswap_store(). If an error is encountered during the store of any page in the folio, all pages in that folio currently stored in zswap will be invalidated. Thus, a folio is either entirely stored in zswap, or entirely not stored in zswap. The most important value provided by this patch is it enables swapping out large folios to zswap without splitting them. Furthermore, it batches some operations while doing so (cgroup charging, stats updates). This patch also forms the basis for building compress batching of pages in a large folio in zswap_store() by compressing up to say, 8 pages of the folio in parallel in hardware using the Intel In-Memory Analytics Accelerator (Intel IAA). This change reuses and adapts the functionality in Ryan Roberts' RFC patch [1]: "[RFC,v1] mm: zswap: Store large folios without splitting" [1] https://lore.kernel.org/linux-mm/20231019110543.3284654-1-ryan.roberts@arm.com/T/#u Co-developed-by: Ryan Roberts Signed-off-by: Signed-off-by: Kanchana P Sridhar Acked-by: Johannes Weiner Reviewed-by: Nhat Pham Acked-by: Yosry Ahmed --- mm/zswap.c | 189 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 121 insertions(+), 68 deletions(-) diff --git a/mm/zswap.c b/mm/zswap.c index 2b8da50f6322..09aaf70f95c6 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -411,6 +411,12 @@ static int __must_check zswap_pool_tryget(struct zswap_pool *pool) return percpu_ref_tryget(&pool->ref); } +/* The caller must already have a reference. */ +static void zswap_pool_get(struct zswap_pool *pool) +{ + percpu_ref_get(&pool->ref); +} + static void zswap_pool_put(struct zswap_pool *pool) { percpu_ref_put(&pool->ref); @@ -1402,68 +1408,38 @@ static void shrink_worker(struct work_struct *w) /********************************* * main API **********************************/ -bool zswap_store(struct folio *folio) + +static ssize_t zswap_store_page(struct page *page, + struct obj_cgroup *objcg, + struct zswap_pool *pool) { - swp_entry_t swp = folio->swap; - pgoff_t offset = swp_offset(swp); - struct xarray *tree = swap_zswap_tree(swp); struct zswap_entry *entry, *old; - struct obj_cgroup *objcg = NULL; - struct mem_cgroup *memcg = NULL; - - VM_WARN_ON_ONCE(!folio_test_locked(folio)); - VM_WARN_ON_ONCE(!folio_test_swapcache(folio)); - - /* Large folios aren't supported */ - if (folio_test_large(folio)) - return false; - - if (!zswap_enabled) - goto check_old; - - /* Check cgroup limits */ - objcg = get_obj_cgroup_from_folio(folio); - if (objcg && !obj_cgroup_may_zswap(objcg)) { - memcg = get_mem_cgroup_from_objcg(objcg); - if (shrink_memcg(memcg)) { - mem_cgroup_put(memcg); - goto reject; - } - mem_cgroup_put(memcg); - } - - if (zswap_check_limits()) - goto reject; /* allocate entry */ - entry = zswap_entry_cache_alloc(GFP_KERNEL, folio_nid(folio)); + entry = zswap_entry_cache_alloc(GFP_KERNEL, page_to_nid(page)); if (!entry) { zswap_reject_kmemcache_fail++; goto reject; } - /* if entry is successfully added, it keeps the reference */ - entry->pool = zswap_pool_current_get(); - if (!entry->pool) - goto freepage; + /* zswap_store() already holds a ref on 'objcg' and 'pool' */ + if (objcg) + obj_cgroup_get(objcg); + zswap_pool_get(pool); - if (objcg) { - memcg = get_mem_cgroup_from_objcg(objcg); - if (memcg_list_lru_alloc(memcg, &zswap_list_lru, GFP_KERNEL)) { - mem_cgroup_put(memcg); - goto put_pool; - } - mem_cgroup_put(memcg); - } + /* if entry is successfully added, it keeps the reference */ + entry->pool = pool; - if (!zswap_compress(&folio->page, entry)) - goto put_pool; + if (!zswap_compress(page, entry)) + goto put_pool_objcg; - entry->swpentry = swp; + entry->swpentry = page_swap_entry(page); entry->objcg = objcg; entry->referenced = true; - old = xa_store(tree, offset, entry, GFP_KERNEL); + old = xa_store(swap_zswap_tree(entry->swpentry), + swp_offset(entry->swpentry), + entry, GFP_KERNEL); if (xa_is_err(old)) { int err = xa_err(old); @@ -1480,11 +1456,6 @@ bool zswap_store(struct folio *folio) if (old) zswap_entry_free(old); - if (objcg) { - obj_cgroup_charge_zswap(objcg, entry->length); - count_objcg_events(objcg, ZSWPOUT, 1); - } - /* * We finish initializing the entry while it's already in xarray. * This is safe because: @@ -1500,32 +1471,114 @@ bool zswap_store(struct folio *folio) zswap_lru_add(&zswap_list_lru, entry); } - /* update stats */ - atomic_long_inc(&zswap_stored_pages); - count_vm_event(ZSWPOUT); - - return true; + /* + * We shouldn't have any possibility of failure after the entry is + * added in the xarray. The pool/objcg refs obtained here will only + * be dropped if/when zswap_entry_free() gets called. + */ + return entry->length; store_failed: zpool_free(entry->pool->zpool, entry->handle); -put_pool: - zswap_pool_put(entry->pool); -freepage: +put_pool_objcg: + zswap_pool_put(pool); + obj_cgroup_put(objcg); zswap_entry_cache_free(entry); reject: + return -EINVAL; +} + +bool zswap_store(struct folio *folio) +{ + long nr_pages = folio_nr_pages(folio); + swp_entry_t swp = folio->swap; + struct obj_cgroup *objcg = NULL; + struct mem_cgroup *memcg = NULL; + struct zswap_pool *pool; + size_t compressed_bytes = 0; + bool ret = false; + long index; + + VM_WARN_ON_ONCE(!folio_test_locked(folio)); + VM_WARN_ON_ONCE(!folio_test_swapcache(folio)); + + if (!zswap_enabled) + goto check_old; + + objcg = get_obj_cgroup_from_folio(folio); + if (objcg && !obj_cgroup_may_zswap(objcg)) { + memcg = get_mem_cgroup_from_objcg(objcg); + if (shrink_memcg(memcg)) { + mem_cgroup_put(memcg); + goto put_objcg; + } + mem_cgroup_put(memcg); + } + + if (zswap_check_limits()) + goto put_objcg; + + pool = zswap_pool_current_get(); + if (!pool) + goto put_objcg; + + if (objcg) { + memcg = get_mem_cgroup_from_objcg(objcg); + if (memcg_list_lru_alloc(memcg, &zswap_list_lru, GFP_KERNEL)) { + mem_cgroup_put(memcg); + goto put_pool; + } + mem_cgroup_put(memcg); + } + + for (index = 0; index < nr_pages; ++index) { + struct page *page = folio_page(folio, index); + ssize_t bytes; + + bytes = zswap_store_page(page, objcg, pool); + if (bytes < 0) + goto put_pool; + compressed_bytes += bytes; + } + + if (objcg) { + obj_cgroup_charge_zswap(objcg, compressed_bytes); + count_objcg_events(objcg, ZSWPOUT, nr_pages); + } + + atomic_long_add(nr_pages, &zswap_stored_pages); + count_vm_events(ZSWPOUT, nr_pages); + + ret = true; + +put_pool: + zswap_pool_put(pool); +put_objcg: obj_cgroup_put(objcg); - if (zswap_pool_reached_full) + if (!ret && zswap_pool_reached_full) queue_work(shrink_wq, &zswap_shrink_work); check_old: /* - * If the zswap store fails or zswap is disabled, we must invalidate the - * possibly stale entry which was previously stored at this offset. - * Otherwise, writeback could overwrite the new data in the swapfile. + * If the zswap store fails or zswap is disabled, we must invalidate + * the possibly stale entries which were previously stored at the + * offsets corresponding to each page of the folio. Otherwise, + * writeback could overwrite the new data in the swapfile. */ - entry = xa_erase(tree, offset); - if (entry) - zswap_entry_free(entry); - return false; + if (!ret) { + unsigned type = swp_type(swp); + pgoff_t offset = swp_offset(swp); + struct zswap_entry *entry; + struct xarray *tree; + + for (index = 0; index < nr_pages; ++index) { + tree = swap_zswap_tree(swp_entry(type, offset + index)); + entry = xa_erase(tree, offset + index); + if (entry) + zswap_entry_free(entry); + } + } + + return ret; } bool zswap_load(struct folio *folio) From patchwork Tue Oct 1 05:32:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sridhar, Kanchana P" X-Patchwork-Id: 13817487 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 A464FCEB2FE for ; Tue, 1 Oct 2024 05:37:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5BC316B0207; Tue, 1 Oct 2024 01:37:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 56BF86B020A; Tue, 1 Oct 2024 01:37:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1502D280036; Tue, 1 Oct 2024 01:37:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id D054F6B0117 for ; Tue, 1 Oct 2024 01:37:16 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 971A41C68C4 for ; Tue, 1 Oct 2024 05:37:16 +0000 (UTC) X-FDA: 82623925272.28.D8C4A30 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) by imf18.hostedemail.com (Postfix) with ESMTP id 73EDC1C0003 for ; Tue, 1 Oct 2024 05:37:14 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=Q4DLvfYa; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf18.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.11 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727761014; a=rsa-sha256; cv=none; b=uUccNhW/lJc7wdLV+MLbGrMlZZf2nlYowgQGg07HVCMuNUAvbXcmjSX9sbUC0BJuDEsqp1 6Ee0RDmjwBZBNi8KGLSkD9pm+9lSwT4ez7P9uXYmcQ9xCg6xektQ0dQeKs6lAHxp5erWgc LAt8m8OgzGz0vTBLgLngSW3S/cH+AVw= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=Q4DLvfYa; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf18.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.11 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1727761014; 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:in-reply-to:references:references:dkim-signature; bh=Zzb0n7WbQynndp9X8ptSglsXUQTU708+oyK3zIdoDgk=; b=2IK/Vpn+3e8xbjLLtQLWBJ2j4hIFUWupmLC3bWJU3iBETdDUUbOwAPCq/t8UyLC/1gwZ6l i0ONQMMDw+WpryOKXcnQD9mbikY4VCC6SvWeGpzZUXVy6eI+SwejYvqUtWcnwFwOpDqqK0 jsnaUCsavw4a1NTm6A9vgYWRfLb2zQw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1727761035; x=1759297035; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EoDLTcNBMro+ufgrjaTKFoCYNP0vIAE8K0H1FKjnXKw=; b=Q4DLvfYadEODvLUPcjd8R7zv/Qs3a4+F3XMrW1KM1heV37U9PqBVna4a THIYs6meNFcckiBbaxCNkXM6/iJ8oKKC9Cd+H2+sE7/H0cMbWJ2QXikAo 19L+OLbFpu1LMo2t5mfaSE1zH9xQuRk7S8NWeAYUAfd/BF9dMcS37gVx/ b5gtt0uYSPko7z0/33WNeRRfU/bdm5vEAcbCz0FefVz0H0obgsmjFCRVj sDMYzPACIbMOTeWbKinMGfapDN167P4H8vAvL82hZz838Zme5t8IgRHdi he8CpR4rs85cB8YuRkRWoASjo7g5xrCWTSnwvs9d4F0tVYadWPD6sJgea Q==; X-CSE-ConnectionGUID: H7JYJuhHRMGY2QkCrytmOQ== X-CSE-MsgGUID: 018AqLykTqylwbEVz8A3iw== X-IronPort-AV: E=McAfee;i="6700,10204,11211"; a="37465141" X-IronPort-AV: E=Sophos;i="6.11,167,1725346800"; d="scan'208";a="37465141" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2024 22:32:27 -0700 X-CSE-ConnectionGUID: yFJuADSqS4eTxH7oBtWwig== X-CSE-MsgGUID: HpaMM9bDQFOGdwAg5THVcQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,167,1725346800"; d="scan'208";a="73205821" Received: from jf5300-b11a338t.jf.intel.com ([10.242.51.6]) by fmviesa007.fm.intel.com with ESMTP; 30 Sep 2024 22:32:27 -0700 From: Kanchana P Sridhar To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, hannes@cmpxchg.org, yosryahmed@google.com, nphamcs@gmail.com, chengming.zhou@linux.dev, usamaarif642@gmail.com, shakeel.butt@linux.dev, ryan.roberts@arm.com, ying.huang@intel.com, 21cnbao@gmail.com, akpm@linux-foundation.org, willy@infradead.org Cc: nanhai.zou@intel.com, wajdi.k.feghali@intel.com, vinodh.gopal@intel.com, kanchana.p.sridhar@intel.com Subject: [PATCH v10 7/7] mm: swap: Count successful large folio zswap stores in hugepage zswpout stats. Date: Mon, 30 Sep 2024 22:32:22 -0700 Message-Id: <20241001053222.6944-8-kanchana.p.sridhar@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20241001053222.6944-1-kanchana.p.sridhar@intel.com> References: <20241001053222.6944-1-kanchana.p.sridhar@intel.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: hzr589fybjsjtgabnjptkk38zx53kdyt X-Rspamd-Queue-Id: 73EDC1C0003 X-Rspamd-Server: rspam02 X-HE-Tag: 1727761034-725857 X-HE-Meta: U2FsdGVkX19eeRMm7d3MNivCLtEmKLWiAcprB02OgbWfa4azG0tRPhedt95CabLbD7Ul/KfUyh9Yv7qnZvklDG8B4yp52QaovTYGRCTj7CYSEEaH4rZsRk0FwtEVdMyXkgF3EhOsLsdoywTOsptS2Oruzoaf302l9+S06m+dEM8X5eDWTeK0Se7EnQh5i2rl+42esUP+BBRJNxuIdotMAnr7XvExs01ghRW9TqVHcffxMltPKABGDu6nZIYpAtBgxjZIkm481FkWGSiI2uQyUYpspqI0a6djQaQdBBjtybpjeHoYbkIObID/aM9p4PMNfDgobSVBYQXxKdTe3DEx+1AfCrKbYD4QyALriT+Sbe8k5e5rUGKWbf8PcWfcF3an5wg3i2Ul+Gji731+ug/cI5ffJjmC5fP5LC6VqUs6pVm1HBtF3Rpeo/ztc5Fac7SVMgw9k2qs1MPe9MJK9dQ1F42z7LhOrQCbUJT5+QRGwA434Cz/DNB4tI7QUxtAQRgRV3xPtdRrq5njIvgR2E1KZb+sDrGqX5QNKhC/4qrfYdhKwPhK5RLZEo0Ecn/U9CxQoP60h33sLo+CnidTZqOHq1cMrX2gSC6hON1rxMg7i9uO/vfRRoxbbQg1zpp7CSBKtgzdfBTSVDmcRDxdw9BcI22OJjndHOtAsIo4A2MoXx+Qu6m0kYiABcc93DZ7cVQ5EmrWffic1sMsGRdrqTDKdJ+Xn9lOOwLq4p5R1J4bvXqL+QrFEiYhgVkp4BNBrfT/uUOSK57REXUgAI2JvSsNSjKmEnxaz+YAbTBxPIy2iaDCcGLFgVxh5yOBupE8r7Eaa/jSVSzM98UZwtyoKxzXJf51F32NdArjIiv/DKCgQjez7ddCdLu4fP+186Fx4qKo0q3506r+YgxMw2x651adlnoTPGEmV7Myb2uNbq1VtiAoxAyJZbUgBdaUqm5gyIGlV91oWfVy9l9JOlZOaEC rNLbKVF4 BIQ6RA1ERLV2DWJEnF/sI274I9HJ90MwcFj14DpfnPJzp62k5dmS5WVkvuXLPcF1CMJ1M5P6se3ieF5gMX6Q7WeFjRNeAhXr8Man23r9EY6sxw+vr856dR8w+KRRy6mlx6vSk2e2ijOHodMw/AsmNtIEP3eKeGt6GA2rAvaffzqQjJ3dzpdda7S8JuStg9/f8zhVT2FAm1eCdI5o= 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: List-Subscribe: List-Unsubscribe: Added a new MTHP_STAT_ZSWPOUT entry to the sysfs transparent_hugepage stats so that successful large folio zswap stores can be accounted under the per-order sysfs "zswpout" stats: /sys/kernel/mm/transparent_hugepage/hugepages-*kB/stats/zswpout Other non-zswap swap device swap-out events will be counted under the existing sysfs "swpout" stats: /sys/kernel/mm/transparent_hugepage/hugepages-*kB/stats/swpout Also, added documentation for the newly added sysfs per-order hugepage "zswpout" stats. The documentation clarifies that only non-zswap swapouts will be accounted in the existing "swpout" stats. Signed-off-by: Kanchana P Sridhar Reviewed-by: Nhat Pham --- Documentation/admin-guide/mm/transhuge.rst | 8 ++++++-- include/linux/huge_mm.h | 1 + mm/huge_memory.c | 3 +++ mm/page_io.c | 1 + 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Documentation/admin-guide/mm/transhuge.rst b/Documentation/admin-guide/mm/transhuge.rst index cfdd16a52e39..2a171ed5206e 100644 --- a/Documentation/admin-guide/mm/transhuge.rst +++ b/Documentation/admin-guide/mm/transhuge.rst @@ -530,10 +530,14 @@ anon_fault_fallback_charge instead falls back to using huge pages with lower orders or small pages even though the allocation was successful. -swpout - is incremented every time a huge page is swapped out in one +zswpout + is incremented every time a huge page is swapped out to zswap in one piece without splitting. +swpout + is incremented every time a huge page is swapped out to a non-zswap + swap device in one piece without splitting. + swpout_fallback is incremented if a huge page has to be split before swapout. Usually because failed to allocate some continuous swap space diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index 5eb4b0376c7d..3eca60f3d512 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -119,6 +119,7 @@ enum mthp_stat_item { MTHP_STAT_ANON_FAULT_ALLOC, MTHP_STAT_ANON_FAULT_FALLBACK, MTHP_STAT_ANON_FAULT_FALLBACK_CHARGE, + MTHP_STAT_ZSWPOUT, MTHP_STAT_SWPOUT, MTHP_STAT_SWPOUT_FALLBACK, MTHP_STAT_SHMEM_ALLOC, diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 243c15912105..a7b05f4c2a5e 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -611,6 +611,7 @@ static struct kobj_attribute _name##_attr = __ATTR_RO(_name) DEFINE_MTHP_STAT_ATTR(anon_fault_alloc, MTHP_STAT_ANON_FAULT_ALLOC); DEFINE_MTHP_STAT_ATTR(anon_fault_fallback, MTHP_STAT_ANON_FAULT_FALLBACK); DEFINE_MTHP_STAT_ATTR(anon_fault_fallback_charge, MTHP_STAT_ANON_FAULT_FALLBACK_CHARGE); +DEFINE_MTHP_STAT_ATTR(zswpout, MTHP_STAT_ZSWPOUT); DEFINE_MTHP_STAT_ATTR(swpout, MTHP_STAT_SWPOUT); DEFINE_MTHP_STAT_ATTR(swpout_fallback, MTHP_STAT_SWPOUT_FALLBACK); #ifdef CONFIG_SHMEM @@ -629,6 +630,7 @@ static struct attribute *anon_stats_attrs[] = { &anon_fault_fallback_attr.attr, &anon_fault_fallback_charge_attr.attr, #ifndef CONFIG_SHMEM + &zswpout_attr.attr, &swpout_attr.attr, &swpout_fallback_attr.attr, #endif @@ -659,6 +661,7 @@ static struct attribute_group file_stats_attr_grp = { static struct attribute *any_stats_attrs[] = { #ifdef CONFIG_SHMEM + &zswpout_attr.attr, &swpout_attr.attr, &swpout_fallback_attr.attr, #endif diff --git a/mm/page_io.c b/mm/page_io.c index bc1183299a7d..4aa34862676f 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -269,6 +269,7 @@ int swap_writepage(struct page *page, struct writeback_control *wbc) swap_zeromap_folio_clear(folio); } if (zswap_store(folio)) { + count_mthp_stat(folio_order(folio), MTHP_STAT_ZSWPOUT); folio_unlock(folio); return 0; }