From patchwork Wed Aug 28 09:35: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: 13780971 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 C4D98C54799 for ; Wed, 28 Aug 2024 09:35:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3DA766B0098; Wed, 28 Aug 2024 05:35:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3385F6B009B; Wed, 28 Aug 2024 05:35:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 13F7B6B009C; Wed, 28 Aug 2024 05:35:27 -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 D8BB16B0098 for ; Wed, 28 Aug 2024 05:35:27 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 7FA2112044F for ; Wed, 28 Aug 2024 09:35:26 +0000 (UTC) X-FDA: 82501146252.14.AD781A5 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) by imf22.hostedemail.com (Postfix) with ESMTP id 556D0C0007 for ; Wed, 28 Aug 2024 09:35:23 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=f9dcPQ4L; spf=pass (imf22.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.10 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=1724837637; 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=nqdSQww6uEu4a2u/7hSPuFcCXnOozboCRBNq3UNoJ3k=; b=cvtWpHPKdlpcHT8LJk77G6yarboItediPbtPb4AejcspmXVMk7TqNinI9+n1wVaD1el4uC bVuVUSX3aPlZhDJpumC9OiiA7EwPvR81W8R9QBEgxsyovUbRsYJinCADepgEJzhgtinz0X 4LVIzfHBo50trTw3dAF+eKDATTl0PWA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724837637; a=rsa-sha256; cv=none; b=fvb5hmdFuYGMrm4V9D5A9XN5Tyi/NMnTe2x2EljXid/PzqIOxoFr7yn4wC3u3MUuUudko8 Q3sLP+LV6wPAne486G7+MtwhdfWcYcKw010LJWO/S6KyKFNJ8gUFCqf+xufVMhTZwdCNoG QR23TPF5klqTsxP89GXaTgMqpMauH74= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=f9dcPQ4L; spf=pass (imf22.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 192.198.163.10 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=1724837724; x=1756373724; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=z3IdVzEmkKayZcVA4c5Lx8bWa1kn1UvcXwMHQ9hiN50=; b=f9dcPQ4LnXbkXyPO3CeSn3dtBSc6flUacGydfCtBfFxTsr6O/uxLFTuh 7i7zRpa516Gv/T8NMIO6dOTiLTeoW97Pd3OTwY2rfprxWevrcInyOBKda b9d/+BHEFEKP7W7SIMXoQzSpPVJDShn8AHoV7kMe/2vuQHlPSWtcio8j8 GP6mlpjN4n57sdSDA679KVTo9UwqOr7IQ1ULGaHy8Trj4XSHLeX3HZf7X 5U/wrqwsy/hxmPbjLSBGtumjNzo8I722mwpXoKdOLpWFwbcMlY8UnCtVm kU2Y8UMO5qtbqix8Ftk+8ibxRBR6/22fGj9ySLR9fuItJEE6aVh437cZQ A==; X-CSE-ConnectionGUID: QI3lfYpuT5yeC+AMJTfA3A== X-CSE-MsgGUID: YeFXY9LyQVKr/3P3GLpwnA== X-IronPort-AV: E=McAfee;i="6700,10204,11177"; a="34763880" X-IronPort-AV: E=Sophos;i="6.10,182,1719903600"; d="scan'208";a="34763880" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Aug 2024 02:35:17 -0700 X-CSE-ConnectionGUID: PdKxBT0kTjeKQaE0G6sGVw== X-CSE-MsgGUID: qK/TMayGQfCohrla7Z6y4g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,182,1719903600"; d="scan'208";a="100678978" Received: from jf5300-b11a338t.jf.intel.com ([10.242.51.6]) by orviesa001.jf.intel.com with ESMTP; 28 Aug 2024 02:35:16 -0700 From: Kanchana P Sridhar To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, hannes@cmpxchg.org, yosryahmed@google.com, nphamcs@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 v5 3/3] mm: swap: Count successful mTHP ZSWAP stores in sysfs mTHP zswpout stats. Date: Wed, 28 Aug 2024 02:35:16 -0700 Message-Id: <20240828093516.30228-4-kanchana.p.sridhar@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240828093516.30228-1-kanchana.p.sridhar@intel.com> References: <20240828093516.30228-1-kanchana.p.sridhar@intel.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 556D0C0007 X-Stat-Signature: tr4kzw8iqw94imh8mcafc438qcb17g4z X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1724837723-51154 X-HE-Meta: U2FsdGVkX19E8QqwGx5EMGViO8lELOP23gelHA0GG6Ymsro8jifB5c+Xh6Xv+8UKA8V+YVodBgxdljRHXhBwOfWGOu+qqj2nhQXe4pfzTWIS62QQVsgc7yzeWx+bMiS6wLHHgpADB+t2j562mzdXs3BPhNZj3/0IyIwNFwnsvnfenkSvWQKiXsuZUbFwi8LAw72m3khW0fcybjtLxaHzByt8uCYxTBI2RgGxohjx9UELpHswV7qKwtPb7TOpBPnVpirr6SAP9e9Q5RURHzxHS0hdMh12OoFBXH477HKCtxsq9UJ9ycbTE+/cEok0Xf3EhTD0ECjbM6DBnI5hxA0a4yluUK+1tv2kUoj7g3ggdJeTTSwb/OvjN+X5cQggL772yS6ZEhrSU6YOAkyLVZDXYH3d35tMHMze8lvhWye0Bj7ZojyULRXgV5wpNIX+1XbeG+frE+V2DLLrw1AFiHX+ybBuy6MzskkI2oKtAhfKEJN6nxZk1jg57a3OJbGi+8R2m1GTxw4j+bT1NJLkORMs/sSaGd31QNjkTvMO1dT3pNdnkgR7gsL1I9Kfs/AeKMdFjSn4uEKZ/yWb0iOWoqoa7kVKDLqtpzMk3oUiAa8GAAH/jLSp3kqDw1NS9+kqcSDIEEKmZix+PCLqCrfq+C/4qZFxHX/hasm7QyoyDwR4y3AF5gV8kxDZ2A5z14Am3/KvD/7NRzok1M0FdZ0oboS5sEIA+QefYE2RKi8qyQCHmlNavope+jMbSapoBxVgGTgTS87mKJj3ruotHv5K8pYaid/C+hmRIHDcUgC7k5eEclmxHbbxY4KGnKfP97Vg4v5x8ehYlayVTl7WAwH6e7meOj3EQW2OzkZRj9v2JBbLSAv1VmpkNAWgg8QiAqoua7JrE6dcCYrOFdod9rsbseu/CiHSSsXqi1vp7B+O1VxfIV7grz3fDAoYznMdnLrM55Zy1h1AjUkma+RJ18kORWx qqTLi7km imaA4tYWLNrfsAq/N24bNyU3VjzKVvKVmTEpva3VYPlz+HMM//qgEb0tlpVxfwzVMguWwF5EKNd8wZ9a5OjFII0jgaXAeEOSBPwJHlntZWeUh6EhYBuAPSif7pfC8BX9LhcCvNJ8aaAGCPo7mgRwW4EUZwHbjSPU3Ui+DaC0USWq5X9RaceR+gcbWug== 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 4902e2f7e896..8b8045d4a351 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 a81eab98d6b8..45b26c8b3d8a 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)); }