From patchwork Fri Apr 12 07:37:36 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: 13627052 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 8FB63C00A94 for ; Fri, 12 Apr 2024 07:38:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 07D446B007B; Fri, 12 Apr 2024 03:38:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0063D6B0087; Fri, 12 Apr 2024 03:38:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DC19B6B0088; Fri, 12 Apr 2024 03:38:02 -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 BB1F16B0082 for ; Fri, 12 Apr 2024 03:38:02 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 6CD1580DF9 for ; Fri, 12 Apr 2024 07:38:02 +0000 (UTC) X-FDA: 82000076004.07.EBCA250 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by imf06.hostedemail.com (Postfix) with ESMTP id AB0E4180009 for ; Fri, 12 Apr 2024 07:37:59 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=mGyvjV4w; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf06.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.214.181 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=1712907479; 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=i8Uou6ceHlqIama13YYiFU7oji+lihhby0gYb2Jomk0=; b=FCJ7dRBPz0ZoizJsv7dKkfFsGM61c8zoc7Iokgi4b2p2t0lQXQiz+vgmQl5/78bdw/qeni YvmcN8Dew8zWgqUUd3jC5gpyA7uRDxOTQCdoZynLDC2VFU9jS+pnG7H/ebA6x4PsxdyNXl PjXbPeIdLUm2lZDDAVtCBU2LY77JWrE= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=mGyvjV4w; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf06.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.214.181 as permitted sender) smtp.mailfrom=21cnbao@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712907479; a=rsa-sha256; cv=none; b=FQCm+XCkB8+5vfbWq+ZUMxzdbDpv9fXRhPzgQd8CKLtlijUtsNFVIZ9uRscGsvkKb3FHuV APYd/LAIwoDaW+5x3oeDR4giuiq+8P1vEzcZni2iwNx9UTYygHCS6El+etJho08A2i7lhW ht1PKl2oUZ3o+ylT+NqBF9IF7x9NXx4= Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1e504f58230so5667685ad.2 for ; Fri, 12 Apr 2024 00:37:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712907478; x=1713512278; 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=i8Uou6ceHlqIama13YYiFU7oji+lihhby0gYb2Jomk0=; b=mGyvjV4weKQ3YJ88+r3j1M7QCArj2swZp7UJEZ+jfYHhlD/jn4rf67xgAyD2wGG4fm ieEqQyTSN8W8EwOfUgm1k7ovzfI+xSfCSs0iGtBEsOHrdGkoXd/DvrkQbkZxYV0xjL+A wlylj9OaWBSxqoZznoNa2+mas40STHuW6f+HxbxderAR723PgNZdP6oSC7jf6C9s3LRS XScmc3hj1lW971w9az/o3riUccgXL4/0//3pwQLyvbRxhQhxAlfI3xa9VU6Qw/Xm09BR Nzm1+gZSBUa6yhqmItb9aWdGru2wgFuvkMeucXT+iL5Qpa+N/+NswezG34kLEwNdhOy7 m9qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712907478; x=1713512278; 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=i8Uou6ceHlqIama13YYiFU7oji+lihhby0gYb2Jomk0=; b=HMtqu9uHdcZmuXTVyYN9q46/3efQdtui9zUWCpT/i6Gx0lK4p13Wqzyy5oR0rHs1vj 5WLSSrsCJkABqppNOXc6x7eD2QRXRJy2vycbNlBmHswWxO+YQ/d9Dvhd5rmgQ/RkRtrm ITSGdC0FoHFW9GtttIN+k80GtjqQriGKun5Vywy5C2Wu1pq9Nwd0WMqqyLioYNUBw2py mQLEMKR2NtPr+AOgdxcwtymzXs91/OCTyAfCuQI+99DaVJPkWCCOFZieBj0pkgJEB/5D V88QjnW4v5IJRtp37P0AFU2SNFSAg6Vq7yZYaQgBaPUVcPoS+ITDl6qsUIe1Jhp/4eJr agqQ== X-Forwarded-Encrypted: i=1; AJvYcCXQlINIp2OiU4ARGOkpvoT8hFHE5ZG2QuLvWdbfXNEdpk8/Up/TXd2m93euD14wkMDhGrBD4L9MUAnTIPypQefrK8M= X-Gm-Message-State: AOJu0Yx4vyN+/6NOi27FUtqBGNarreD7Sg6DwEYsJLenDtgVPKfqJsUD VPemSzKPxqSWH8V8Inkrg/MrFywrE7KrfFrIHoU4kqvvMQ3UHB+X X-Google-Smtp-Source: AGHT+IFF1RQ+qoT47FkJAuq1ppdbZf8q0nwvGmfKUv2rJD3pj9qmNMR05kZO48tt0XGhqSCJfLm0bQ== X-Received: by 2002:a17:902:cecb:b0:1e4:2451:c2b5 with SMTP id d11-20020a170902cecb00b001e42451c2b5mr1895200plg.13.1712907478445; Fri, 12 Apr 2024 00:37:58 -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.37.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 00:37:58 -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 0/4] mm: add per-order mTHP alloc and swpout counters Date: Fri, 12 Apr 2024 19:37:36 +1200 Message-Id: <20240412073740.294272-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: AB0E4180009 X-Stat-Signature: mdoddbshc3srribt7fasi6s8ptwjeba3 X-HE-Tag: 1712907479-967423 X-HE-Meta: U2FsdGVkX1/ND313AAfbJZGNiBsUhgR+gpSQe8hLUNdveBK6ULa77ffxvBorW/vp0oDf8oy4n7KR/l5u+bHKSo86gT5BXKSNiyiwWbP41pgsxm7VgIzu39oIK4caf+q1YtJ7ys1l0Od70A+rfRptcnvwmwGhUVUjZ5/wDM1KMqhldbXKqTsXCX1pzQUam3KuySdj4FTBj8fHk3oQBZJvwRG9T8etvzBDv4lMK+2k5EiPcVdO8S+93+DSltjDYoW17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6uW0QzNGYH6g6vgFTVi+GQejfDe7pInyI1+X6Lm0yO4/MkuC8104xtdZ3vkLMjWGiB6qIxLgvIvuTFChuWvNAmtqBJGoj5vWq5X94nVkXiln2Ssgd2WDICQxUkdmGqVPLiS/BuwGLoFl7UBG/ez9/a8qeI2ou8k9TvksTGg5dqGaRULDx6z8u66gZvt6UjwzNnVkxiN/vIMG4cYpohOh5DHwzASKSwKCHtXpcalSHss 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 The patchset introduces a framework to facilitate mTHP counters, starting with the allocation and swap-out counters. Currently, only four new nodes are appended to the stats directory for each mTHP size. /sys/kernel/mm/transparent_hugepage/hugepages-/stats anon_fault_alloc anon_fault_fallback anon_fault_fallback_charge anon_swpout anon_swpout_fallback These nodes are crucial for us to monitor the fragmentation levels of both the buddy system and the swap partitions. In the future, we may consider adding additional nodes for further insights. -v5: * rename anon_alloc to anon_fault_alloc, Barry/Ryan; * add anon_fault_fallback_charge, Ryan; * move to dynamic alloc_percpu as powerpc's PMD_ORDER is not const, kernel test robot; * make anon_fault_alloc and anon_fault_fallback more consistent with thp_fault_alloc and thp_fault_fallback, Ryan; * handle cpu hotplug properly, Ryan; * add docs for new sysfs nodes and ABI, Andrew. -v4: * Many thanks to David and Ryan for your patience and valuable insights throughout the numerous renaming efforts! * Guard the case order > PMD_ORDER in count func rather than in callers, Ryan; * Add swpout counters; * Add a helper DEFINE_MTHP_STAT_ATTR to avoid code duplication for various counters; link: https://lore.kernel.org/linux-mm/20240405102704.77559-1-21cnbao@gmail.com/ -v3: https://lore.kernel.org/linux-mm/20240403035502.71356-1-21cnbao@gmail.com/ Barry Song (2): mm: add per-order mTHP anon_alloc and anon_alloc_fallback counters mm: add per-order mTHP anon_swpout and anon_swpout_fallback counters mm: add docs for per-order mTHP counters and transhuge_page ABI mm: correct the docs for thp_fault_alloc and thp_fault_fallback .../sys-kernel-mm-transparent-hugepage | 17 +++++ Documentation/admin-guide/mm/transhuge.rst | 32 ++++++++- include/linux/huge_mm.h | 53 +++++++++++++++ mm/huge_memory.c | 65 +++++++++++++++++++ mm/memory.c | 3 + mm/page_alloc.c | 4 ++ mm/page_io.c | 1 + mm/vmscan.c | 3 + 8 files changed, 176 insertions(+), 2 deletions(-) create mode 100644 Documentation/ABI/testing/sys-kernel-mm-transparent-hugepage