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; }