From patchwork Sat Oct 26 08:24:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Barry Song <21cnbao@gmail.com> X-Patchwork-Id: 13852142 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 09244D10BE8 for ; Sat, 26 Oct 2024 08:24:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F226E6B007B; Sat, 26 Oct 2024 04:24:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ED16B6B0082; Sat, 26 Oct 2024 04:24:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D98E36B0083; Sat, 26 Oct 2024 04:24:38 -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 BCD876B007B for ; Sat, 26 Oct 2024 04:24:38 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 70A62120A99 for ; Sat, 26 Oct 2024 08:24:19 +0000 (UTC) X-FDA: 82715066532.15.4E508BC Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by imf12.hostedemail.com (Postfix) with ESMTP id AB72B40009 for ; Sat, 26 Oct 2024 08:24:26 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=RCcJXl4H; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf12.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.216.41 as permitted sender) smtp.mailfrom=21cnbao@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729930961; a=rsa-sha256; cv=none; b=f12YoFoMj4aDSux2zcibGS8Q7bWzlHQszQacNqw0OG6uxSFaY9Xa80HIRuG1UvjSGJRZOF GV0HitEIzhsJckrPyMySOYlDRPlazzqkLeEQC21Edrw1TFesh/yLlWZXz43nAISuFq5Dd0 XW3XqUgEEVsPKKyTly1JYRMebiacZHI= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=RCcJXl4H; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf12.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.216.41 as permitted sender) smtp.mailfrom=21cnbao@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729930961; 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:references:dkim-signature; bh=XorRTbiB9fNi80ZoTkLFTNgIsMBK5QYf5PnFoxW5V/Q=; b=HTW/fdpTC/EiDTUU3CNr2tJv2qFSol1wADkBPwT+PAJLfEKOxeX1NYBsPhNWcQ2Rw7ddwi 6z5KTN5/iLuYkX3nGPILXSExkcCgneJUjEXir+QcPNpjq9DRakFftEaY9qjC6CoyHr53yC MuKD4abtQsmKKaiAfDcvkouTqcbnaKg= Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-2e5a0177531so2120195a91.2 for ; Sat, 26 Oct 2024 01:24:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729931075; x=1730535875; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=XorRTbiB9fNi80ZoTkLFTNgIsMBK5QYf5PnFoxW5V/Q=; b=RCcJXl4H0ZYD0bcLwVqhiW5l2Rp4zOPfR2Uz1dwP0+dl9WRcT+X5ufRsYEtd5q4ocG PJDh+CMDrN+4hjndl0h0wGdd7tdPNUhZ1XxSNOwtKoFRpBQuotct9ye3xX38Ns/KiAQa MvulhMigpaLsG69LUDEVW7xSE3n6nNcqaomOVc4EbjLRUU0zS3hNdFBjOikM80c3EsrX QcfQxhy2hy3arzlMIqJfaP54gpEWVF3FNXq52AyY6W3pZ2K5f6hywEMN5Z++E7bOVlHA yd1J5ooI9jiAzLS+inIWdU7AKESqWR9isi8RqaDW+jX/v7dft4i6YabrexF3fxZAiVlD Chbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729931075; x=1730535875; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=XorRTbiB9fNi80ZoTkLFTNgIsMBK5QYf5PnFoxW5V/Q=; b=ILDjS9pLq2rRoQSOaomYdzAQ+Eu6Rskc6KdBE2UBi6Lrz3SR8ilhvAs+IiIHzMkcmG Nl1cQT/jFtegNibWUKvWf6aVEuQdjpJYucmGMJ9RmwxbW5zwKclWij5NCKjmth9VonUu okEi8+6NuWO8JBqdcZX1wuesL+rncqTQdm6ju/NYRRDMrrJKBlqeYMihQG5PfqywGAJp WUjxDNfDEgDY7Ww7GOsMFeXhFhrqcTr3DpWKGOGWMI9wpUC/Sen/uLtASxzxkSg7KcQL mHH37oOfAfxTeY2OAvfpMwqRccTZlYOdBaKm37WQaqpEBVMJe1GXVoLop2XnbZxbDxkP IQZg== X-Forwarded-Encrypted: i=1; AJvYcCVI+AWsVTia9ZyAf2zIA6zB16m7y7fEzGm0FcGmtjmgVfzPBc00pK00oV9wUUu+srR4iwfw0204/w==@kvack.org X-Gm-Message-State: AOJu0Yx5Ed/pa+X5a622ymd4nZKmhIqPyjqh+a9Kb9e8BUpn5VC/cXtc JvH5nztdpcWzQQbbrGdsQ/lgmDDsI+r5GLM4CckUWju+8dMCJoGY X-Google-Smtp-Source: AGHT+IEtrrz2kV2IPR7EXre6cDCAc9fw38xdnWE2UaWAFoXKMDo6wToszg75o9qq52IB7jtOqkiuEw== X-Received: by 2002:a17:90a:f185:b0:2e1:682b:361a with SMTP id 98e67ed59e1d1-2e8f11bad82mr2499850a91.28.1729931074696; Sat, 26 Oct 2024 01:24:34 -0700 (PDT) Received: from Barrys-MBP.hub ([2407:7000:8942:5500:b036:2443:5187:864]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e8e3555c33sm2932319a91.3.2024.10.26.01.24.29 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 26 Oct 2024 01:24:34 -0700 (PDT) From: Barry Song <21cnbao@gmail.com> To: akpm@linux-foundation.org, linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Barry Song , David Hildenbrand , Baolin Wang , Chris Li , Yosry Ahmed , "Huang, Ying" , Kairui Song , Ryan Roberts , Kanchana P Sridhar , Usama Arif Subject: [PATCH] mm: add per-order mTHP swpin counters Date: Sat, 26 Oct 2024 21:24:23 +1300 Message-Id: <20241026082423.26298-1-21cnbao@gmail.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) MIME-Version: 1.0 X-Rspamd-Queue-Id: AB72B40009 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 4c69h9me79p3crtiusmk89yu5tbubnyh X-HE-Tag: 1729931066-591492 X-HE-Meta: U2FsdGVkX18Vj0YHNyI8VrDc1u0odb7lDM/YxSBuBSh5KqgU/tAM6aEuGCiBZLr+6vZXSgYqep83t6eD8Okd0Tz1AzhmsBAAZ6aXV4A4R3MlzCnEhcsRcnObXn1DNAx27yPvRP0adqHUP4IemhM0ILIdZhZRZGYQbloNzJa2K8oHafEC5GEKe+ZwUzFpWD1UPszcc5OaHnc5q+IjsLW9gW+WBw1eww8QjIb8Ex8qMPdUVrnm0fOF17rDskkvUO4SUqLA1KB1crAXDniplNnvC2f0oD0AXZS2QwhpcWfESXAa0JZ3L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uUMO8R4Y4z5mIHTSWxpn5rERF7Er5jUCPbU6Nlmoz0cexg+FxTpcix+/lbOjYOw7v2/oXFo9wW+Qvlf3qTe+10uoQJizKf3sLTtLZjRIk4UT1hSXJfiOaOhXoLIT2PEd9MoWC1iS5wIPRfs6abL73c4BcsJxFl0c5ASH7mQyAOCqvphhOM4CfylaB9MA3eE/uKtpnSbD5WvYQgDkpw7tHniGqfGS2NZUY1M= 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: From: Barry Song This helps profile the sizes of folios being swapped in. Currently, only mTHP swap-out is being counted. Cc: David Hildenbrand Cc: Baolin Wang Cc: Chris Li Cc: Yosry Ahmed Cc: "Huang, Ying" Cc: Kairui Song Cc: Ryan Roberts Cc: Kanchana P Sridhar Cc: Usama Arif Signed-off-by: Barry Song Reviewed-by: Baolin Wang Acked-by: David Hildenbrand --- Documentation/admin-guide/mm/transhuge.rst | 3 +++ include/linux/huge_mm.h | 1 + mm/huge_memory.c | 3 +++ mm/page_io.c | 3 +++ 4 files changed, 10 insertions(+) diff --git a/Documentation/admin-guide/mm/transhuge.rst b/Documentation/admin-guide/mm/transhuge.rst index 2a171ed5206e..203ba7aaf5fc 100644 --- a/Documentation/admin-guide/mm/transhuge.rst +++ b/Documentation/admin-guide/mm/transhuge.rst @@ -533,6 +533,9 @@ anon_fault_fallback_charge zswpout is incremented every time a huge page is swapped out to zswap in one piece without splitting. +swpin + is incremented every time a huge page is swapped in from a non-zswap + swap device in one piece. swpout is incremented every time a huge page is swapped out to a non-zswap diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index c59e5aa9b081..b94c2e8ee918 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -120,6 +120,7 @@ enum mthp_stat_item { MTHP_STAT_ANON_FAULT_FALLBACK, MTHP_STAT_ANON_FAULT_FALLBACK_CHARGE, MTHP_STAT_ZSWPOUT, + MTHP_STAT_SWPIN, MTHP_STAT_SWPOUT, MTHP_STAT_SWPOUT_FALLBACK, MTHP_STAT_SHMEM_ALLOC, diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 830d6aa5bf97..846c1a43f61c 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -616,6 +616,7 @@ 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(swpin, MTHP_STAT_SWPIN); DEFINE_MTHP_STAT_ATTR(swpout, MTHP_STAT_SWPOUT); DEFINE_MTHP_STAT_ATTR(swpout_fallback, MTHP_STAT_SWPOUT_FALLBACK); #ifdef CONFIG_SHMEM @@ -635,6 +636,7 @@ static struct attribute *anon_stats_attrs[] = { &anon_fault_fallback_charge_attr.attr, #ifndef CONFIG_SHMEM &zswpout_attr.attr, + &swpin_attr.attr, &swpout_attr.attr, &swpout_fallback_attr.attr, #endif @@ -666,6 +668,7 @@ static struct attribute_group file_stats_attr_grp = { static struct attribute *any_stats_attrs[] = { #ifdef CONFIG_SHMEM &zswpout_attr.attr, + &swpin_attr.attr, &swpout_attr.attr, &swpout_fallback_attr.attr, #endif diff --git a/mm/page_io.c b/mm/page_io.c index c69fab5060a1..5d9b6e6cf96c 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -487,6 +487,7 @@ static void sio_read_complete(struct kiocb *iocb, long ret) for (p = 0; p < sio->pages; p++) { struct folio *folio = page_folio(sio->bvec[p].bv_page); + count_mthp_stat(folio_order(folio), MTHP_STAT_SWPIN); count_memcg_folio_events(folio, PSWPIN, folio_nr_pages(folio)); folio_mark_uptodate(folio); folio_unlock(folio); @@ -573,6 +574,7 @@ static void swap_read_folio_bdev_sync(struct folio *folio, * attempt to access it in the page fault retry time check. */ get_task_struct(current); + count_mthp_stat(folio_order(folio), MTHP_STAT_SWPIN); count_memcg_folio_events(folio, PSWPIN, folio_nr_pages(folio)); count_vm_events(PSWPIN, folio_nr_pages(folio)); submit_bio_wait(&bio); @@ -589,6 +591,7 @@ static void swap_read_folio_bdev_async(struct folio *folio, bio->bi_iter.bi_sector = swap_folio_sector(folio); bio->bi_end_io = end_swap_bio_read; bio_add_folio_nofail(bio, folio, folio_size(folio), 0); + count_mthp_stat(folio_order(folio), MTHP_STAT_SWPIN); count_memcg_folio_events(folio, PSWPIN, folio_nr_pages(folio)); count_vm_events(PSWPIN, folio_nr_pages(folio)); submit_bio(bio);