From patchwork Wed Aug 14 06:28:30 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: 13762879 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 F3012C52D7F for ; Wed, 14 Aug 2024 06:28:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 739DE6B008A; Wed, 14 Aug 2024 02:28:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6EAD96B0092; Wed, 14 Aug 2024 02:28:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 566F96B0093; Wed, 14 Aug 2024 02:28:43 -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 2D81B6B008A for ; Wed, 14 Aug 2024 02:28:43 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id A9FB7A5DE2 for ; Wed, 14 Aug 2024 06:28:42 +0000 (UTC) X-FDA: 82449872484.15.60D5D3B Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by imf03.hostedemail.com (Postfix) with ESMTP id 7E8CD20003 for ; Wed, 14 Aug 2024 06:28:40 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b="ciWu3/20"; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf03.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 198.175.65.9 as permitted sender) smtp.mailfrom=kanchana.p.sridhar@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723616867; a=rsa-sha256; cv=none; b=fQ8F7q3AlfI0IXMG5FAegb2xglWI9kI2wDv1CZV9FP+srsup3IU6wiTl8O/mvQdKtwaLDS w2UPAqpPXrEoWsbmL3joh8Ofkm8snRY6LmgJx3O+YKCwePXYYF7/OeTDnzJyx5my4Cd8O6 /aeBYlbvSTfe7m90Eyopfs35CtIbLPU= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b="ciWu3/20"; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf03.hostedemail.com: domain of kanchana.p.sridhar@intel.com designates 198.175.65.9 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=1723616867; 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=NnIOYOJcae/XJVFDtoPVRP3OqiwFgt+Z74TkZx2hdWg=; b=aLN65OEQOBFI62ztxV82mC7QCZnK0NHtQnwbRoIEA9uCmROe0xODIWVOPaPhmMXRT+fjTh iu6uz8WowrR8s5SchBx+wmU6/CWqBH+w38nsQ1iceYYaWc+Ch2ORW/nZMDerIshn8hxr5O /AmMk7J8eukqmxP5qZzOvu/1uA5Ydzk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1723616921; x=1755152921; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=K2v1VkFvaq+3TScgsmYP670KxeFAd1V81S4yNBh/NTc=; b=ciWu3/20KyLGylHzrBXL9f4dWSjQSWSmwWBdl2izeATlTlK2IK8hvVbU +AnIHIxkDAWYo/COo08UIU+0imFfT8hHQrT6MDPPLk+dNxF+TfkvP7BBX joMQjtIkSVN6RLL5ZuitvJefKVvBl9ZWRXDr3w0NEmvXu+fttMF43n19K iqHBFPi8x/udfvKVFttwFVCVVuaCQqFAHLLbC4p5wcsVvOlzINDmfI5PH B5P72XS/SsVb0gUDhq/A8XCtaphydvaPVjy4QrW7sDLal34zF/x6QVueI sfh/2F+Vmz+gPmrHVgSvEA4yAJ0gYv8AFQ+16t7ctLDd/EfEeOf3ulUaU A==; X-CSE-ConnectionGUID: Q0lqJYM4T3qKgR4K0yTYqg== X-CSE-MsgGUID: vlyZd5LCQfSGzUCHrqINBg== X-IronPort-AV: E=McAfee;i="6700,10204,11163"; a="44333024" X-IronPort-AV: E=Sophos;i="6.09,288,1716274800"; d="scan'208";a="44333024" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Aug 2024 23:28:33 -0700 X-CSE-ConnectionGUID: 2zyx+9DPTjmnHtf37Gg14Q== X-CSE-MsgGUID: Jy9a/cZJQdGV9YY2ZGhG0w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,288,1716274800"; d="scan'208";a="63568762" Received: from jf5300-b11a338t.jf.intel.com ([10.242.51.6]) by fmviesa004.fm.intel.com with ESMTP; 13 Aug 2024 23:28:33 -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: [RFC PATCH v1 4/4] mm: page_io: Count successful mTHP zswap stores in vmstat. Date: Tue, 13 Aug 2024 23:28:30 -0700 Message-Id: <20240814062830.26833-5-kanchana.p.sridhar@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240814062830.26833-1-kanchana.p.sridhar@intel.com> References: <20240814062830.26833-1-kanchana.p.sridhar@intel.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 7E8CD20003 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: xu4akkoy3c4jwerugcukzrom5nzjshxn X-HE-Tag: 1723616920-356366 X-HE-Meta: U2FsdGVkX18t0GyYeVOR727E1TofmCoxaqvz7U1rQ75tvclIwQYzxGalqGFo4WnHG60N/N2MBb9pJ2k6vXJ8TW8NUN2ELDdq6603i/nYfJSgKGsP22x+zH+6yLQc6A+pLVw4MSoXYgFjCj695bDyIicFd6MLJrs51H9eyJ+4XLYfYxZi2Zk6jhFGDniYydpZtcCKZX7CpD13dadz94CRnRH3YtmIPK2ja7WOvdEZqYNPOaEhLu16wLicAqT+0k2ijXoFEH1LxDNtWz/QdqDt4u+PMnlgewmqxrFE/tJJICKfiLVSVZbob7xHKKAVplmcAH/EHxaVGWMRqxxfe1WU9XMSPqMd6Rljja4yCYaQb61zFNKUm7Q9YvqMOs9wZPebcsiOLHfk24zPybbENem0Wy/K5VxV/4e2Eweo1chEmNlihKXRSFpjz8Xg7ItqPo+n0hr4Rffl7Kib9gIROHjSCgUuju1SfCOLhb3q0sEnfziTu3Vxgrgpgl9GuKIWiAt9t/+zOfTLbqpw6O2wp4cnSYfbusctQw26vCdZqggtX/HjafgCmVZ3ypHG5c8W6YNrHUqj/kWZXAxInSiX4GbYtC2d9vafsT9cJ/d9AjZtFuh8o6n7tymW0PCmd091cFiauPgLoVlB1xMyAtDJEd9jte5xw6PXrKSJrV5ITd7gTehYxl/p3pgUCEHhonlN2OMbMl4Ncc3wS4VEO3ggVxwVeE3GcBxCkDD5n4BiUGktR1NCDj6faTaeQtxj+Rxxj2GGgAZxrcZUEB4PKclLnkGNRwzzxUde478N10OqnRVfD6oh8GuH/0hYsS7+FoR/csV4p7YBfOASid4t1v+PVQSgYdEpAusTUONl07KhWCuSb8a1o0lEuLqghVmUKiQ4FBoLkw/K3HwHntEeMJKFA/O3TS3JjS/4CShvBEUbEPIqWF/NQKPLfc4oNfK2NifjnAFiv47oLz3JBqqXU08J8WH kv1dBjyQ GiANNe+I4l/YOli106NVaMokjzb8jsHgzWby5UpP7YL43raWjgbWdmowc5u8uhjIJVb9tnvU9P0YjTViBCicVJg9PLZ3jHvK1V9xf00U4mpIEfYkLdQB2mVX+oLW9R8INq2MxcirMvzCmmy2ndB+KyJCXDi4rMJtgXfEIY0nbM/7nvDJFQ8Bl3QaK6RL+4Nrfe9CqvkqcZf5j8oE= 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 count_zswap_thp_swpout_vm_event() that will increment the appropriate mTHP/PMD vmstat event counters if zswap_store succeeds for a large folio: zswap_store mTHP order [0, HPAGE_PMD_ORDER-1] will increment these vmstat event counters: ZSWPOUT_4KB_FOLIO mTHP_ZSWPOUT_8kB mTHP_ZSWPOUT_16kB mTHP_ZSWPOUT_32kB mTHP_ZSWPOUT_64kB mTHP_ZSWPOUT_128kB mTHP_ZSWPOUT_256kB mTHP_ZSWPOUT_512kB mTHP_ZSWPOUT_1024kB zswap_store of a PMD-size THP, i.e., mTHP order HPAGE_PMD_ORDER, will increment both these vmstat event counters: ZSWPOUT_PMD_THP_FOLIO mTHP_ZSWPOUT_2048kB Signed-off-by: Kanchana P Sridhar --- mm/page_io.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/mm/page_io.c b/mm/page_io.c index 0a150c240bf4..ab54d2060cc4 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -172,6 +172,49 @@ int generic_swapfile_activate(struct swap_info_struct *sis, goto out; } +/* + * Count vmstats for ZSWAP store of large folios (mTHP and PMD-size THP). + */ +static inline void count_zswap_thp_swpout_vm_event(struct folio *folio) +{ + if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && folio_test_pmd_mappable(folio)) { + count_vm_event(ZSWPOUT_PMD_THP_FOLIO); + count_vm_event(mTHP_ZSWPOUT_2048kB); + } else if (folio_order(folio) == 0) { + count_vm_event(ZSWPOUT_4KB_FOLIO); + } else if (IS_ENABLED(CONFIG_THP_SWAP)) { + switch (folio_order(folio)) { + case 1: + count_vm_event(mTHP_ZSWPOUT_8kB); + break; + case 2: + count_vm_event(mTHP_ZSWPOUT_16kB); + break; + case 3: + count_vm_event(mTHP_ZSWPOUT_32kB); + break; + case 4: + count_vm_event(mTHP_ZSWPOUT_64kB); + break; + case 5: + count_vm_event(mTHP_ZSWPOUT_128kB); + break; + case 6: + count_vm_event(mTHP_ZSWPOUT_256kB); + break; + case 7: + count_vm_event(mTHP_ZSWPOUT_512kB); + break; + case 8: + count_vm_event(mTHP_ZSWPOUT_1024kB); + break; + case 9: + count_vm_event(mTHP_ZSWPOUT_2048kB); + break; + } + } +} + /* * We may have stale swap cache pages in memory: notice * them here and get rid of the unnecessary final write. @@ -196,6 +239,7 @@ int swap_writepage(struct page *page, struct writeback_control *wbc) return ret; } if (zswap_store(folio)) { + count_zswap_thp_swpout_vm_event(folio); folio_start_writeback(folio); folio_unlock(folio); folio_end_writeback(folio);