From patchwork Fri Apr 12 07:37:38 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: 13627054 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 D93A7C4345F for ; Fri, 12 Apr 2024 07:38:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4E9B06B008A; Fri, 12 Apr 2024 03:38:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4734E6B008C; Fri, 12 Apr 2024 03:38:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 313FC6B0092; Fri, 12 Apr 2024 03:38:13 -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 0F7456B008A for ; Fri, 12 Apr 2024 03:38:13 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id B5BAD40DA9 for ; Fri, 12 Apr 2024 07:38:12 +0000 (UTC) X-FDA: 82000076424.16.0F5D372 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by imf26.hostedemail.com (Postfix) with ESMTP id E5DD414000F for ; Fri, 12 Apr 2024 07:38:10 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=BOEpGMX0; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf26.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.214.178 as permitted sender) smtp.mailfrom=21cnbao@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712907491; a=rsa-sha256; cv=none; b=fp9oyMc0kuD9/h/kqCJkjGVlpskNeMs1aE6cmzbZ1to5Qw/K/mVuyU5qrbUQlUO5H/S+Su vtwhI7kZpHdg7KP8ZbORvEe134TY0VhbnE7q96p/axYgHXidynwO7blwulxCAiaHiX9sfD ymx/558KnEZJbx8nV/hz55cQQoo5tlI= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=BOEpGMX0; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf26.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.214.178 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=1712907491; 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=hsOHXEK8Nh5pewumsjjrvdM3HKJLRrjO6yqH5K5tp/s=; b=BjwKwjEES3tPMzyG1L2/JK3KA9iAUNshavXWwhpqVIR1DzsmB1hiWwmqRF3Q4kP9Put6PQ oXfNtcWEGvX7lKCDfymChXjS4/b4znmG6oKI7hGohICrfWCYfrB55HN92IzjCDIedGH7XE ypliF9sgPFDRNr/PUYLa/+AaKe1CZCg= Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1e40042c13eso4839885ad.2 for ; Fri, 12 Apr 2024 00:38:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712907490; x=1713512290; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hsOHXEK8Nh5pewumsjjrvdM3HKJLRrjO6yqH5K5tp/s=; b=BOEpGMX0TlJhnbYI2dOKSSrYRKqsLhMFjcgH+HpLDDk7uQPBm3VDPHyM/4Wd05t5fZ S5OVAtTcM3Qj53VfpPz8JTr0hkonMCotreIGzpJ8gQiU49y/CJoH17dtRbcqD6cSSZsP cu6Aga96yfwS78lu6zIJ9df9v1n+ljYE3fmtn3lTZ0HfkzGCBfeNjcCXw7C3+T+2MqrM 8HQR4OYBMV/+HL1eOljogXpx0sh9HtUHRhcKd3sGJPxtVHaK5r6Y1oiqKWnbVPA8efUO bSNUcQ0fDNvbTAxkGAYrj2YjA8I6CHiIkhWgKgMyNdhGaeWkY6xMhtKHvvBCMVD9+xG7 yF8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712907490; x=1713512290; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hsOHXEK8Nh5pewumsjjrvdM3HKJLRrjO6yqH5K5tp/s=; b=jaWO18BUm8BRUsPqSlfomDwWB5dguk3dJnex5ChphyM1Aus/z7ONqjCkYGJkkDVaVe tTje0dAppBAtJPMiEwKAo/vViabr84sz+SnRWbeftCX31YXMQ82VIOm5c3qHpmGT5gud 71Jfu7uZr1y8hF08BpLNWpEiFxS1iHqdnPAc4LA9hDjPxkkpUDpKJsejak+Ne7HcLDSu eIEQFwmGB0xKXQ5FyfJZ/0ljofeI9ojiQ5XZIgURg5iqcOvWRp1jSL+/GIPbTIcbDGpQ EFbrdhrp/d9wmPRF/esTkE8iPl+CUpPac/HCIFRl4C/P7BHfj3N4IA9ThIiWmNrEJK5D PPpg== X-Forwarded-Encrypted: i=1; AJvYcCVgbrKz8V6zvrrwzgNbT47Hvu6LGhG04rXM4lBRXoZoFUES4FTSMamvf6IMmIb9J+8R9WA96P9PmQNYZR4v8PAZ0tM= X-Gm-Message-State: AOJu0YxiSCCSade4bXY2iMmRe88mcFuivjdgqvGytd2Tp1TjMenG5lXD bk20WBGtUcMJUOxP3t1nkTT66q36jSyMK5NEGW2d1379QFQdS4gcr599o0su X-Google-Smtp-Source: AGHT+IHWZYew+Q9NtnWF+a6SE88ptdUjsAwDnwkkWmi3sA6yX2D3E8zqruIKdheWkebuC2R11yEKEg== X-Received: by 2002:a17:902:9341:b0:1e2:952b:81fc with SMTP id g1-20020a170902934100b001e2952b81fcmr1436795plp.29.1712907489843; Fri, 12 Apr 2024 00:38:09 -0700 (PDT) Received: from localhost.localdomain ([2407:7000:8942:5500:aaa1:59ff:fe57:eb97]) by smtp.gmail.com with ESMTPSA id n5-20020a170903110500b001e478f359bdsm2344011plh.127.2024.04.12.00.38.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 00:38:09 -0700 (PDT) From: Barry Song <21cnbao@gmail.com> To: akpm@linux-foundation.org, linux-mm@kvack.org Cc: cerasuolodomenico@gmail.com, chrisl@kernel.org, david@redhat.com, kasong@tencent.com, linux-kernel@vger.kernel.org, peterx@redhat.com, ryan.roberts@arm.com, surenb@google.com, v-songbaohua@oppo.com, willy@infradead.org, yosryahmed@google.com, yuzhao@google.com, corbet@lwn.net Subject: [PATCH v5 2/4] mm: add per-order mTHP anon_swpout and anon_swpout_fallback counters Date: Fri, 12 Apr 2024 19:37:38 +1200 Message-Id: <20240412073740.294272-3-21cnbao@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412073740.294272-1-21cnbao@gmail.com> References: <20240412073740.294272-1-21cnbao@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: E5DD414000F X-Stat-Signature: 4a153mdd8qwqcbfkubt5qnamg14rbycg X-HE-Tag: 1712907490-841216 X-HE-Meta: U2FsdGVkX1/RNIOuoooyDh0SlmMfoOCVbkLqhyqRKtST38WGKaHFX3Aq/lZArhe/ywMk46OAxUNiflenkX+U5vY0AUnkt2RwhXHRDV/wnMhrtA/zpqRtt4nAvw/eQIK7U4UHJThtyli2p7Bai+n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UYtsLWFTzbHNq0SS4O9OGZHBOoWhJ0uKXd85Hdnd/oKqiKuPGzm8Mh/nicboVvM7ifFRfwL++JSiqsu3/7adnYrhCR5I2qF2OJj62QgD7H3C1FiA2CtjVf+5X602Rp5mKSNM6SOoMoXMxziPumn4CwAUNoyYcX4et+KGVhlpY6Azzxaiz43afIjuHCuE8ShX0vzmnEyJ/5ZYjsb65wjCqd/jw07sk5aX60u7hZmaIiWWK5c3MUuNwpciasi8miH1t2/5ETWs5KwgCNLXPvk31JufJ0iYJznGkMzWztNbyaa4t0/KgDkhqcc5tsGuEN6112bBUL8MT512ZBUOWXMERY52E9DqtZpcaJjuMqwIKNzrwYbH/0ux/AC1ZV/a/4ML34aCvjaAiFiCOXK/xNyrZ0hBSE/A01W/PnFwah8wS1PaA+O+o4/3tBgztbcUxE6LiZqiMh8/KEF8dcqbfMdmsykj7Ze/cvrlA8adf45ydVU+hkLLm+kK2uB8GGSN52iQLmNsl5HaomqIptYRLOpkmIDHFkpi2Qsd1PhnczgG5nSzpcpeg+nNbPS4t8+RUXYAZBFEcwPv95vMNuPgpLvMmGfHcHa82qftqOj6uOT5G/2A== 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 to display the fragmentation situation of the swapfile, knowing the proportion of how much we haven't split large folios. So far, we only support non-split swapout for anon memory, with the possibility of expanding to shmem in the future. So, we add the "anon" prefix to the counter names. Signed-off-by: Barry Song Cc: Chris Li Cc: David Hildenbrand Cc: Domenico Cerasuolo Cc: Kairui Song Cc: Matthew Wilcox (Oracle) Cc: Peter Xu Cc: Ryan Roberts Cc: Suren Baghdasaryan Cc: Yosry Ahmed Cc: Yu Zhao Reviewed-by: Ryan Roberts --- include/linux/huge_mm.h | 2 ++ mm/huge_memory.c | 4 ++++ mm/page_io.c | 1 + mm/vmscan.c | 3 +++ 4 files changed, 10 insertions(+) diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index c5beb54b97cb..b69c3b3e1436 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -268,6 +268,8 @@ enum mthp_stat_item { MTHP_STAT_ANON_FAULT_ALLOC, MTHP_STAT_ANON_FAULT_FALLBACK, MTHP_STAT_ANON_FAULT_FALLBACK_CHARGE, + MTHP_STAT_ANON_SWPOUT, + MTHP_STAT_ANON_SWPOUT_FALLBACK, __MTHP_STAT_COUNT }; diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 21c4ac74b484..13e74724d0c3 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -557,11 +557,15 @@ 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(anon_swpout, MTHP_STAT_ANON_SWPOUT); +DEFINE_MTHP_STAT_ATTR(anon_swpout_fallback, MTHP_STAT_ANON_SWPOUT_FALLBACK); static struct attribute *stats_attrs[] = { &anon_fault_alloc_attr.attr, &anon_fault_fallback_attr.attr, &anon_fault_fallback_charge_attr.attr, + &anon_swpout_attr.attr, + &anon_swpout_fallback_attr.attr, NULL, }; diff --git a/mm/page_io.c b/mm/page_io.c index a9a7c236aecc..46c603dddf04 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -217,6 +217,7 @@ 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_ANON_SWPOUT); #endif count_vm_events(PSWPOUT, folio_nr_pages(folio)); } diff --git a/mm/vmscan.c b/mm/vmscan.c index bca2d9981c95..49bd94423961 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1231,6 +1231,8 @@ static unsigned int shrink_folio_list(struct list_head *folio_list, goto activate_locked; } if (!add_to_swap(folio)) { + int __maybe_unused order = folio_order(folio); + if (!folio_test_large(folio)) goto activate_locked_split; /* Fallback to swap normal pages */ @@ -1242,6 +1244,7 @@ static unsigned int shrink_folio_list(struct list_head *folio_list, THP_SWPOUT_FALLBACK, 1); count_vm_event(THP_SWPOUT_FALLBACK); } + count_mthp_stat(order, MTHP_STAT_ANON_SWPOUT_FALLBACK); #endif if (!add_to_swap(folio)) goto activate_locked_split;