From patchwork Tue Mar 26 03:01:03 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: 13603306 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 931ADC54E64 for ; Tue, 26 Mar 2024 03:01:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D78A76B0089; Mon, 25 Mar 2024 23:01:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D280D6B008A; Mon, 25 Mar 2024 23:01:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BEEDD6B0092; Mon, 25 Mar 2024 23:01:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id AF3626B0089 for ; Mon, 25 Mar 2024 23:01:28 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 7D12D4022E for ; Tue, 26 Mar 2024 03:01:28 +0000 (UTC) X-FDA: 81937689456.22.A388156 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by imf27.hostedemail.com (Postfix) with ESMTP id B55B64001A for ; Tue, 26 Mar 2024 03:01:25 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Ezb5TW0l; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf27.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.210.180 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=1711422085; 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=m5m/cowzEqviM7sBlPkL+Ry7OEYMGLe8OoJYuuWeQt4=; b=io/y73ivxS+tOmabxs802k4r9Jw9UtjL2DwqKlTIuy91TaCxJf84aAFoyj2OnoGFlONsvI rCxn9DSNfllVWD1iVLDIRGp+Duobom6UzTCrpzbOEM0vIv27SaffwlQyRAD7ZRUu8UPyIK EM3lU4Dpc24G/L1Lo6eMg1J5oqNFwSQ= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Ezb5TW0l; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf27.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.210.180 as permitted sender) smtp.mailfrom=21cnbao@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711422085; a=rsa-sha256; cv=none; b=QO/Otl5/fS6gqSkV23d7oODm5PVgZAziYDc/Hn0zD3Cmo8GgCJuhRCpzE6/UjEH4d02I8q FaMgwMpLQ5U8o3Pn5PHyKyOgrLeB0V39mWAL4bUscx/nA3j7VEXzodg5jO0vGrzu51m5UO /4boKXh008r4pS9ZfFDqdfjq0Z+6N4Y= Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-6e46dcd8feaso1995073b3a.2 for ; Mon, 25 Mar 2024 20:01:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711422084; x=1712026884; 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=m5m/cowzEqviM7sBlPkL+Ry7OEYMGLe8OoJYuuWeQt4=; b=Ezb5TW0lN7ilKCOsyU/DuxkG399HmGdsCugdO4iyEItWO3o3txLYsL8cn4WCtVq8YX wU2/oBVV02JvZcVbzQ4HkBc3AaaJ6SF2D/SkQPra7/hmB/1t+djL5t81c+izUjrJlPdy DqBgHyfyhHVon/JurHQbPcrEAlitfO4FZGvieUbyJV9RjaPMSDwNMYL7n+78BcyRxXSJ w2ASbu1pTK3EIhN1Caj/hRb2N+e/8ZOlcrQG3Q0MLTaxtJGRiKZxsX5dzX3zJAlWlZPK rjeM8CrqR34skerhBzER1kxKu6RF0bPx6sksXhTmr4XqbD15dfAUYidvnzQkjywQ+azK SK4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711422084; x=1712026884; 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=m5m/cowzEqviM7sBlPkL+Ry7OEYMGLe8OoJYuuWeQt4=; b=V3nMc6TpQRR+WdS6a3XZPF4AftbsW+JXnVhCln9e4kRfWofcI74bkgfHO21vW3FcDU rpRXt+iJsiyL23diYqQzT3oQQyTEKg4eF3UjqQdbjnywXWrVfkAHa8B4l4qhiqVADOqn cKr4hjEAUUGyYjgQCEDd4DCBUmZr8bhSCPLPRsEW4xa/hWFKmZBfgVhHRGNaa3yS4I/N nVdh8yGyWsWSjc6Phyc9Y1yHwHuDZleAJoulERMRHy8In/uX3fex6V5QPbd8o1c513zB VwZlkWcFH5BQVMCPsuOHEvbT4lI3J6MCeUS50n0FUZJSP2jzrJwwGtRkyH2Wx1uX6g8N XiRA== X-Forwarded-Encrypted: i=1; AJvYcCXZoj2ekeZA1bbaRI5P6lAs6kd2TJZcwhEbeolL3fRWmQbBPWtovUNMIaJE6pyjhxBtnotRzj2Mr29B5onZGeJdtjo= X-Gm-Message-State: AOJu0YysG51DiDSpHuj7wIG66Gl+YLB8Y69HzjmCkJVMKMjOyeC4juOk NLuuZ8GPv6HEa1ULzr1CzYCKDsWhK4gNC6nNvf+X3/uhrbMmNiP0 X-Google-Smtp-Source: AGHT+IHVCWeOe/bbYmgHOh0sZm4/O/vsXwvGKZehCvvcwE4QWuUWTX8aFTi2mn4QtwZoJtUaC8dv/g== X-Received: by 2002:a05:6a20:8421:b0:1a3:a99a:cd56 with SMTP id c33-20020a056a20842100b001a3a99acd56mr7798569pzd.38.1711422084467; Mon, 25 Mar 2024 20:01:24 -0700 (PDT) Received: from localhost.localdomain ([2407:7000:8942:5500:aaa1:59ff:fe57:eb97]) by smtp.gmail.com with ESMTPSA id d13-20020a170902654d00b001dd99fe365dsm5640667pln.42.2024.03.25.20.01.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 20:01:24 -0700 (PDT) From: Barry Song <21cnbao@gmail.com> To: akpm@linux-foundation.org, linux-mm@kvack.org Cc: ryan.roberts@arm.com, david@redhat.com, kasong@tencent.com, yuzhao@google.com, yosryahmed@google.com, cerasuolodomenico@gmail.com, surenb@google.com, Barry Song Subject: [RFC PATCH] mm: show mthp_fault_alloc and mthp_fault_fallback of multi-size THPs Date: Tue, 26 Mar 2024 16:01:03 +1300 Message-Id: <20240326030103.50678-1-21cnbao@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: B55B64001A X-Stat-Signature: 31hne4zno1cfw3d78no8r8rio7znr9tf X-HE-Tag: 1711422085-314835 X-HE-Meta: U2FsdGVkX19EODRUdUrGZ+8X5ERFvCt129liflG4c9hY/VJYKcchxDunSrv5TitA7FR6U6MlnMgPiQBnnGjwoNsOiz/s9PCv6rU1tthWEgpry2sNUqMIX1vOVfxTF5XAYPEE09PHedj7dojJesKUDFpDOf+n35gG0MtZFn7SOcy/VUNsV5A+iAkiKMu89p2q7Kr8GvZDu99cHrAwbAaL1O++bTg+zVGdHvOrGgx9XKjMomqYQ8S6gVPwJy7YlqK+/eGAbxrUdmv2VkzjxbZ+jsh1H5yZFQHTjdew7idCIz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wECZZ0qK4995vc+rmPFbXtIM2TdwJDn5njbb470bCCLJdLerP8KgPehk6iqbj/UPJQnr7BtrinwZQzugXeesdSIGI6GGMO5nsU787h/v48FroYOLwHzKakxEOYNhDuumXlBH3ieTHCBAzt0cgwCfQ40vlxyXcXttfoskaDoD0L3T+e1rsqJsG2X1xFHT0w3 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000005, 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 Profiling a system blindly with mTHP has become challenging due to the lack of visibility into its operations. While displaying additional statistics such as partial map/unmap actions may spark debate, presenting the success rate of mTHP allocations appears to be a straightforward and pressing need. Recently, I've been experiencing significant difficulty debugging performance improvements and regressions without these figures. It's crucial for us to understand the true effectiveness of mTHP in real-world scenarios, especially in systems with fragmented memory. Signed-off-by: Barry Song --- include/linux/vm_event_item.h | 2 ++ mm/memory.c | 2 ++ mm/vmstat.c | 2 ++ 3 files changed, 6 insertions(+) diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h index 747943bc8cc2..3233b39bdb38 100644 --- a/include/linux/vm_event_item.h +++ b/include/linux/vm_event_item.h @@ -95,6 +95,8 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, THP_FAULT_ALLOC, THP_FAULT_FALLBACK, THP_FAULT_FALLBACK_CHARGE, + MTHP_FAULT_ALLOC, + MTHP_FAULT_FALLBACK, THP_COLLAPSE_ALLOC, THP_COLLAPSE_ALLOC_FAILED, THP_FILE_ALLOC, diff --git a/mm/memory.c b/mm/memory.c index 62ee4a15092a..803f00a07d54 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4364,12 +4364,14 @@ static struct folio *alloc_anon_folio(struct vm_fault *vmf) } folio_throttle_swaprate(folio, gfp); clear_huge_page(&folio->page, vmf->address, 1 << order); + count_vm_event(MTHP_FAULT_ALLOC); return folio; } next: order = next_order(&orders, order); } + count_vm_event(MTHP_FAULT_FALLBACK); fallback: #endif return folio_prealloc(vma->vm_mm, vma, vmf->address, true); diff --git a/mm/vmstat.c b/mm/vmstat.c index db79935e4a54..0cc86c73ecdc 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1353,6 +1353,8 @@ const char * const vmstat_text[] = { "thp_fault_alloc", "thp_fault_fallback", "thp_fault_fallback_charge", + "mthp_fault_alloc", + "mthp_fault_fallback", "thp_collapse_alloc", "thp_collapse_alloc_failed", "thp_file_alloc",