From patchwork Fri Apr 12 11:48:54 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: 13627656 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 39810C4345F for ; Fri, 12 Apr 2024 11:49:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7B2106B0087; Fri, 12 Apr 2024 07:49:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 739F96B0088; Fri, 12 Apr 2024 07:49:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5B37E6B0089; Fri, 12 Apr 2024 07:49:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 3C4556B0087 for ; Fri, 12 Apr 2024 07:49:15 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id C3FFE1C136F for ; Fri, 12 Apr 2024 11:49:14 +0000 (UTC) X-FDA: 82000709028.10.94D9C90 Received: from mail-oo1-f45.google.com (mail-oo1-f45.google.com [209.85.161.45]) by imf01.hostedemail.com (Postfix) with ESMTP id 0F76C40002 for ; Fri, 12 Apr 2024 11:49:12 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=DFYgXMf0; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf01.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.161.45 as permitted sender) smtp.mailfrom=21cnbao@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712922553; a=rsa-sha256; cv=none; b=s5eq7CqmBSJhX+FN0UXUSoEZIczm1F2wjshvys32/H/c4N6O0kfHoWID0sCEYR0mZltFLV mxMzPDMn+FALxA0R03dzLHltZ0r88RLPvShHrDyuDHEBW2B689PLzjCv/Uq79PE6I7Wtn0 T0Dw/NrTXZXDfPAfy0XhGFo+LVdL/fE= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=DFYgXMf0; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf01.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.161.45 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=1712922553; 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=tz5rhJc+yuuVb5lYrBOCyx724Exwzgl0iVGVIeQYh74=; b=hasIo+T+B9A+9AJJH1s8GPU9Ti9B0w1G4GOKOt4+A2WQd3E2BJ+Gs7idD6LStjslbBb9IG V89B1MRkg2ljgFGKEgBDQQIgkn6s/WrVFBPS/sQY5G7k86Yn/tIC8T16PbvoYQItOY/epF C8RaLaEmzqW8U8dVRlhQxfJSWlN9hPM= Received: by mail-oo1-f45.google.com with SMTP id 006d021491bc7-5aa27dba8a1so493590eaf.0 for ; Fri, 12 Apr 2024 04:49:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712922552; x=1713527352; 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=tz5rhJc+yuuVb5lYrBOCyx724Exwzgl0iVGVIeQYh74=; b=DFYgXMf0/BPgJxKiAtmWPXdSsnY7mUXYLO4Bhmqo6DpzTJrYEHgj4CRAXnTRo1BYfn Ge3UUvEXW90VAYlDvPTndB4u9ykBLTjMpd/vUvFVBCoQDabXe0eIUmNVLXBPCmaxzhDG 6sDCXgD3svqSyxvpfmUhwbkAHzsuTlOyf4sV01Dbuncm5Qcgktiqco75rYUnm9Qhmw78 sm2XWy+rxic7G4NL/phXTHr53948STslVfjVPm9zXfyN5mBpp4Wp68cj2mupzJL4JVkg zLasv+WhYfGWChfwruBOZCpFFq7uSiVuw+zpBke/N9c+6r8wDAlaAvXKoBrRyKdNKN7+ vL4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712922552; x=1713527352; 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=tz5rhJc+yuuVb5lYrBOCyx724Exwzgl0iVGVIeQYh74=; b=WArC7BFua0gGmefPWTOACxkBZx2bx7jWIda6nGokI35xSpgcsdBVyVFyRuRqejqYRb lgJdAjCfaxy6yZ1DSURsD+lHOQ89d11I9/EUYTH4YGjrq4WaBOplpGhbYfkWOiJ6U4jW t1d6c8VfyAjsruRYr/JCSujqYQ3m9wvwyrdfTbQNNOiRe6fNzSFZsoRt5pEjzW4LUiqS RYKz7OhU1Vgho5AGlrpzTRsPQLK4IGmV6RmO/O+xLWKF4opq6l8cVOzzd2kd5b0aiXqO Lc9EOuRaYWD6f2C6PpYOwNLKswZ7dUNL/tjfOSALii759OSrsqAsWTS12Ab813kAfAx7 PWxA== X-Forwarded-Encrypted: i=1; AJvYcCWllvfx2KW6Q8Syb05Z1c80bOYhrCLNelNS1jzB2XE5j4qt9Dy+L3xVs35A6rEKoAakA9pEh7F077htT2dbpDjxtdQ= X-Gm-Message-State: AOJu0Yx6r6QUBecVTXTg+acvTnhUTxicvWcHlAhgG5ozrIx3pvb4J1oI iKKTO1AVIlnPeS1HEs4uZ8UWm02ML2i1vQMBj4bJadJzaRHGdNvE X-Google-Smtp-Source: AGHT+IGoLlrB1/az7wzxBwzCkP/GkjJ0TQT9RFsF15NkGD4EpE8snCMsOZiPMUh4sw8oPvuY54mhig== X-Received: by 2002:a05:6358:6914:b0:17f:87fb:5326 with SMTP id d20-20020a056358691400b0017f87fb5326mr1970254rwh.24.1712922551996; Fri, 12 Apr 2024 04:49:11 -0700 (PDT) Received: from localhost.localdomain ([2407:7000:8942:5500:aaa1:59ff:fe57:eb97]) by smtp.gmail.com with ESMTPSA id q1-20020a634301000000b005e43cce33f8sm2541048pga.88.2024.04.12.04.49.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 04:49:11 -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 v6 0/4] mm: add per-order mTHP alloc and swpout counters Date: Fri, 12 Apr 2024 23:48:54 +1200 Message-Id: <20240412114858.407208-1-21cnbao@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 0F76C40002 X-Stat-Signature: ktabwr9e6okiyxtofqq9rfmij87u7dko X-HE-Tag: 1712922552-807013 X-HE-Meta: U2FsdGVkX19LmMgY3hgLV2s/moe4JTvJ3Jf9JNR+G3aRoAwj+p+A/GS0XHaeC86EOqSamhP7aQ4537IH5UJ/M31YoVLPQ/Rk6dv/9rJxgo0STkosxDOZze0zbUOzKphtzerA0cQ2Eb4iBTCpTR0jnuLDCZKpUM8TpSc2zFDr+scnSkLz5Xffl7wm2PrXYhWu+rjisWY+uxvsJnJC3qY6wwElZMoSnXS2rgxJtF4Pz+E3mQS2nDDs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mq/HjJS+lBcCcZ5OqBKidWqNKyqqzVz3ZMPRvKyycwVVClodSaXQ1iizpOWFgBr7goEF7wxzG8NTSzhfDuWkA4bsSlZmtrE7h2C/a6M/NK7TdnXYPexQODhQF9uDudASblWvxDJQZUFd3P7xwmeCCcwKN8KrUUoT+LVUeMnVkj553TNHVlCh3QzqLsPYvPasbMm8SciutAJgjNj+l/UCMKpu2/hYDd34CTihc/QgQYvnUXXkH 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. -v6: * collect reviewed-by tags for patch2/4, 3/4, 4/4, Ryan; * move back to static array by using MAX_PTRS_PER_PTE, Ryan; * move to for_each_possible_cpu to handle cpu hotplug, Ryan; * other minor cleanups according to Ryan; -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. link: https://lore.kernel.org/linux-mm/20240412073740.294272-1-21cnbao@gmail.com/ -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 (4): mm: add per-order mTHP anon_fault_alloc and anon_fault_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 | 23 ++++++++ mm/huge_memory.c | 56 +++++++++++++++++++ mm/memory.c | 5 ++ mm/page_io.c | 1 + mm/vmscan.c | 3 + 7 files changed, 135 insertions(+), 2 deletions(-) create mode 100644 Documentation/ABI/testing/sys-kernel-mm-transparent-hugepage