From patchwork Thu Aug 29 21:27: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: 13783908 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 E1F57CA0EC3 for ; Thu, 29 Aug 2024 21:27:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 17C566B008C; Thu, 29 Aug 2024 17:27:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1061F6B0092; Thu, 29 Aug 2024 17:27:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DFDF96B0093; Thu, 29 Aug 2024 17:27:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id AF2C26B008C for ; Thu, 29 Aug 2024 17:27:15 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 6C090C08ED for ; Thu, 29 Aug 2024 21:27:15 +0000 (UTC) X-FDA: 82506568830.11.9298DAC Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) by imf05.hostedemail.com (Postfix) with ESMTP id 55DC7100002 for ; Thu, 29 Aug 2024 21:27:13 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=fWa4YkxV; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf05.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 198.175.65.19 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724966760; a=rsa-sha256; cv=none; b=HwrapetmHjzOe9DzcpZloTMrSTsJ89/Tu+D39dxSoVVv0fMLg+wfkEvDuTOnfz8tNuf1fO rjNMNB8LLix/CLa5LxrhP2LaNiz6qkgNCkELRfjAgJNGbbwuazsLSFOPyUx1DkU2ZJR+pl dAc3CEHpENirofoFceM6/BSZNbK/9m0= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=fWa4YkxV; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf05.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 198.175.65.19 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=1724966760; 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=YHJDZPJGQ3yjt5nx/9DOnI7WGhrGbTA0Swg/OJGz+RI=; b=LIGpix1qYe6WndbrzholAhcOZcdcDyyzvTsWa64oe9xjkzSm3zBjxYOjx0a/B5JmrSRyUj TdGZrthQLhxXGNIpt94PysWD6tyDZ3QSc+FjXWbwYITToNyrc9a7Sk0CRPVZAz+CqGMTW7 Q5a6/scdM8/0RC/6AS0K6/qBcs5HNWU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1724966833; x=1756502833; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Or6JtsX4DElqSgWxB+UTsMM5LcYpKMfhZpaMRcyI7+E=; b=fWa4YkxVEZ5LO9VWAyNU+hRlkGccR1YzCxAINtx7BMOW3MsroXmDi9oE JdPoMuF6T4ItBko29KKJpgVGB+yZQhpcVQDrbVUwxWE3j1uKCwGjcgmLj Guwp6L/cg7vdC1aKFXr5Al5j0ifMlExRlxlpPh8hGnjqMB3DuZcAhIBJY btPen9q2/ehbKDFm7nvHla3dNIiMeDGgkU1oPz/me0mF138y7sr1oNhKi K83I30pYdTs1+/xo46Y4YjpjU4wanZ9IKcBJ/BuhC1WJimCBur6yWIk+l rmPA9cFMZtwod1kknODX5UFaL1mOK/c/QibtghlUDJlD06I9TqmkTyWtB g==; X-CSE-ConnectionGUID: wFt9VzEKS4+PbDb50xEhBA== X-CSE-MsgGUID: o15IqTITTDOtqKNR8ap+8A== X-IronPort-AV: E=McAfee;i="6700,10204,11179"; a="23455211" X-IronPort-AV: E=Sophos;i="6.10,186,1719903600"; d="scan'208";a="23455211" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Aug 2024 14:27:07 -0700 X-CSE-ConnectionGUID: fjEjsifpSK+141+sdK48gQ== X-CSE-MsgGUID: RCg+/KznR7G9xMttevfeqg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,186,1719903600"; d="scan'208";a="68365422" Received: from jf5300-b11a338t.jf.intel.com ([10.242.51.6]) by fmviesa004.fm.intel.com with ESMTP; 29 Aug 2024 14:27:08 -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, 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 v6 3/3] mm: swap: Count successful mTHP ZSWAP stores in sysfs mTHP zswpout stats. Date: Thu, 29 Aug 2024 14:27:05 -0700 Message-Id: <20240829212705.6714-4-kanchana.p.sridhar@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240829212705.6714-1-kanchana.p.sridhar@intel.com> References: <20240829212705.6714-1-kanchana.p.sridhar@intel.com> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 55DC7100002 X-Stat-Signature: rpr37k7iqjbjzze6kt9rc97bd8ukjzen X-Rspam-User: X-HE-Tag: 1724966833-857055 X-HE-Meta: U2FsdGVkX18oMq1m7e5fJRVw2uYn5lPYv7fY1P9n5vLxFDxk+3+Vqk2Y2l+4Iw/DmwL7/0iuZf4sjO2Up+Ez+PQLgRsn7157B7DROsPBKpQOhyhs0cdU6je1zGmhCLkjGFE6b8AOUZSLdpWwjl1+bnQBmaiwWx4pUemQ0w8v9oLo5Tp7GRDinsB037WDJt0NQeZwh6XwpbKAnAAyd0emEL7+tIUefMr3QTqPgQCla1qjSDEJkuAwMX4u4UMA0Kg55H5ZqtCUYEs8IKR6Iqxqn7Wzc7LTxqjk82mwRLzDXk8DRB6WKJClSFugNuNyJLA6oC6w60pHxmSScBSO1OY1eGB0YqXPdYL7SbOMzcs6XnOPSsNbOShY6hf5rSARU1pvec5O4paXUpPhT/mgna1yVQEtpi9MmnTiL+Qk1KOKthqKP0ivcbjj3gDIk6HjCzrrVbsQ99BnQjB9F3SuUUmVvftpjPmd0QF6f168MYtFjE3FDP+SDZQlOK+vT9uLTsagAnl8qfNtble0L2Dq/JmzGYwdTHdo6hqfC/OJRtJcssE7CICzCf5Bxtcj2g5zY7exVHdfMEEAilHnEJIeyyJzunOS70PvPbmQT2yYW8BddiaTWYk8nDGG7Hh5QlRk04B7V4892hOUbMQcSRBbd7AIJqW3L3oI0lP6kHG/FMCqHBctcx8WPGBsXijc1JaJnXuOiEN6DsNJPnzgsGAaxLjFq83NM/xUdNV5rzAdylGJafW10gHnpjM4lqDyme7r38XC2qQIVBxDUTg2EEcwBt3WPHkOo8UO+yay+EtSD+uDbrE+393Ou8U2I71T5pzCDXL8ow8zPvcuFJYPF7jsQyhIN8RJ5nO2mg2QxoLyoKd3Qko7mvjIcgDU30HhhNw6j6xTyT4nSAe1J+4Kee4kfapvZcwyuRElHJfLJA7r2ezppKl4UAo97QUy1wxM30au1EuCKh2FAorX/U9qcklQYan wOoLKHkB tT1ii8Am8XbNalGULRTo3xcF1wlgw7/Ex0TuVtzt8m/lhRLW1vqFrQwpvhe0ODgriVhWTB9R8cf5yJ3onRZFJJHLcQFlvimnNl0R/BWIAbxNmPTC6AB62qrhEgITDcGfbeKfHjmE7QS/7FodvD5n/KxXeMH5DpJED7kuV8NUa02Oak1qJjj58VEz1pA== 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 Based on changes made in commit 61e751c01466ffef5dc72cb64349454a691c6bfe ("mm: cleanup count_mthp_stat() definition"), this patch also moves the call to count_mthp_stat() in count_swpout_vm_event() to be outside the "ifdef CONFIG_TRANSPARENT_HUGEPAGE". Signed-off-by: Kanchana P Sridhar --- include/linux/huge_mm.h | 1 + mm/huge_memory.c | 3 +++ mm/page_io.c | 3 ++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index 4da102b74a8c..8b690328e78b 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 15418ffdd377..ad921c4b2ad8 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -587,6 +587,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 @@ -605,6 +606,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 @@ -637,6 +639,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 b6f1519d63b0..26106e745d73 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -289,6 +289,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; } @@ -308,8 +309,8 @@ static inline void count_swpout_vm_event(struct folio *folio) count_memcg_folio_events(folio, THP_SWPOUT, 1); count_vm_event(THP_SWPOUT); } - count_mthp_stat(folio_order(folio), MTHP_STAT_SWPOUT); #endif + count_mthp_stat(folio_order(folio), MTHP_STAT_SWPOUT); count_vm_events(PSWPOUT, folio_nr_pages(folio)); }