From patchwork Tue Sep 24 01:17:02 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: 13810014 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 6719BCF9C5B for ; Tue, 24 Sep 2024 01:17:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CFB3D6B0083; Mon, 23 Sep 2024 21:17:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C84BA6B0085; Mon, 23 Sep 2024 21:17:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AFCBF6B0088; Mon, 23 Sep 2024 21:17:18 -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 9497B6B0083 for ; Mon, 23 Sep 2024 21:17:18 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 44BE9121632 for ; Tue, 24 Sep 2024 01:17:18 +0000 (UTC) X-FDA: 82597868556.26.17B2034 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) by imf08.hostedemail.com (Postfix) with ESMTP id 1E4CA16000F for ; Tue, 24 Sep 2024 01:17:15 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=e9pGbf80; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf08.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.12 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727140601; a=rsa-sha256; cv=none; b=G6S2JxpBMu9iMpM1OhWo8iuSmY8HwYHEXEkFEGnpWCTBtk4+dxmtj1KFpJE2ZhKQCy1PeC 8uIWSoSfG3tCEVad23jeH+R6c9hL38NA/zD9CD8WQzTYcZFl4PCrDL92UgIMih0HENKbG0 6kOE97JfvVGi+TNMAFFvu3PlZShR3EM= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=e9pGbf80; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf08.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.12 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=1727140601; 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=RTs+0Yqd8sZSHUC6ky5gE4k/LE5LQXAWkMtzsx0yAMU=; b=zX8fQhC6OG86zT7XtJPIGWvz238x7tItCtdZAG/EMSapmKgXAMJ8I4se9IWSa27fbh3S0t aLfIO7a/oDZ/Jmq5OWeYfnvIuQrVYWYJfLqo0cYDPHg4kudB1rzrHW8HVYHc/cWp1ssAcC 7gleoew5h0klirF+E/veql3ydTpgLIE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1727140636; x=1758676636; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=j6MRHvvdb4Y/ecSm2gb8TOi+Txe+Ci0dZeAdkAYjrOU=; b=e9pGbf80ybSGnqqKH7hXp7D252lqR+1mFXcNCkDvlHMuY2+TL+nl7X8W HGKzvw/H2PvAVGZh2M65pf9JCHUdaQqetq3zFjSmES59/LQIVlC1J2hwb MadBIcJ3YeZnfMtOqEs+nS/Oht7wNNVy7ZCCEfrWMq8tgRFpyPPLf09HU hVMXj6Ht9PZJunXEfpaYPpGO73OHr069x8lu4IoClOX1zsgvataTXV7wj E+U+RY87q8Zv2+N7iuLVsFXR+b+bj6WUQ5alIFkFQQ9kTybIdR2ph8Vnp 5zL+VWAlD1pXCdmVDVTNW07CY7LuclSarEBC7A0K7bKLXDC2H57YTN1tL Q==; X-CSE-ConnectionGUID: 0FdE2+7uRkWsVlytI8WBgA== X-CSE-MsgGUID: crB5hP/FQdyVOkAtP0H6LQ== X-IronPort-AV: E=McAfee;i="6700,10204,11204"; a="30002001" X-IronPort-AV: E=Sophos;i="6.10,253,1719903600"; d="scan'208";a="30002001" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Sep 2024 18:17:10 -0700 X-CSE-ConnectionGUID: im59xWO4QgiDbIGKgbJwwQ== X-CSE-MsgGUID: mRXKs5anS0CqWg+gbdX0Xw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,253,1719903600"; d="scan'208";a="108688443" Received: from jf5300-b11a338t.jf.intel.com ([10.242.51.6]) by orviesa001.jf.intel.com with ESMTP; 23 Sep 2024 18:17:10 -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 Cc: nanhai.zou@intel.com, wajdi.k.feghali@intel.com, vinodh.gopal@intel.com, kanchana.p.sridhar@intel.com Subject: [PATCH v7 1/8] mm: Define obj_cgroup_get() if CONFIG_MEMCG is not defined. Date: Mon, 23 Sep 2024 18:17:02 -0700 Message-Id: <20240924011709.7037-2-kanchana.p.sridhar@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240924011709.7037-1-kanchana.p.sridhar@intel.com> References: <20240924011709.7037-1-kanchana.p.sridhar@intel.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 1E4CA16000F X-Rspamd-Server: rspam01 X-Stat-Signature: kzeaktxtsy98wb9uw1k84hho5ehgznqi X-HE-Tag: 1727140635-96821 X-HE-Meta: U2FsdGVkX1+v+CvanngSybaerWbh5p/vEnHclK0j7xLPPk2Y/igzk1DWxeSq8YPIf2K67mXeHZZ8wFVACVYFNhg1WgeFPN/wSTwT8SpBSlqJEA3DnWXoRdogbzeAjp/9VToHvk/G1bOB0HgYWNg4w/Y83UQYUJMrsQA8NYOwwSMH1/fPQ0StQ93mEpyv2jJVi0BHaVMylsJBCH8cxUf5UAPXhCEvu+QSmi1QRJIVun7W9SGQJw7ZnR9Z2JueRmTfG8MGt33xWL1Q/IXmp35P/hFzg6czzy/YgH7DegFT1t94YReUb5KbVCfhgMNu8krwIi1XM1ATI7vd0ct2JIx4h2qJQgbrZyUWMT/NAFOZeKTCw0p0CFdvrWiHPJUd6OrsjG+HkeRXbgTeHbOJKHYl1DF0VxKsz30U8T5b2xg4KEWJJgunfbBkHpILS0VuzgrE+XdVtsKCMbpxck55xie89Pq+JSMY9Qaxr4pLyEbrKn0WT27tmL+uGI4U0tcoRwkc49wfvUwS1i4RWzIvn4HI8yzRidiPpG9dtE12pluNmMzQySio/IYpLtYiCE4plfpf/DjNPeHd1B4+EdKU+3AwZ6Jc0IkCdZu8IjIuzWTUiICq0TN9AKZOLeqcXLJyD1plPGyTPRHN9nrdGkxnydkJ6wZXgfnIQRMqXMg8xRHj73MYeAFuFvrjdltsgHPOIbbQ29faUX5n5AQwXIg0q6vHxMFZyFjUh4X4isRvXiexCTU0Qbix42JlueHEU/duJhWTFrn6XF8H8bxF20equaFxaaUz0bjjWJ+mIXmRw+9sLg5FEeY2Zco9kOLtomZJdwQpbq+wuVycBvDaPfrjYkoVWLlqi4HQlFDf1Yifqa12DsPSc6rw9C8rVKzSgJnVRm49k9kpvYGMkDLyX1r9ftqJnC3BKvF01GTHAonKAmZMC030lfX+Eq1dcmep7G/t3ozCxyTbb5KvTczhaK9QTyV j/4HoqTj I0icVpPlvfLWNpgwGOP252udV5YDSBHwt/qHGF1Mb/xrLKey2LWG6FUcBdbzX3fjd5Eb8AJkexG/KdyCTqjW+OFXIGvTNRAPIeCg52U04Kx7KoEIzebQGDc4U58ggC5DzoTEbslAloiJfHf4prjZglFSBT22wOx3Us71SkzpA1TRw2Lvm9exi3rtAqTxkp5GsnMq7SUc8ODPUrd/zctlXfis7ZucuG8L4X+sFcHll1eixuY8= 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 mTHP 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 --- 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 Sep 24 01:17:03 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: 13810015 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 9817CCF9C73 for ; Tue, 24 Sep 2024 01:17:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A8A0F6B0085; Mon, 23 Sep 2024 21:17:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A14056B0088; Mon, 23 Sep 2024 21:17:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8B3FA6B0089; Mon, 23 Sep 2024 21:17:19 -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 711426B0085 for ; Mon, 23 Sep 2024 21:17:19 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id F0B56816A6 for ; Tue, 24 Sep 2024 01:17:18 +0000 (UTC) X-FDA: 82597868556.18.288DE8E Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) by imf09.hostedemail.com (Postfix) with ESMTP id DABD1140007 for ; Tue, 24 Sep 2024 01:17:16 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b="CC8qCu/Q"; spf=pass (imf09.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.12 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727140576; a=rsa-sha256; cv=none; b=uw4u3EaAIvKK6igGN1ZhBErcAMZIKf2obFSyskIgUZUcfqTvx4Uq8eUGKSohrRARuiZeZC Q7A6R8uXWChCWZI77SlVFCPGOePGt7u9YOFRK062Qcq6O0nsWjXV0NZmCAYX3+9RCerQKZ rwc6qA3SDVVnokSYj6BuVjHrdEZut4w= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b="CC8qCu/Q"; spf=pass (imf09.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.12 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=1727140576; 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=omR98ZCGNxhbtkybxIwrYfvGrA5EOSYSIR72vJ7FVis=; b=S5nuArcmX8lnPznvjRIbez870+45vcQTPrJ6MTVI+SPk6CXPRaDAindZpjaF16i66rI6Wj F/oWqv4ngNqcj7RYNGza6JksV0BeKnImisbCHc1p3/NFR7199QMc3VuuMFzf9oBXVyVwsI gnIRhZAej3Sb9uRFnbLTZDVGP9AvyEA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1727140637; x=1758676637; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pUUdV92IiG6zC8GNm5xDbVEXW5oShMyaugmREkMxm7k=; b=CC8qCu/QRNq4iA5WbLNloPb6b60wDN8IGOT6QPcssjDbmum6Kdu6t6rQ tscMTapGbNj0grwARTiLDL3Y77QugnTFHxqyuoSK3c9vF0nO81TiUIbPw 1jy7S1Wyxast4mbrhfYYYUW21JpclBxQb/EaAt1apHFinmADK+1UDqWTl jjvnR6gNfGPKoNZOy8tbfbmjxbY6BuNkMXeFENnGUDgyuXvf5b/T8itzz fJP37HyFB3PAlm1qZXGPSFCUDJcsHPuz9KGrCHYPS8t57A+5mUjK7bkM5 vDOEDDJYKYFG7kXQ0AU+J5DwApE2iXP4QrEG2UB+PHGZo9itdt0QT67nn g==; X-CSE-ConnectionGUID: F27bXeUoQK2V5hQ+N80vyg== X-CSE-MsgGUID: 3fTQP7r3SmqNzqLDoBjeCQ== X-IronPort-AV: E=McAfee;i="6700,10204,11204"; a="30002009" X-IronPort-AV: E=Sophos;i="6.10,253,1719903600"; d="scan'208";a="30002009" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Sep 2024 18:17:10 -0700 X-CSE-ConnectionGUID: Ow60v4ymQFG6hfj4EMYAUA== X-CSE-MsgGUID: HuTf+8mJT82ukI2RZ+87ug== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,253,1719903600"; d="scan'208";a="108688447" Received: from jf5300-b11a338t.jf.intel.com ([10.242.51.6]) by orviesa001.jf.intel.com with ESMTP; 23 Sep 2024 18:17:10 -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 Cc: nanhai.zou@intel.com, wajdi.k.feghali@intel.com, vinodh.gopal@intel.com, kanchana.p.sridhar@intel.com Subject: [PATCH v7 2/8] mm: zswap: Modify zswap_compress() to accept a page instead of a folio. Date: Mon, 23 Sep 2024 18:17:03 -0700 Message-Id: <20240924011709.7037-3-kanchana.p.sridhar@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240924011709.7037-1-kanchana.p.sridhar@intel.com> References: <20240924011709.7037-1-kanchana.p.sridhar@intel.com> MIME-Version: 1.0 X-Stat-Signature: fxx61esoey56pbdac3abxyq1ewefecsh X-Rspamd-Queue-Id: DABD1140007 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1727140636-890141 X-HE-Meta: U2FsdGVkX19dEdfGJNwt7+ouCbtoi+Dhrj6NGT7ePApqquPQaJpzJF893NDM/0oPW9mUT71+pFDEyuph6cvVoBToSRFmSjhVsWXngwvvtRLKXQre9pi3K2lPg1kj13n/UwtVSS23Ck7Kev7n0R7S4k1kEfkER1LTmz+kJiPFSdQEEFnDQYephKs55lkAqk4PdsB+OzBsDHq4qlCNqKxW5K/bgL6ua7Dg21I0CRjOExzMF2Rg+SiajbX3ZsNUQZZR+GI9uP6/iS3LlmJZAjz86Egay8VpbmvarMYr86rHVV3N5rjf5NXVMA1Pwv5/4VTI1PQvPZeCRiAQ0xFsAHJ8kW832+/0/397JvWHcfvfF1/75gtfEVd75nD8gqPIJYHKgOm73TnZTmTxU4jE/bVbyvdQ6oRW1P/cHxKj9Rhyd9Bpv7Y5w1+mNG59A1yFJ4mm7TC56SokjuqJh+jtvGa2gnzqyQvtLgpbF+4ouXw0P5AZz4Zo47zTVF+05VTrwBLHHLKjgW8PrPDeuytoJSzW9c1iMgcWswCGqO4JIKrKyI5GVJsbgKpYxYlypfOU6dZSvDqD6t/K9cS8aMOmRPUlE5ZpZYJLITOyhPVoghhLE85SAvcpqyibhOFLWmEvOCBLahqsFbNs3kAapgHsT4dQdFtW6u9uoJFsBsn8XBIlJXSzcsujTKWcwyjr8tiwj7HVd8cwuCwtdZbWOho1VhG388y5EgThZmn2Y1+InhTpwPJ8z3POh8TTFrPbYt+RSKU9FJPJBahgBYqdtUxl2gEVfOs2ywewn4kGS4J+gHuEn9s/X4cSlUoKzLYtVmh0FMDyc+SaKjhWX7ors4iFpkv6Q73afnTZfHSC87ZD9y8RsImAJWerOlkDFqw5gGtmqjupMOv1SjRo/0WgCORQlb+QewWsREQMxGDWmkPfgjeFsIwIDWiaRsmBUtn6WPb4h7Kh5wWCe+ZIxv38XZNIHWX FNtmKKJy uU2xOHDX0gCEQUX9faEhBwlMTcrZqEFoDdVmPkqdo+ogACfuV7eBpPZiFPYCt0Wboy8DBm9M3vDmXeIqqJc0iqlK7KrS5q8k3R7Ux7GBwLgqWWIKxQuDeNV9W98DS6OGC4bZ+hlsSCTQlDVz0kuLYfSfD5RVUJu3XOYtbdJLCZP7Y+KlGlEng8XwkVmWfGiiARSJ8+gMyblvMzi93CDJk5/qKCqOrd8Z16kvIEkKcp3004rqIYgFnjvyLcJLkn6O9t1Va 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 an mTHP 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 mTHP in zswap_store(), compress it and store it in the zpool. Signed-off-by: Kanchana P Sridhar 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 449914ea9919..59b7733a62d3 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -876,7 +876,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; @@ -894,7 +894,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, @@ -1458,7 +1458,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 Sep 24 01:17:04 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: 13810016 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 8B9B8CF9C5B for ; Tue, 24 Sep 2024 01:17:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 645036B0089; Mon, 23 Sep 2024 21:17:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5F51E6B008A; Mon, 23 Sep 2024 21:17:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 446C76B008C; Mon, 23 Sep 2024 21:17:21 -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 2220F6B0089 for ; Mon, 23 Sep 2024 21:17:21 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id A4C881A16A7 for ; Tue, 24 Sep 2024 01:17:20 +0000 (UTC) X-FDA: 82597868640.26.9EF488E Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) by imf08.hostedemail.com (Postfix) with ESMTP id 7C88716000F for ; Tue, 24 Sep 2024 01:17:18 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=dAplLPa3; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf08.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.12 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727140603; a=rsa-sha256; cv=none; b=6c/TosiBkMl3bJ7T5hd+47km/7WUTFoinYfQB9JV10g1Psx+fFrJfxSETUrxWAmUvunpfq yomry4MyFh5OE6uUaV6mvLitMwRuTPFftJne8KArfmRfJbAkbqdn2eEm5P2Huhfo9TT5WR 9lb5cU914d5exlHIqdTnbIbU3gsmmfI= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=dAplLPa3; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf08.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.12 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=1727140603; 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=EBv3m2nI93FladilCYs/u/j4frjUgCIUIZqiel6SNjs=; b=wSrXDg4P1H6nKDkETeRt9jC8qHnO5hG1IgiK+tohpg9xJ3VzvQcM+Cxh2vgKink++jLmgr En8dCSo81IooA8RwheTogL/FQbqos/w9G+/umfd/KIxt8ki12GX6MNmQdBEQxq5uP1+QT0 alawMeT8jimWfseuHUpNsjPboc1WuVY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1727140638; x=1758676638; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RHgitxCwk2O92AmxepTIkYLlPlxcPNy3AMLz8p6gNWk=; b=dAplLPa3MKGgvE5u6qeVAAFexb7Dr0m7os5pHhABOW78z1ahL1AsuUMj lHGHIi238vFoSAP3IT2RTCkMRvjZzVYgHg9fwIhviiK+y82ti4PYJ+Soc C2KH8dU2UD6yhMBuKCRM87qyrHJu1LMghFVn2JSw2FM4t220/AcOmssxJ upDQiREZTjntElrZZi9A28uJ2Wi+Qwgb/Lsms3PNdul6qwbpo5Orftvqn bKg0sSLT2rb7XSiKY7Z6M5JyriMqSOJLKoqzElvJbGE5LVNSwbJ1EBexc qkPly2zJ7GBWFt33sxFq0qK30RtMOnhJJwu0tIx+bq/CS4gBWjFK0M/NW A==; X-CSE-ConnectionGUID: zC5nTFl8QEKbZ3Y5uZXiiQ== X-CSE-MsgGUID: L2O18fw1Q9CkPp3zRaILNQ== X-IronPort-AV: E=McAfee;i="6700,10204,11204"; a="30002020" X-IronPort-AV: E=Sophos;i="6.10,253,1719903600"; d="scan'208";a="30002020" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Sep 2024 18:17:10 -0700 X-CSE-ConnectionGUID: l8/bok0JQDenH8syzM42bQ== X-CSE-MsgGUID: 3+hniOHXQ32cgOpTEREr0A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,253,1719903600"; d="scan'208";a="108688451" Received: from jf5300-b11a338t.jf.intel.com ([10.242.51.6]) by orviesa001.jf.intel.com with ESMTP; 23 Sep 2024 18:17:10 -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 Cc: nanhai.zou@intel.com, wajdi.k.feghali@intel.com, vinodh.gopal@intel.com, kanchana.p.sridhar@intel.com Subject: [PATCH v7 3/8] mm: zswap: Refactor code to store an entry in zswap xarray. Date: Mon, 23 Sep 2024 18:17:04 -0700 Message-Id: <20240924011709.7037-4-kanchana.p.sridhar@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240924011709.7037-1-kanchana.p.sridhar@intel.com> References: <20240924011709.7037-1-kanchana.p.sridhar@intel.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 7C88716000F X-Rspamd-Server: rspam01 X-Stat-Signature: ro33ahszeqpfj8gwx4eh1pk7xa5ezkhy X-HE-Tag: 1727140638-18410 X-HE-Meta: U2FsdGVkX199Sn2Hc/bSpwiZGPX+g+7TopnoCwD/z2VV8Hf8n1XyTvqIfhJOp+ks924gI6rBpVDYYVG6Z7teD2XkbDo1irXIJrWybgHPp7tih3fNGZgFOB5zmpreMpzrHPIX5+KtWaJlf2/opaOVHYJW0y3fLqO2yuZc6cYy2+ZgD7q+ex4bOmWaXMtxjFbSK9HIHeHzr6gvtn7AWUoPZRfWfjxQvINg3h68xDfOemsMCMqGqkgSbHVUvEMlB3u9Ik/SZHtHEI1ClHb4u+8zv8JbWJs0HunFJHX3ase/qwskg81D8XaTiDGUU96fvl4tdWzJTZ8/SFbQLZNeqeyBphHTTA5rzGnzX95XrKp0oT7hifKtqthx3g3F5p86OqBkBUZvCn7Hj3qWkR695mhE7ta0QHB5x9AQZhSH3gKJl1mdISvprLY1c/2M+wDYD8O19336xh3VJyq+Kgu+cNo/bC/bfRdNpCpA6T3Rcj/EJTuBcmGwdyI59DVE+YicHKy06Ce3ta7JzjOH+y3l5dZwBCHdUb8B66W0UBEHmv80hf057bBRJt6YsQc7gokFRdweUu72MahIsMjJJR3N+5Sq1anU/JC8K/qhTUH2iYy18lSm3ZvGOs6fuvErqxo5dE8wfhjuo7PlMfTUgh1aVU/arDXAvD5kBRkxY00mOpEiPUuMB59PVLZNSDdUJGUIxt79+obPXSeITG6FQ0Foj4IQULjx9PKShHaY0Cg3O2IGbWHt33CLkFwAl0vnMigaYBjJG59wLqpbRsgonbsygg3KvypYzgOevat0N0/p3JudwRPs9P+4BzNfVNoHFVsrN8Mknp6B6b5f0n0merV78gL4OFeNXW2L/K+OzK05OJTGLMDu5QZqY4Peqh/CJB/kNTkRr3mJ3YlsZKSw4sQYjGBSir66L2b+VYZXnpgyczCGN9S9p4Ut4piMilccHoestTuy0/lCmARxrV8wLCOBHdO a3ybvtH7 PgIif0zgTwhQ3YaOMF51dGnjkb07aJEE/Ax3G6aobUVdjI+9P+S5kTpM0NecC9nJvdyAjPd/Hj8Dn3iR2n0eRcyrCMJnypyR6/JhDgviTJ69IzLSFoJCIbLEMTFXBzWq1wCWcluSYfV70EdmGu5vFOFgxX1BCuOYGYR+j8GKMUqE4cTGRDBBhPGfGHA== 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 procedure zswap_store_entry() that refactors the code currently in zswap_store() to store an entry in the zswap xarray. This will allow us to call this procedure for each storing the swap offset of each page in an mTHP in the xarray, as part of zswap_store() supporting mTHP. Also, made a minor edit in the comments for 'struct zswap_entry' to delete the description of the 'value' member that was deleted in commit 20a5532ffa53d6ecf41ded920a7b0ff9c65a7dcf ("mm: remove code to handle same filled pages"). Signed-off-by: Kanchana P Sridhar Reviewed-by: Nhat Pham --- mm/zswap.c | 51 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/mm/zswap.c b/mm/zswap.c index 59b7733a62d3..fd35a81b6e36 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -190,7 +190,6 @@ static struct shrinker *zswap_shrinker; * section for context. * pool - the zswap_pool the entry's data is in * handle - zpool allocation handle that stores the compressed page data - * value - value of the same-value filled pages which have same content * objcg - the obj_cgroup that the compressed memory is charged to * lru - handle to the pool's lru used to evict pages. */ @@ -1404,12 +1403,44 @@ static void shrink_worker(struct work_struct *w) /********************************* * main API **********************************/ + +/* + * Returns true if the entry was successfully + * stored in the xarray, and false otherwise. + */ +static bool zswap_store_entry(struct xarray *tree, + struct zswap_entry *entry) +{ + struct zswap_entry *old; + pgoff_t offset = swp_offset(entry->swpentry); + + old = xa_store(tree, offset, entry, GFP_KERNEL); + + if (xa_is_err(old)) { + int err = xa_err(old); + + WARN_ONCE(err != -ENOMEM, "unexpected xarray error: %d\n", err); + zswap_reject_alloc_fail++; + return false; + } + + /* + * We may have had an existing entry that became stale when + * the folio was redirtied and now the new version is being + * swapped out. Get rid of the old. + */ + if (old) + zswap_entry_free(old); + + return true; +} + bool zswap_store(struct folio *folio) { 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 zswap_entry *entry; struct obj_cgroup *objcg = NULL; struct mem_cgroup *memcg = NULL; @@ -1465,22 +1496,8 @@ bool zswap_store(struct folio *folio) entry->objcg = objcg; entry->referenced = true; - old = xa_store(tree, offset, entry, GFP_KERNEL); - if (xa_is_err(old)) { - int err = xa_err(old); - - WARN_ONCE(err != -ENOMEM, "unexpected xarray error: %d\n", err); - zswap_reject_alloc_fail++; + if (!zswap_store_entry(tree, entry)) goto store_failed; - } - - /* - * We may have had an existing entry that became stale when - * the folio was redirtied and now the new version is being - * swapped out. Get rid of the old. - */ - if (old) - zswap_entry_free(old); if (objcg) { obj_cgroup_charge_zswap(objcg, entry->length); From patchwork Tue Sep 24 01:17:05 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: 13810017 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 73173CF9C5B for ; Tue, 24 Sep 2024 01:17:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D4B9F6B008C; Mon, 23 Sep 2024 21:17:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CE3F56B0093; Mon, 23 Sep 2024 21:17:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B723B6B0092; Mon, 23 Sep 2024 21:17:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 9B4976B008A for ; Mon, 23 Sep 2024 21:17:21 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 519FCA16AE for ; Tue, 24 Sep 2024 01:17:21 +0000 (UTC) X-FDA: 82597868682.21.B774DB1 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) by imf09.hostedemail.com (Postfix) with ESMTP id 233FD140007 for ; Tue, 24 Sep 2024 01:17:18 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=SZZv6PUn; spf=pass (imf09.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.12 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727140579; a=rsa-sha256; cv=none; b=sUdn+aKxV6i5f8nubi1fxTgDDzSS5EO2C9f1aDlTL2TwjWo1myWuu+xdyweqbxAngT/pOj Opkm41dhkBSPMn219XFX5bvVGlp/08ug121EZ1NbzJEb87s4bFrrlE++9eJrhB32xTPAGv tsxjFMwXAJTx3bJCWVnzEp7/crqb2U8= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=SZZv6PUn; spf=pass (imf09.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.12 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=1727140579; 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=YfUB20h+ZbfWHXPjxyHIrlPz9ExwouRgac9n957/Lm8=; b=pCz61/tlW8Fk90SGIUhz7Qvf3zSssjxNpiGrskNkFsG5Ve4h1xX4t+slxsVqf/DGATdV1+ sZVi94lir+RJKGrtsWzDuA53W9iqpD20m0oJ27qvtXz0QaDPH3uNyVA8G+X6CKMggX0QJu gKgm1ungz47dk6QmnLmrUUCAhPMr2fg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1727140639; x=1758676639; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=C86so49XKpWlsyU2wpioV+UDdpE1jz5mE0FAlDLAhFE=; b=SZZv6PUnJj1997NGsPTLbA0B5sX4tvp5Op2k82qSHMYRvFzEP+LS4t3t zHioAHW+g6p8rgUr0LDWOLEL3FPsvegWFsy5h8gRVhYbdY+JDQ4rXM3Oi mnNuNhnHAZmpfS5yQF82P4zV+4UplmflCj07mkmeE1JqFAEjHBO9ZrLJy Lp4+sRxvV+B6wr7iqiJoKM7EHRCAoz3XUqPErsGU1WJWh6GkwqCSUvZFe W2wwGaVh1IKUG9xUQUbShn0SdhjUh+xvplTS/z7B7IKYGwrrr6yr+Yowg BeyxOHSCK6uw8jmMw3stUmGUBWISo3i+sE8ddeJFYGERuA/wcVsmuUG81 g==; X-CSE-ConnectionGUID: EKgL/Z5hSb2YgbCpwruddA== X-CSE-MsgGUID: SkL9sTUOSFGdO5fXUAbCNA== X-IronPort-AV: E=McAfee;i="6700,10204,11204"; a="30002027" X-IronPort-AV: E=Sophos;i="6.10,253,1719903600"; d="scan'208";a="30002027" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Sep 2024 18:17:11 -0700 X-CSE-ConnectionGUID: sEGsfpQ9TySxYR5zKcbTVw== X-CSE-MsgGUID: jSs+zcAeQrCa4Hib2fFedw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,253,1719903600"; d="scan'208";a="108688454" Received: from jf5300-b11a338t.jf.intel.com ([10.242.51.6]) by orviesa001.jf.intel.com with ESMTP; 23 Sep 2024 18:17:10 -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 Cc: nanhai.zou@intel.com, wajdi.k.feghali@intel.com, vinodh.gopal@intel.com, kanchana.p.sridhar@intel.com Subject: [PATCH v7 4/8] mm: zswap: Refactor code to delete stored offsets in case of errors. Date: Mon, 23 Sep 2024 18:17:05 -0700 Message-Id: <20240924011709.7037-5-kanchana.p.sridhar@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240924011709.7037-1-kanchana.p.sridhar@intel.com> References: <20240924011709.7037-1-kanchana.p.sridhar@intel.com> MIME-Version: 1.0 X-Stat-Signature: iq6tth6fmutj16bru1szq57txo8wpiti X-Rspamd-Queue-Id: 233FD140007 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1727140638-51306 X-HE-Meta: U2FsdGVkX18MNgv15U/8IEHO5uVTrM1EH5Uns5fRF9z9SqRY8PUvBqWbQ09V+JcuF2IJ2U4J4LJVRM7CpsRrV3K2qbuvl4SI1sXlSAdAqVhxDvHgf4vxhibFO+3D6M7Y0p1nwuPNxSksfTOJ/NshPn4viZsILCfithfFUSxrLm4X+N3jb2AZsoZUht94mEcNsA95/mvic7Za028ArrFwQuI9KcDqCx0KRLRsC2BVIy5mYvywfdoF+3zeEZ2716n10ZMAerN0EEqWfX0N0CafO5GqGn5E+t2Tgyf79yXwZbwooxhaN5nYlhLtRphtdPD+cIujIGqeEKjoKVOF8IGsvlxuIyboCEB198TPy7V3JfDYc9PyMJF1UactFEh+JOaOgZD0GyACcchtsXTsovnBi9qPURjk3J/xiP0+e614io1y8itL8rVH1PFlzXfZsxUb+xqzXkbmUYHY8zljxYDsZTB207CnyY8yUG6hBUjgqv5WscHCJFFDJAe230ZTdtEbDN33cWtJb2cxItq5vhJCkAue6VIUocq5O3HW+FHJaE3g7WcgFO4wIyGt9Epu2Jo2EdUwFxBcCgylw7A3Z8kxz+BS0fv/KzXwcCkSdtzTYsOpU+UEespQARd/JdyW7ntfch032K+NWI1n2QevpUyvkkGG5dP2LUwK7F1+KBsVo8SW8K5n33Gytzpsrv3TYX29qDK0gQcsHI89AqVb1d4115hZ7YAuZh8stsA4GwzvHfFAZmXFO6KNvxXJAHupwNpTlELGeNjfR8uDWCEj0OuvdLRf71a7Dmc+GCIaAmg8A8AZMpcV5/fCaG1BdBST4pCrd+PfWkABhxCXCOY/oLKdRn/qMbz3P1kRT4TpjdttcoTZRLaVyaUa2RxiW7IlKuBo3CkYBns/HPkzXLTV2vSg5skeDUeLDi0HlmbjHbwTGDTqOEb4SmiXwNs9M5ySpwSDYgvxylrJV7kh3qeI0qN b9gV9nXt 0WZqXwu98PqkDDiY8+F66ikClgb/L67T+YQugpl138dMfFYzuNTniqaP8SOnrcTEkGX86K5doILBmkgEnYrJ7ST0BqUrlNP7UD4Y0Swg1hk24rPSMJrSDvT+wZYiXJGqlBMifvJzfb74C0zbndlyz/agIG28BM/B0zRtKEkPtb7/tmPthP8o5AG34ivlVOZPpBIOUFc+9IxW8ynai4aBDnGq3Vw== 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 procedure zswap_delete_stored_offsets() that can be called to delete stored offsets in a folio in case zswap_store() fails or zswap is disabled. Refactored the code in zswap_store() that handles these cases, to call zswap_delete_stored_offsets(). Signed-off-by: Kanchana P Sridhar --- mm/zswap.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/mm/zswap.c b/mm/zswap.c index fd35a81b6e36..9bea948d653e 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -1435,8 +1435,37 @@ static bool zswap_store_entry(struct xarray *tree, return true; } +/* + * 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. + * + * This is called after the store of an offset in a large folio has failed. + * All zswap entries in the folio must be deleted. This helps make sure + * that a swapped-out mTHP is either entirely stored in zswap, or entirely + * not stored in zswap. + * + * This is also called if zswap_store() is invoked, but zswap is not enabled. + * All offsets for the folio are deleted from zswap in this case. + */ +static void zswap_delete_stored_offsets(struct xarray *tree, + pgoff_t offset, + long nr_pages) +{ + struct zswap_entry *entry; + long i; + + for (i = 0; i < nr_pages; ++i) { + entry = xa_erase(tree, offset + i); + if (entry) + zswap_entry_free(entry); + } +} + bool zswap_store(struct folio *folio) { + long nr_pages = folio_nr_pages(folio); swp_entry_t swp = folio->swap; pgoff_t offset = swp_offset(swp); struct xarray *tree = swap_zswap_tree(swp); @@ -1541,9 +1570,7 @@ bool zswap_store(struct folio *folio) * possibly stale entry which was previously stored at this offset. * Otherwise, writeback could overwrite the new data in the swapfile. */ - entry = xa_erase(tree, offset); - if (entry) - zswap_entry_free(entry); + zswap_delete_stored_offsets(tree, offset, nr_pages); return false; } From patchwork Tue Sep 24 01:17:06 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: 13810018 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 CDFEDCF9C73 for ; Tue, 24 Sep 2024 01:17:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 387356B008A; Mon, 23 Sep 2024 21:17:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3397C6B0092; Mon, 23 Sep 2024 21:17:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 033966B0093; Mon, 23 Sep 2024 21:17:21 -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 C442F6B008A for ; Mon, 23 Sep 2024 21:17:21 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 79D4216145B for ; Tue, 24 Sep 2024 01:17:21 +0000 (UTC) X-FDA: 82597868682.14.A56A9F5 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) by imf03.hostedemail.com (Postfix) with ESMTP id 5C9732000E for ; Tue, 24 Sep 2024 01:17:19 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=nZbaL8q9; spf=pass (imf03.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.12 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=1727140520; 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=mHMd+SqdnpxAzHVAFfwrphaSBViVXbwMZjo7qjKq8N8=; b=kasBuCqCyHxUCMCZs2HE+ECSHPCXZqsdon0EFKBlPGEO3Ou0PUDbAnBUId6DpGTa2gcYLg AxEgTQ2xTl8xM1J/GNVEsb6y3Ke1Uh0ILIRMlF+R6uzFpMf/7ULDALcyTvj+cEepW6i3dX vNkQ4488lzJOBOMSI1n34sSCP5Zkv4Y= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727140520; a=rsa-sha256; cv=none; b=vh0VIz8sYTOyz7IB6gRsi7q16nMnrgXEC6TXhhVtw8MP/sH7Hhtu/ejmUMZFvOzh9YVfZP lD2tp6mAjH3QL7T9UAaKQLFSrHR1Mg/kOmOB7nn09jAwtcN+tTEnqfsbxjX0lmMZ9lO10s +iZiJR3Gimc0hi+uciCYfzkPWaGN5vw= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=nZbaL8q9; spf=pass (imf03.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.12 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=1727140639; x=1758676639; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2mNeQTWJUlWcoSNPRsAXaDiBYPB5nqJS0eAJPgQB/Sk=; b=nZbaL8q9n+knCf+n0mbYe40FuEb3V/kVX+kkpGiT4USh4vl2AoNgJkdD guYzOx9YqaG13tfONv0FBuYdmGKC+xiXmxkwr/PN6QoMB2H9Gp3rAGTz/ xfH6PuCz7PKlA2Iq2t1DE28KdqhQusRh5zKLy+GotRFlx0MPfJgiuW+on CUEAD1Lfu1K7BP1dCPXPMnxvCzetUdx6315Pbt5lKdAcIOJDT+Iw9h4yT uVzq1+Z8ykooWDW1T8dpd4e/uHKnm6b35UatCRcFHZUSLj3D+YnU20fAB CUA6VnhXXUXn/jvHCuSV0/Adg19u5OAw8M13FwQOi3Xuuk3FYErSy3RPt A==; X-CSE-ConnectionGUID: toTHajqlTfW9v+Jw+sevHg== X-CSE-MsgGUID: tpPpg9ZITyC704XOdE7NBQ== X-IronPort-AV: E=McAfee;i="6700,10204,11204"; a="30002035" X-IronPort-AV: E=Sophos;i="6.10,253,1719903600"; d="scan'208";a="30002035" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Sep 2024 18:17:11 -0700 X-CSE-ConnectionGUID: e+1Xguk5Qg+HYwyEEGg18Q== X-CSE-MsgGUID: zCaUK/6kQ9uT9pt7psyHcA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,253,1719903600"; d="scan'208";a="108688457" Received: from jf5300-b11a338t.jf.intel.com ([10.242.51.6]) by orviesa001.jf.intel.com with ESMTP; 23 Sep 2024 18:17:10 -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 Cc: nanhai.zou@intel.com, wajdi.k.feghali@intel.com, vinodh.gopal@intel.com, kanchana.p.sridhar@intel.com Subject: [PATCH v7 5/8] mm: zswap: Compress and store a specific page in a folio. Date: Mon, 23 Sep 2024 18:17:06 -0700 Message-Id: <20240924011709.7037-6-kanchana.p.sridhar@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240924011709.7037-1-kanchana.p.sridhar@intel.com> References: <20240924011709.7037-1-kanchana.p.sridhar@intel.com> MIME-Version: 1.0 X-Stat-Signature: 73pfzddr99n88b7o3c3tr5fqm6pkkfe4 X-Rspamd-Queue-Id: 5C9732000E X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1727140639-633004 X-HE-Meta: U2FsdGVkX19lvO7rFG1YdsMDFQ0CHRP6sZfvYSxpn69nNOaeoolariVH2tbnRPkRgcTcPsb55d6QgtFyZRgt08dyk6DtH877a5j0wXS+x2wLAHlsOjQeyWNn+QAzCHfRTpU9DjnI6jHT5cTVWGtgauaAIpLTSBIoyWh/rpWmEvqjkBmqoVE9Omd6/H1os39SKd9l4wLeZqihNdp8/ysvHgHXOLsRUxr8RpZSBNThRCVEz2AHH/whuA6C3WtaBp+N5y0FwV3eW7AyXmQWS4BpgKMNJNski9rPCDnTq1/epseuTXdUMTgmRmQ9GM/gPQ34hHBtBDT/cILC5v2EEINvnHYSwu+v7X+G2hcPK80f2o5W/0R+lSEqyh9TYySquZZc8UUn/doUSROCojqpsJYo/1X+CiDXP5DxEZVpzCeAhmE0fKAhbR1gSxeEuFhebhm48F8YpVfWkOUhAFKVma/grvKVx732NMGnT3Wqp0LLJuziltua8LqEZDuD781r4c0aBSMIIQId0xtUJg9GfpyPfCbcFzP0mrFhEMCCM+K7K59iJ1UuHffaHjoR9L71TNhGOUqH36tPw4y8EQdUiNrW7xWpB/nyJKO2D97fnn3jO6/HjnAxrvULnMaGVQRRnKS0G59lBlnXjg/Xd/nu8Eqg3UOcNC0eM2wKXq3rHSJKX/o6OWUmBzGZ1y00mKrAvoSv0bQRL5IEklh1jCd1YRdjrC1N/wsDCxwO3vpoZ/IEzqng71uif9C4DJ7HoAhpZWnwO/6lpp5kWEK862usm8/Mn/VjQqkA97EHRyw7CXTM+VYczOYqihhsT0tweLprwl+Tfi1kUvMSZxLSIZgQU1pK9/MVrp+UJ8+FzIJG27CN3aw6Ql6F0B+neGTNB6GIwRPjXD9Kfdn5hr1dLW7OAJNA8V4rKPleC9zveq8ZzV5CFdoTRmp9GQW77f4IwJWk4VoRnK0TUk9dYHMBzoUsWvN R8F/+pco 9P5vROQL05q++DZbUH706m3+GMzwIF0dMnwLCzPlIH7q112nDYp2tC3T9jGrdbwSlbSJVCgnamIZsEcHinXJ96DhwRyFsx55sO1Kd1XQN94wFTxdRaZGSpWY+MrjXbIu7SsxI4J3BKg5nuD+s2Wz2PgrVaBnO5V6zxsLzTE7zg95GvJXt0Cocpxu9yMZOWZoyqo4E2ZsRX5x8DrFbLbUEwZn6Jlda6hrYMeiH0mTdQ04hGUs9UFR36gDgUj7XqmM56hbr 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 handle mTHP folios, we need to iterate through each page in the mTHP, compress it and store it in the zswap pool. This patch introduces an auxiliary function zswap_store_page() that provides this functionality. The function signature reflects the design intent, namely, for it to be invoked by zswap_store() per-page in an mTHP. Hence, the folio's objcg and the zswap_pool to use are input parameters for sake of efficiency and consistency. The functionality in zswap_store_page() is reused and adapted from 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 --- mm/zswap.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/mm/zswap.c b/mm/zswap.c index 9bea948d653e..8f2e0ab34c84 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -1463,6 +1463,94 @@ static void zswap_delete_stored_offsets(struct xarray *tree, } } +/* + * Stores the page at specified "index" in a folio. + * + * @folio: The folio to store in zswap. + * @index: Index into the page in the folio that this function will store. + * @objcg: The folio's objcg. + * @pool: The zswap_pool to store the compressed data for the page. + */ +static bool __maybe_unused zswap_store_page(struct folio *folio, long index, + struct obj_cgroup *objcg, + struct zswap_pool *pool) +{ + swp_entry_t swp = folio->swap; + int type = swp_type(swp); + pgoff_t offset = swp_offset(swp) + index; + struct page *page = folio_page(folio, index); + struct xarray *tree = swap_zswap_tree(swp); + struct zswap_entry *entry; + + if (objcg) + obj_cgroup_get(objcg); + + if (zswap_check_limits()) + goto reject; + + /* allocate entry */ + entry = zswap_entry_cache_alloc(GFP_KERNEL, folio_nid(folio)); + if (!entry) { + zswap_reject_kmemcache_fail++; + goto reject; + } + + /* if entry is successfully added, it keeps the reference */ + if (!zswap_pool_get(pool)) + goto freepage; + + entry->pool = pool; + + if (!zswap_compress(page, entry)) + goto put_pool; + + entry->swpentry = swp_entry(type, offset); + entry->objcg = objcg; + entry->referenced = true; + + if (!zswap_store_entry(tree, entry)) + goto store_failed; + + if (objcg) { + obj_cgroup_charge_zswap(objcg, entry->length); + count_objcg_event(objcg, ZSWPOUT); + } + + /* + * We finish initializing the entry while it's already in xarray. + * This is safe because: + * + * 1. Concurrent stores and invalidations are excluded by folio lock. + * + * 2. Writeback is excluded by the entry not being on the LRU yet. + * The publishing order matters to prevent writeback from seeing + * an incoherent entry. + */ + if (entry->length) { + INIT_LIST_HEAD(&entry->lru); + zswap_lru_add(&zswap_list_lru, entry); + } + + /* update stats */ + atomic_inc(&zswap_stored_pages); + count_vm_event(ZSWPOUT); + + return true; + +store_failed: + zpool_free(entry->pool->zpool, entry->handle); +put_pool: + zswap_pool_put(pool); +freepage: + zswap_entry_cache_free(entry); +reject: + obj_cgroup_put(objcg); + if (zswap_pool_reached_full) + queue_work(shrink_wq, &zswap_shrink_work); + + return false; +} + bool zswap_store(struct folio *folio) { long nr_pages = folio_nr_pages(folio); From patchwork Tue Sep 24 01:17:07 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: 13810020 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 D89DECF9C5B for ; Tue, 24 Sep 2024 01:17:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4BB066B0095; Mon, 23 Sep 2024 21:17:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 421596B0096; Mon, 23 Sep 2024 21:17:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 161EE6B0099; Mon, 23 Sep 2024 21:17:24 -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 E083A6B0095 for ; Mon, 23 Sep 2024 21:17:23 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 99D4C16145B for ; Tue, 24 Sep 2024 01:17:23 +0000 (UTC) X-FDA: 82597868766.29.5E95451 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) by imf09.hostedemail.com (Postfix) with ESMTP id 71BD6140007 for ; Tue, 24 Sep 2024 01:17:21 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=akDrgN+F; spf=pass (imf09.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.12 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727140581; a=rsa-sha256; cv=none; b=0hmn/p7GYYRG/7zmhjyxL4oWLqNKvC7+U70AVvkTA+zfYbbvUPL+rDf0f9qx+2ZpZEDIVd C7sVXUMe7UK02ArayWVzgD/JhmmWc2IJzj8nPo4k1jqSxDp0+/5ZjnILIQkWGEDMPSKgNX TP7LsJ2RgxEprB7QwFFLmFBsF+eglHI= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=akDrgN+F; spf=pass (imf09.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.12 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=1727140581; 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=Wpk9e2m9w0bKMmnLcils/bKHy9sueQxxMvfHpFn3D8M=; b=Jw7MN8fh9bCl801C8lhTuMTYu60JVmpIACr/z9ZN3FOXibCmv33eribL+ReG7O2Jtbnb5j eGLgbzF8uCwkRsJCDAU3FnZ4vBOYu4iJlwkJCmuORyPZw5Ivydd9vC1OCEzkRZvtctFY0g m+ZNafUAQladvrVy5Q3wXipud867PXs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1727140641; x=1758676641; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TC61NMZkVLT5VlFsRHxoHlVUivXlE7pDxlM31DB9mpg=; b=akDrgN+FuB02OT8XP1hpTfh0I4GckvigNFiYiJz7JkNNDUzeFnt54A4i mC7Lo68KNxi68c5kSCfA4z7QzGmbTLHcv5wCEZJ1VA7pQ6iotEHf4PDRi xLVPbawP3NuyUNroZqU5C7GLw5ptjsAzkX5mTez2KBtyzh4WDW7ZIr2Cc +hJ7+7C5hlVJ/H9sEkvEuszOgsiItTSO3ca9GSg6kwGZ48PKKZBGbCybB iqarnaHw3sJgQmKY2iCSH1L+IOA+n5WQPi9gEMxTKH4lDqJpY7pgdWEil 8tVFdhSaY4qnxgURE8vjIu3OL9y7cVicjP7+S4uJ1aE2aYCM55/2n4JpS Q==; X-CSE-ConnectionGUID: ykAbTKflQQWVHHbGCsCllw== X-CSE-MsgGUID: ppdh4lNGQ8S9K+sDN5ZhQQ== X-IronPort-AV: E=McAfee;i="6700,10204,11204"; a="30002043" X-IronPort-AV: E=Sophos;i="6.10,253,1719903600"; d="scan'208";a="30002043" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Sep 2024 18:17:11 -0700 X-CSE-ConnectionGUID: h6kZ0n4KQd2ezP+USAgHWA== X-CSE-MsgGUID: 6ihG0j0jSjSdRCs1upV+/g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,253,1719903600"; d="scan'208";a="108688460" Received: from jf5300-b11a338t.jf.intel.com ([10.242.51.6]) by orviesa001.jf.intel.com with ESMTP; 23 Sep 2024 18:17:10 -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 Cc: nanhai.zou@intel.com, wajdi.k.feghali@intel.com, vinodh.gopal@intel.com, kanchana.p.sridhar@intel.com Subject: [PATCH v7 6/8] mm: zswap: Support mTHP swapout in zswap_store(). Date: Mon, 23 Sep 2024 18:17:07 -0700 Message-Id: <20240924011709.7037-7-kanchana.p.sridhar@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240924011709.7037-1-kanchana.p.sridhar@intel.com> References: <20240924011709.7037-1-kanchana.p.sridhar@intel.com> MIME-Version: 1.0 X-Stat-Signature: mtj3ynzauphn4y79a33yessgizge5g8q X-Rspamd-Queue-Id: 71BD6140007 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1727140641-966411 X-HE-Meta: U2FsdGVkX1++STwyzNbHmJRZsxm0IEDWsNM98DbWKsB+UPtux8CEhyjLjTiuSBbDAVj0ioCjFuK03lxzIAvNB4LrEM7Cq4dNE3eHHmPHdJCulx9thP+D3C1/cgZdBE3nPpk3vTQDlWWgY3ctz+a4sOaVHfuejIkPV3XnEpFLnL40FEYrlOmRfl0YJQa9oze0EreftRduzKp8HzM6g6V7XSmQwy5jWNNGGFFld3k1tUsY52TNr++idb9a+u4ua0R+tQygRTpOClKHMjJL7onxQ4VeTKB6NHTP6NED+BvSVKtAqHypeXKOjyQlVK5mytsk4uIUOceA6CMQgXOGf7PeXSnFNuMkwxI3ad+kophLQwyeJjhl7Q5YIWs3KBc6EmKYCuc5Xan5jc4ug3ipUElb9zovvnYt6QXzlidBfwW9KSVlwtsxb83PwAooY7dfB4v1RJ8dwNAo/OTMJsW4GRg0XpIlFUhZdlFqJVTEARFQ3wL9OeJJ/ovdm8ohnphp0+yakEm2saHkj1Coo4ZkP7q/waoj5k2P/qJepvoD5gRn0M36pXAavIJyJ3IsGtpmTqoQ14MoZDiXnHak6lRaHxGKvP25hVw0v4B5a+GR6hXN0+FSflzyKTodUlDvoRbV0Q1nWu04479NcLL0erlZ2wOP1JDa8U8av2lZdxjIRVfHziGBektFY5iohsYxZVF/KtQZMeT+WMfo2Jvmnvulnitk3gdkE4LVUZRMfE4eRiXL/ximUn13RLP1nljo8T6umI85Yf6kZ56YkS819f8mDubI/676/03trmMCOj0hxidRrfyDUz42NDh+DpdPW1uCi9TkxjiZjtCAjJzZWsrfMCk3XRXCqy+859K29KPeS5T45oHqR12Z7d774Snbe3syCHNgYCNrTj53STc9PvJot6aegxhjzrunl657P5zPRB5Hy2ylep5vHCFPzRXEFmNpcfq/x+aEw54YfB8O7xZcXVb PtGcuixO NOJe/B5ImYObM/rS+UBPYXt8z6CzzsHaKAIin5ccdEA2taYa7Z+TQ+qH+pjmE+c39+JdV+nI96HyZSb5k/tcovWnoZhKqqgC57CB3XJM3aYOk5J8vmuoe9eiGE87nS4znvkdzjA20IoeY1V45XPUiRko1CLgQVadNySQmtFz/cyMiYOWk/Sfj0IjnTwKIOJ0k2HIOAa1+tD4Dh5gavH0McJq16PAzqnna2mNmA4M8zl1thneFsCLAaKq+KfG01GD6bmpHSPyVPcncIbhPWNTwFFzQrwD/r4jAenRRxWbWqYA2Bl401459AA+g5w== 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 now store mTHP and PMD-size THP folios by compressing them page by page. This patch provides a sequential implementation of storing an mTHP in zswap_store() by iterating through each page in the folio to compress and store it in the zswap zpool. Towards this goal, zswap_compress() is modified to take a page instead of a folio as input. Each page's swap offset is stored as a separate zswap entry. If an error is encountered during the store of any page in the mTHP, all previous pages/entries stored will be invalidated. Thus, an mTHP is either entirely stored in ZSWAP, or entirely not stored in ZSWAP. This forms the basis for building batching of pages during zswap store of large folios by compressing batches of up to say, 8 pages in an mTHP in parallel in hardware, with the Intel In-Memory Analytics Accelerator (Intel IAA). A new config variable CONFIG_ZSWAP_STORE_THP_DEFAULT_ON (off by default) will enable/disable zswap storing of (m)THP. The corresponding tunable zswap module parameter is "mthp_enabled". 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 Also, addressed some of the RFC comments from the discussion in [1]. Co-developed-by: Ryan Roberts Signed-off-by: Signed-off-by: Kanchana P Sridhar --- mm/Kconfig | 8 ++++ mm/zswap.c | 122 +++++++++++++++++++++++++---------------------------- 2 files changed, 66 insertions(+), 64 deletions(-) diff --git a/mm/Kconfig b/mm/Kconfig index 09aebca1cae3..c659fb732ec4 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -59,6 +59,14 @@ config ZSWAP_SHRINKER_DEFAULT_ON reducing the chance that cold pages will reside in the zswap pool and consume memory indefinitely. +config ZSWAP_STORE_THP_DEFAULT_ON + bool "Store mTHP and THP folios in zswap" + depends on ZSWAP + default n + help + If selected, zswap will process mTHP and THP folios by + compressing and storing each 4K page in the large folio. + choice prompt "Default compressor" depends on ZSWAP diff --git a/mm/zswap.c b/mm/zswap.c index 8f2e0ab34c84..16ab770546d6 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -127,6 +127,14 @@ static bool zswap_shrinker_enabled = IS_ENABLED( CONFIG_ZSWAP_SHRINKER_DEFAULT_ON); module_param_named(shrinker_enabled, zswap_shrinker_enabled, bool, 0644); +/* + * Enable/disable zswap processing of mTHP folios. + * For now, only zswap_store will process mTHP folios. + */ +static bool zswap_mthp_enabled = IS_ENABLED( + CONFIG_ZSWAP_STORE_THP_DEFAULT_ON); +module_param_named(mthp_enabled, zswap_mthp_enabled, bool, 0644); + bool zswap_is_enabled(void) { return zswap_enabled; @@ -1471,9 +1479,9 @@ static void zswap_delete_stored_offsets(struct xarray *tree, * @objcg: The folio's objcg. * @pool: The zswap_pool to store the compressed data for the page. */ -static bool __maybe_unused zswap_store_page(struct folio *folio, long index, - struct obj_cgroup *objcg, - struct zswap_pool *pool) +static bool zswap_store_page(struct folio *folio, long index, + struct obj_cgroup *objcg, + struct zswap_pool *pool) { swp_entry_t swp = folio->swap; int type = swp_type(swp); @@ -1551,51 +1559,63 @@ static bool __maybe_unused zswap_store_page(struct folio *folio, long index, return false; } +/* + * Modified to store mTHP folios. Each page in the mTHP will be compressed + * and stored sequentially. + */ bool zswap_store(struct folio *folio) { long nr_pages = folio_nr_pages(folio); swp_entry_t swp = folio->swap; pgoff_t offset = swp_offset(swp); struct xarray *tree = swap_zswap_tree(swp); - struct zswap_entry *entry; struct obj_cgroup *objcg = NULL; struct mem_cgroup *memcg = NULL; + struct zswap_pool *pool; + bool ret = false; + long index; 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)) + /* Storing large folios isn't enabled */ + if (!zswap_mthp_enabled && folio_test_large(folio)) return false; if (!zswap_enabled) - goto check_old; + goto reject; - /* Check cgroup limits */ + /* + * Check cgroup limits: + * + * The cgroup zswap limit check is done once at the beginning of an + * mTHP store, and not within zswap_store_page() for each page + * in the mTHP. We do however check the zswap pool limits at the + * start of zswap_store_page(). What this means is, the cgroup + * could go over the limits by at most (HPAGE_PMD_NR - 1) pages. + * However, the per-store-page zswap pool limits check should + * hopefully trigger the cgroup aware and zswap LRU aware global + * reclaim implemented in the shrinker. If this assumption holds, + * the cgroup exceeding the zswap limits could potentially be + * resolved before the next zswap_store, and if it is not, the next + * zswap_store would fail the cgroup zswap limit check at the start. + */ 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; + goto put_objcg; } mem_cgroup_put(memcg); } if (zswap_check_limits()) - goto reject; - - /* allocate entry */ - entry = zswap_entry_cache_alloc(GFP_KERNEL, folio_nid(folio)); - if (!entry) { - zswap_reject_kmemcache_fail++; - goto reject; - } + goto put_objcg; - /* if entry is successfully added, it keeps the reference */ - entry->pool = zswap_pool_current_get(); - if (!entry->pool) - goto freepage; + pool = zswap_pool_current_get(); + if (!pool) + goto put_objcg; if (objcg) { memcg = get_mem_cgroup_from_objcg(objcg); @@ -1606,60 +1626,34 @@ bool zswap_store(struct folio *folio) mem_cgroup_put(memcg); } - if (!zswap_compress(&folio->page, entry)) - goto put_pool; - - entry->swpentry = swp; - entry->objcg = objcg; - entry->referenced = true; - - if (!zswap_store_entry(tree, entry)) - goto store_failed; - - if (objcg) { - obj_cgroup_charge_zswap(objcg, entry->length); - count_objcg_event(objcg, ZSWPOUT); - } - /* - * We finish initializing the entry while it's already in xarray. - * This is safe because: - * - * 1. Concurrent stores and invalidations are excluded by folio lock. - * - * 2. Writeback is excluded by the entry not being on the LRU yet. - * The publishing order matters to prevent writeback from seeing - * an incoherent entry. + * Store each page of the folio as a separate entry. If we fail to store + * a page, unwind by removing all the previous pages we stored. */ - if (entry->length) { - INIT_LIST_HEAD(&entry->lru); - zswap_lru_add(&zswap_list_lru, entry); + for (index = 0; index < nr_pages; ++index) { + if (!zswap_store_page(folio, index, objcg, pool)) + goto put_pool; } - /* update stats */ - atomic_inc(&zswap_stored_pages); - count_vm_event(ZSWPOUT); - - return true; + ret = true; -store_failed: - zpool_free(entry->pool->zpool, entry->handle); put_pool: - zswap_pool_put(entry->pool); -freepage: - zswap_entry_cache_free(entry); -reject: + zswap_pool_put(pool); +put_objcg: obj_cgroup_put(objcg); if (zswap_pool_reached_full) queue_work(shrink_wq, &zswap_shrink_work); -check_old: +reject: /* - * 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. */ - zswap_delete_stored_offsets(tree, offset, nr_pages); - return false; + if (!ret) + zswap_delete_stored_offsets(tree, offset, nr_pages); + + return ret; } bool zswap_load(struct folio *folio) From patchwork Tue Sep 24 01:17:08 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: 13810019 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 41494CF9C5B for ; Tue, 24 Sep 2024 01:17:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8DDE66B0093; Mon, 23 Sep 2024 21:17:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 865FD6B0095; Mon, 23 Sep 2024 21:17:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 691C96B0096; Mon, 23 Sep 2024 21:17:23 -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 44EA86B0093 for ; Mon, 23 Sep 2024 21:17:23 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 03A0D121687 for ; Tue, 24 Sep 2024 01:17:22 +0000 (UTC) X-FDA: 82597868766.02.068A20F Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) by imf08.hostedemail.com (Postfix) with ESMTP id C937F16000F for ; Tue, 24 Sep 2024 01:17:20 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=gFHJD764; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf08.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.12 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727140606; a=rsa-sha256; cv=none; b=ZJ/eBqCBaU5Z579t0yim0+slviulSjOpBi4CujE4F0FD5F+SQ+9XjagIE93Z0T8AE1xm4F rOqT+ZCdz5y3qxyBEeL6iRYyn1dnEPvn84bDmJXnBUdvLgU5yIxMV282IBFmSDnNjJsltP Rw0bNw2H9qboMiQ/9LaZ9Auw67PneFU= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=gFHJD764; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf08.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.12 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=1727140606; 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=IzCyQpijUi8KhTUi9wHeO0ohr9XKAejr7G14xu+UwfY=; b=D6LB3NzuHImhEeYyHa8q/Ny2hPk7X42QFI7cxlhYn693dsI83bD4++LFZCQtS0/Egjhk4X aM/frsORaeZIDkSAZhNu+1uSc0fBpCE3oiSS20U8m8Qd1TGbcLeMZBtoi8xY3l3fh0aGr+ SoGOUlsZdlUa6ymYCzSnXroO86Jn49U= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1727140640; x=1758676640; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nZQ5WdYOudXFblQyI1xpFNONjVx0pWlV5kfygJBmOHg=; b=gFHJD764nr9pT9bLiUIFzJ5mV52r+sgJ0ohqhsTrsl5Iue0GOUTi2svt wqhpEFRWvqe83gNGV1G4bjTaLaQSf2NwiJUmovd0C4u7JPLaHzpXnmYoC fHCvw6PIe/1VnYKE/krYBDUD/rWyashauCOgSIq9HSSGtUWGHVVvcP2Rq IbcBCDbNSQYNDTz/xxfFA5RXvS7Wbfv+xSdvYaa0b3dS/13Xj02rZC4gT 0o/kxQqfIwiL5KuxW0PRjkwZvOcgzY0oiCyAphcc4MPkpxBsWy7P+x9Ma /JhbcH1aOYeVLTKJxYX80WMMkWZGcHp296ZteFYaA46vL57lvJKwJ4nYd A==; X-CSE-ConnectionGUID: IGAvul6+SiODZDDFAmLZ/g== X-CSE-MsgGUID: ga44Iq2eTH22XNT5HNmINQ== X-IronPort-AV: E=McAfee;i="6700,10204,11204"; a="30002048" X-IronPort-AV: E=Sophos;i="6.10,253,1719903600"; d="scan'208";a="30002048" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Sep 2024 18:17:11 -0700 X-CSE-ConnectionGUID: udjgHgWqQzO/LxXYb+uyVQ== X-CSE-MsgGUID: lLNNKrXVTtWLEYgP3S0l6Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,253,1719903600"; d="scan'208";a="108688463" Received: from jf5300-b11a338t.jf.intel.com ([10.242.51.6]) by orviesa001.jf.intel.com with ESMTP; 23 Sep 2024 18:17:10 -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 Cc: nanhai.zou@intel.com, wajdi.k.feghali@intel.com, vinodh.gopal@intel.com, kanchana.p.sridhar@intel.com Subject: [PATCH v7 7/8] mm: swap: Count successful mTHP ZSWAP stores in sysfs mTHP zswpout stats. Date: Mon, 23 Sep 2024 18:17:08 -0700 Message-Id: <20240924011709.7037-8-kanchana.p.sridhar@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240924011709.7037-1-kanchana.p.sridhar@intel.com> References: <20240924011709.7037-1-kanchana.p.sridhar@intel.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: C937F16000F X-Rspamd-Server: rspam01 X-Stat-Signature: c97o5xsc9bsy187miekpin7ubeei64g1 X-HE-Tag: 1727140640-222424 X-HE-Meta: U2FsdGVkX1/mzS0ZfH9I4QISqDeaissxX79tObmLxQnKLd3meHrkD35Ys5kTqOcQgGsBDTzyiIIPSmtpLz3Wm+7WSHYpgZNuwxDM1kuyiM0WzTmWpxPnSlgaxPoJGGwfKwKOlhF8RG2dBBzctaGvkbDlV5fNo5sF6p6sUo6wHlQ3valKF8QULjHptkRGgm5Es90i1jLdvW4/qqRL47bOOFyyQu6vhge/RLY7OnKd3e8x/03lxD8Ihb5p8Oj9qPKaGFpA1c2fHuVqr7vgZGHZ6nL00l8mWLuc4y3R4s4+J+lxcTRuSujwVE3Pg2DfuOTySteMMa5mtEc5QHW1mpKjbSG3DhngdPRj+U2/zRvs4jRZI3b4e8xh26EYiKzC3/eCa7DCC6lOO2uNIzRhSTWiMPAjtJDi2WnER6dj1+b6Fnsh9ZAmI33X5nKlzW+bABKLkezYBwlbo1ecA2OVkvCUM6jCnnXSZUqeRJLksh9vTNM678Zc2XOzrq6iHsNZjR4uq+iTC9M+lRVhPdVdNO8vJfRbSk8wnK0hImE3d+m6uIbrZPeBQb0EdLy8bmFXvRFbxeXNsRosNh7OEsHrT54Yi0S3DxI//mrUQYrmDjHlZF1Y5ZyN+G9b8SjbTS1lhr9rjY3MYHy8DKSgJUFoY+4Yh/ITvuh7b1xoKt19XnKEvW21zWKtdVGAOzgk1NysAmJv47F0FUZF+lBrkASURmI5z6jPIGLUhW9JXqTsLahQQjlirJzcLy73zXcVDmypYP8brF0U1Y0L517qQcQyqbbpx8u/DkNnqJZ1gZkUMER8k++/lz/nD6DctPgsneFQPV2nwxbleg3SXux/ZrgEuEnZy+jM1BZ3j5V89l4kv57kKGEESfYXFGO9X+43PckclBXNXHZu6wLgHBxamYuHUCP+K+56Bj5RkKpcVQkCp8FAHnH5ER33mQuLfp9kZg8s2hz9iNqDL758R8Sd7ySNz6i nqX8dw6Z XPtoFkjySSqfGgSwkwqXIbHQ6bAx3wJ5e/UnfSB7SPHK66QHphXUhYGk5yQmydEiwZi3T0jie1mOXcYk2y5BxsV3G/ybGZe2TOFIwcfrw1Kqx9ARsujbwNqO2Ku2kK2EBx6uZa3DaDUYbXBo79u6x5ujvgTUwCgkhLUej0R5WJ746nJUHduBXYt4SKg== 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: Add a new MTHP_STAT_ZSWPOUT entry to the sysfs mTHP stats so that per-order mTHP folio ZSWAP stores can be accounted. If zswap_store() successfully swaps out an mTHP, it will be counted under the per-order sysfs "zswpout" stats: /sys/kernel/mm/transparent_hugepage/hugepages-*kB/stats/zswpout Other block dev/fs mTHP swap-out events will be counted under the existing sysfs "swpout" stats: /sys/kernel/mm/transparent_hugepage/hugepages-*kB/stats/swpout Signed-off-by: Kanchana P Sridhar --- include/linux/huge_mm.h | 1 + mm/huge_memory.c | 3 +++ mm/page_io.c | 1 + 3 files changed, 5 insertions(+) diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index 0b0539f4ee1a..ab95b94e9627 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -118,6 +118,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 4e34b7f89daf..7d8ce7891ba8 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -612,6 +612,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 @@ -630,6 +631,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 @@ -660,6 +662,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; } From patchwork Tue Sep 24 01:17:09 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: 13810021 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 A58B7CF9C5B for ; Tue, 24 Sep 2024 01:17:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 769E26B0098; Mon, 23 Sep 2024 21:17:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B8566B0096; Mon, 23 Sep 2024 21:17:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3ACDB6B009A; Mon, 23 Sep 2024 21:17:24 -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 05CC86B0096 for ; Mon, 23 Sep 2024 21:17:24 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id B1900AC729 for ; Tue, 24 Sep 2024 01:17:23 +0000 (UTC) X-FDA: 82597868766.28.670F292 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) by imf03.hostedemail.com (Postfix) with ESMTP id 99E7D2000E for ; Tue, 24 Sep 2024 01:17:21 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=lfAAnKzt; spf=pass (imf03.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.12 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=1727140523; 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=hYr/0fE/hEH7EXfr+sA39oMCJTKJM3BQ1R8I1zTAG5k=; b=Kioa5KfbxVHZLkgULpWkFYp5Xb6CSVYB0vsbN5clm9FP8CzFU3+V+lB5o9oWvw+wfNaOvC arq7xz+F4+OZ19oIUDRGf3obTrRB0pzxiLB5b+D5iejd3ODqu90RoX1AHxPIF5nZbj78Fq EcFov/TfW6ywIgLP6xFpndZfYVlDU9c= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727140523; a=rsa-sha256; cv=none; b=lpgCgN94mgYuisCfWCKj8szhr6bdXoCaqgPALWbeIo0zd5JSZmxpmzj1KL0c4QL569Nb/3 tmu7x+kHVrxx8YgsyhWVFagHrTV2tNo1Xa5A1WvO4duwVGgcFAWAbVNj9GBjZIWWYoeBqp QC2v1S1d8qGURvuoszCcWlfAiufvsK0= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=lfAAnKzt; spf=pass (imf03.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.12 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=1727140641; x=1758676641; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6ALoeaC41g+MaGEwJSRyCvBiONdX4EAtPZdFIMUQEE0=; b=lfAAnKztoMX1kyVthhgb8tae9VejhfjwE71+v+ojhZWSZxl7yVuxVQa+ mivpfSqsl5uhu+RnlxJS/lbW3z+QuxwcVz8+EJ42EMzcxj1wOgsnH/8GD qvCc+stgM2gMm93wZdSDD/qezuHx/tbh26gT80cF2BXICm+5EvVgZx27O 9DHQx6cHCJtbn01h+JQHjrbMJJUGZKgUCIYCo+bKsTd4N5zSb33artgJz PdvoR8i0wF0K3wSnAGUjPhT1aeM6DjusCWoYSHKKLDgM4dMc6zah+VeT3 4QG/9LMkgR2gL2wkEjJsmlINNAqLDtbX5S7OLchewMAbV2hE23R2JAyw9 Q==; X-CSE-ConnectionGUID: yIhbLTWaTLSIdtHySu0YSw== X-CSE-MsgGUID: H050/3llQ7Scrac5b5dhSA== X-IronPort-AV: E=McAfee;i="6700,10204,11204"; a="30002053" X-IronPort-AV: E=Sophos;i="6.10,253,1719903600"; d="scan'208";a="30002053" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Sep 2024 18:17:11 -0700 X-CSE-ConnectionGUID: XVBMt6QAQySzvitwOcWK+A== X-CSE-MsgGUID: EuABZkyHT6aA0zdKQwNlSA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,253,1719903600"; d="scan'208";a="108688466" Received: from jf5300-b11a338t.jf.intel.com ([10.242.51.6]) by orviesa001.jf.intel.com with ESMTP; 23 Sep 2024 18:17:10 -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 Cc: nanhai.zou@intel.com, wajdi.k.feghali@intel.com, vinodh.gopal@intel.com, kanchana.p.sridhar@intel.com Subject: [PATCH v7 8/8] mm: Document the newly added mTHP zswpout stats, clarify swpout semantics. Date: Mon, 23 Sep 2024 18:17:09 -0700 Message-Id: <20240924011709.7037-9-kanchana.p.sridhar@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240924011709.7037-1-kanchana.p.sridhar@intel.com> References: <20240924011709.7037-1-kanchana.p.sridhar@intel.com> MIME-Version: 1.0 X-Stat-Signature: d8rhk6wni5pknytxexi75qzznemdsbxa X-Rspamd-Queue-Id: 99E7D2000E X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1727140641-14380 X-HE-Meta: U2FsdGVkX19eFxbSDurwa9gYlmIrMMKueNkCKSF9sDdF/Nlgy/Mp7FDRLD2QJB9/fZU6B4RLDXmWcqptaR0FCkEfM0ABv2TRtmqx3lmCknkOtnmvjr0Uo33AvO85cwo/NkO37CfFgIQWLt5KtKYtGRXIzb6tfQ/IA/zJuZz4lNJ85ifheIEdmPsfBePJhhqV3WKesk50+2V21wijG6g+1SvToxEBCeu7r881/edIDZIPwrc+14qY4SpotVpnMW+qSPWWG5H30HuotXPxV7DmrICr1igJjCEDsF9SMC+RfZgE4W3j65+mscTmFpuuI59PGnccGXc//CajBD1SZ/EODgNw7Hq+iiPJDS/koIRsWGkWXn05x2+QkOjOnWX/75T041tgWvpA6hkuz4BV0XU2yaszLBY/NOc4YoSgyGVQocVupeG4+xILRLipkiCHwX2P9e3VDrfoGXlHBk4rCEdYUxFyUbHzRlfsNb+4EFcqS0g7si2UbCEHx3WnW1pOWEEw2D2/IkY9v/blYVJP4kHuLrslymSW+wwhlWWpd+whOkmLEx8hZjhZ4j6KwZVV48MM/eDTZuqrGSSpT1EwyLdO3ciSnGy//F7lA75pCEG90sssqviwkOpnqNAKeUPWbH0BuRPpHOYMs7JsOFoGE6rE3q5DpBGyPOJ3HXryWShZUv71TSYdGwCHSKX/bH7W/C3Wwv97Q6pTb/aealquSL7Gxxpiqav4dMmXunN7sQc7S+HcgTrsyV0D8pkcCFYSzy+7+d+oZ5tjf1gqSrIspl9w8/FKIRa7fyWAtcfpNZCu8w/EVIjYMs4uK6gl5mUCO6RPtJ/eccNm91x3dtjT7K8WX+pdnjefD9sk6Jujy9RR1V+11ZwTqQQDWqIuGj3EKAoUvV47vwoGDsAGMeJTah5bZrJLYGbktru2YZ1PtNN+Lh4QskunTEteLb14a8ZkktcHP8itLqQFukErG0iaQqd iuc2rKWr 8Mk4KzJuIv6Yc9hswygkbDbzkch1wwN/JB80F0PhXrIe9+8DXuGSKB1J8YHggP8Z/QXgzoA+/xQ42DX2wJGyti+Zyv3goxHMkmScdpUuvJY4VS/DPXk7zoSLlFv71e+hhZeK8KReEyIOiqZp9YdaC6rNnFdDZKI1XP+FnHCAUz9GuaN1Ge6DcV+C9dw== 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 documentation for the newly added sysfs mTHP "zswpout" stats. Clarified that only non-ZSWAP mTHP swapouts will be accounted in the mTHP "swpout" stats. Signed-off-by: Kanchana P Sridhar --- Documentation/admin-guide/mm/transhuge.rst | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Documentation/admin-guide/mm/transhuge.rst b/Documentation/admin-guide/mm/transhuge.rst index cfdd16a52e39..a65f905e9ca7 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 entity 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