From patchwork Fri Apr 12 11:48:55 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: 13627657 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 A51E0C4345F for ; Fri, 12 Apr 2024 11:49:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3444C6B0089; Fri, 12 Apr 2024 07:49:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2F4366B008A; Fri, 12 Apr 2024 07:49:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1953F6B008C; Fri, 12 Apr 2024 07:49:22 -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 EB13D6B0089 for ; Fri, 12 Apr 2024 07:49:21 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id A775A80EBF for ; Fri, 12 Apr 2024 11:49:21 +0000 (UTC) X-FDA: 82000709322.12.B6B65BD Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by imf13.hostedemail.com (Postfix) with ESMTP id CD8DD20003 for ; Fri, 12 Apr 2024 11:49:18 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Ww5Nz04O; spf=pass (imf13.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.210.180 as permitted sender) smtp.mailfrom=21cnbao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712922558; 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=EBqcW3yGOLnf8fCkLXd+q0+NdDQ6JnFQ/vzKSqccdZY=; b=iq26dWwpTwaB02sXTuCAlYsx/I+XmnJ9X4N0BZblZ172pJpKoPn6FxEMkKzM3lUK0t/kZF mfA/9ptNA326cx0Lg0bkafTA7MrZqKPh8b24zmGUaflMJd0lFg6gSLYYVYmDaW4QpGiFo1 W2GRbp79S97ZFszHEm9kukjJO2ABY9w= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712922558; a=rsa-sha256; cv=none; b=acGbzv54QqFInP6Yy6cdGmpAxebF6xsYjX217p8M5eGFQG5X5cQZZz52sa9Co0aqo+Nu3Z cEm1SrFH4x3HpbvAZJ1rC3dUnhtp5S4VD6ePqA24HoLGPOkDiRmuYNhog+GlM29WQHKuYB +SUxL86zOXMMAmgNA9FXd1FflHFetOo= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Ww5Nz04O; spf=pass (imf13.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.210.180 as permitted sender) smtp.mailfrom=21cnbao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-6ee12766586so553239b3a.0 for ; Fri, 12 Apr 2024 04:49:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712922558; x=1713527358; 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=EBqcW3yGOLnf8fCkLXd+q0+NdDQ6JnFQ/vzKSqccdZY=; b=Ww5Nz04O1IvaAyYmgMH7B/JGv8ruDgaog3SgDUwbIhsCrq2nZwSTxpGcUBLq9xETLG M6Yzo7YshZivCGxzbokfjxdrqj729AFvH9GOrbjmnpE6+xhUiZM7W22uY+I+WLdi8faI FKxaLs7TU4teAjQJPnNU0PHg2WQm2VNSOHCi6rjn6xEQnDvJEPE+1qgI4MRB1CbGKLju LdbIrpXIrQsOHswnsyki2sc5PSEto8FVvlzG7o0RtCWD/VKawtOyEbYOb/Dy6GEcMJpq U7qQ2LaGZzGYZF8GL0HF9BptjiIS75MKzUThKEwSgBjbU4qLPXMKArR4LNqW0iCDOpVI Tqvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712922558; x=1713527358; 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=EBqcW3yGOLnf8fCkLXd+q0+NdDQ6JnFQ/vzKSqccdZY=; b=UiwA+mNXXpuSFfNuOTjV1gQpNIq0Ji8M7sAMY0rpVlXjBJCYPhOqDQCB8ZpkyUY3OA ca1e51pkOHkH6ylnobm+gLIDP1FMHgnXBuVxfPPwq43MXxzuHTNQj1sVBtVk75XoTACI q9lLHVI04dnQDNf32ZEbdIlvry/QRDWrEmt5lqBiOP8AMTJvolChSJhk6TSoiPkPE6WE 43yRpecEGRVybUkZRSRGm5iZ88L0pq8UdpEK8qrKwqUNv/xP6snJl+JzH9WDKkmmR22q PW3F8TTLSHUS/ZVKwZU9vf3uTQLqqpZUQtCDfB5mMHYVobM48DlIg80IatwJi5mmrDES K8QQ== X-Forwarded-Encrypted: i=1; AJvYcCUf02gRmBUVfRWovMuZx+5vFYeCJTxlupyQXVOhz0uwz4En4cuf/TEQX/+qrQU7z2wl5fX37KU3Sl7yGC54UzDLDr8= X-Gm-Message-State: AOJu0YzInFDPvIlpdSDyePbyGmIJl4ZRx2nVqdiHakSgAKJGMuAI0NB3 rsay8vf3/+OSy3O1U4nCFrznTqs+NIwSeIqVMjc89WBUF8zuE2DN X-Google-Smtp-Source: AGHT+IGaTHWz4rwtGHc+sgkHopCT3nCaKwwOngZTn+zC3VlvQfYHhe+0iaWXVFi2u44WZCge+8Zqcg== X-Received: by 2002:a05:6a21:3406:b0:1a8:58a2:ea41 with SMTP id yn6-20020a056a21340600b001a858a2ea41mr3325699pzb.9.1712922557669; Fri, 12 Apr 2024 04:49:17 -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.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 04:49:17 -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 1/4] mm: add per-order mTHP anon_fault_alloc and anon_fault_fallback counters Date: Fri, 12 Apr 2024 23:48:55 +1200 Message-Id: <20240412114858.407208-2-21cnbao@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412114858.407208-1-21cnbao@gmail.com> References: <20240412114858.407208-1-21cnbao@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: CD8DD20003 X-Rspam-User: X-Stat-Signature: udodp6mw7yox9bxq843e3kh9t5niyauc X-Rspamd-Server: rspam03 X-HE-Tag: 1712922558-375419 X-HE-Meta: U2FsdGVkX1+ZYsToizWr+KKRiGAOvng6m21BHg9k1GxftN9Wv/ZFCTfgmwUgd78TziXgiw5azt3hPdVKjEAU1RygeXkmcJSdrX63VvGwCEPvhV0ilwUC3SCUP2w9gSCVT9DgMFqU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rBCnbeIc3ehNWAXscbzeMCjp2XTfsBXzk0bGe5Co89yF5Fa6USvJSR0tdHiyeFtVxmS3py5J0yHAvTIyi9r+4EE9sugtRX/qp6BlUMBNkkZWYtO9wA/yjYmn8iRTeiX9x7nQYG4bOeH/29CTG2TRhhFGzXEaBquQxcWyZjQki0DDEL00bfSaVOWntr4oJ43wvm+W6oY/JmmGUUChtNt8oXsfImk2Z6nsG52e9nsc2suu3KVw6kuAwDiIYQbI+qNSJSjMX6NTqrpIjdYwduyCsh0yqPV1OXzXZwq2aWsXjNI+V9uuWxzCC4XPM/CUX3bDd7ryr376LXkVP1XQ+zrR2QBDiq76jIh6R27rIvxGTCLo+Yb1yBFhcNYzZKv0JyymjpXbxoumPDDeCf5dQp9hNgiHNeU41UZLarOmvt8oB2yrnGTTKKQJJaMvCx0I/ECT0Zh5CDFfSSSTHxej91mrgsGBH0rsSXGp2iK7NKfo+L88Dl1brH1dMqZUNsfImVSw+BaX37fKHn9Wk0ErFcuhcILrH+McvDF9DMduS211F5fpZuxi5kmGG8+rKbSQWc9i9GOq+6srHkkxPtdAAdQM3nXeRjbaFjYZQTOC+KT05DNltCDRy9o19qGcgBEA== 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 Profiling a system blindly with mTHP has become challenging due to the lack of visibility into its operations. Presenting the success rate of mTHP allocations appears to be 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. This patch establishes the framework for per-order mTHP counters. It begins by introducing the anon_fault_alloc and anon_fault_fallback counters. Additionally, to maintain consistency with thp_fault_fallback_charge in /proc/vmstat, this patch also tracks anon_fault_fallback_charge when mem_cgroup_charge fails for mTHP. Incorporating additional counters should now be straightforward as well. 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 | 21 +++++++++++++++++ mm/huge_memory.c | 52 +++++++++++++++++++++++++++++++++++++++++ mm/memory.c | 5 ++++ 3 files changed, 78 insertions(+) diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index e896ca4760f6..d4fdb2641070 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -264,6 +264,27 @@ unsigned long thp_vma_allowable_orders(struct vm_area_struct *vma, enforce_sysfs, orders); } +enum mthp_stat_item { + MTHP_STAT_ANON_FAULT_ALLOC, + MTHP_STAT_ANON_FAULT_FALLBACK, + MTHP_STAT_ANON_FAULT_FALLBACK_CHARGE, + __MTHP_STAT_COUNT +}; + +struct mthp_stat { + unsigned long stats[ilog2(MAX_PTRS_PER_PTE) + 1][__MTHP_STAT_COUNT]; +}; + +DECLARE_PER_CPU(struct mthp_stat, mthp_stats); + +static inline void count_mthp_stat(int order, enum mthp_stat_item item) +{ + if (order <= 0 || order > PMD_ORDER) + return; + + this_cpu_inc(mthp_stats.stats[order][item]); +} + #define transparent_hugepage_use_zero_page() \ (transparent_hugepage_flags & \ (1<stats[order][item]; + } + + return sum; +} + +#define DEFINE_MTHP_STAT_ATTR(_name, _index) \ +static ssize_t _name##_show(struct kobject *kobj, \ + struct kobj_attribute *attr, char *buf) \ +{ \ + int order = to_thpsize(kobj)->order; \ + \ + return sysfs_emit(buf, "%lu\n", sum_mthp_stat(order, _index)); \ +} \ +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); + +static struct attribute *stats_attrs[] = { + &anon_fault_alloc_attr.attr, + &anon_fault_fallback_attr.attr, + &anon_fault_fallback_charge_attr.attr, + NULL, +}; + +static struct attribute_group stats_attr_group = { + .name = "stats", + .attrs = stats_attrs, +}; + static struct thpsize *thpsize_create(int order, struct kobject *parent) { unsigned long size = (PAGE_SIZE << order) / SZ_1K; @@ -549,6 +591,12 @@ static struct thpsize *thpsize_create(int order, struct kobject *parent) return ERR_PTR(ret); } + ret = sysfs_create_group(&thpsize->kobj, &stats_attr_group); + if (ret) { + kobject_put(&thpsize->kobj); + return ERR_PTR(ret); + } + thpsize->order = order; return thpsize; } @@ -880,6 +928,8 @@ static vm_fault_t __do_huge_pmd_anonymous_page(struct vm_fault *vmf, folio_put(folio); count_vm_event(THP_FAULT_FALLBACK); count_vm_event(THP_FAULT_FALLBACK_CHARGE); + count_mthp_stat(HPAGE_PMD_ORDER, MTHP_STAT_ANON_FAULT_FALLBACK); + count_mthp_stat(HPAGE_PMD_ORDER, MTHP_STAT_ANON_FAULT_FALLBACK_CHARGE); return VM_FAULT_FALLBACK; } folio_throttle_swaprate(folio, gfp); @@ -929,6 +979,7 @@ static vm_fault_t __do_huge_pmd_anonymous_page(struct vm_fault *vmf, mm_inc_nr_ptes(vma->vm_mm); spin_unlock(vmf->ptl); count_vm_event(THP_FAULT_ALLOC); + count_mthp_stat(HPAGE_PMD_ORDER, MTHP_STAT_ANON_FAULT_ALLOC); count_memcg_event_mm(vma->vm_mm, THP_FAULT_ALLOC); } @@ -1050,6 +1101,7 @@ vm_fault_t do_huge_pmd_anonymous_page(struct vm_fault *vmf) folio = vma_alloc_folio(gfp, HPAGE_PMD_ORDER, vma, haddr, true); if (unlikely(!folio)) { count_vm_event(THP_FAULT_FALLBACK); + count_mthp_stat(HPAGE_PMD_ORDER, MTHP_STAT_ANON_FAULT_FALLBACK); return VM_FAULT_FALLBACK; } return __do_huge_pmd_anonymous_page(vmf, &folio->page, gfp); diff --git a/mm/memory.c b/mm/memory.c index 649a547fe8e3..f31da2de19c6 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4368,6 +4368,7 @@ static struct folio *alloc_anon_folio(struct vm_fault *vmf) folio = vma_alloc_folio(gfp, order, vma, addr, true); if (folio) { if (mem_cgroup_charge(folio, vma->vm_mm, gfp)) { + count_mthp_stat(order, MTHP_STAT_ANON_FAULT_FALLBACK_CHARGE); folio_put(folio); goto next; } @@ -4376,6 +4377,7 @@ static struct folio *alloc_anon_folio(struct vm_fault *vmf) return folio; } next: + count_mthp_stat(order, MTHP_STAT_ANON_FAULT_FALLBACK); order = next_order(&orders, order); } @@ -4485,6 +4487,9 @@ static vm_fault_t do_anonymous_page(struct vm_fault *vmf) folio_ref_add(folio, nr_pages - 1); add_mm_counter(vma->vm_mm, MM_ANONPAGES, nr_pages); +#ifdef CONFIG_TRANSPARENT_HUGEPAGE + count_mthp_stat(folio_order(folio), MTHP_STAT_ANON_FAULT_ALLOC); +#endif folio_add_new_anon_rmap(folio, vma, addr); folio_add_lru_vma(folio, vma); setpte: From patchwork Fri Apr 12 11:48:56 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: 13627658 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 67926C4345F for ; Fri, 12 Apr 2024 11:49:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F05526B008C; Fri, 12 Apr 2024 07:49:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E8D4E6B0093; Fri, 12 Apr 2024 07:49:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D2E7B6B0095; Fri, 12 Apr 2024 07:49:26 -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 B05D16B008C for ; Fri, 12 Apr 2024 07:49:26 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 81511A0E61 for ; Fri, 12 Apr 2024 11:49:26 +0000 (UTC) X-FDA: 82000709532.12.E34D3E9 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by imf11.hostedemail.com (Postfix) with ESMTP id AFA1840007 for ; Fri, 12 Apr 2024 11:49:24 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=fn1dpIG+; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf11.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.210.169 as permitted sender) smtp.mailfrom=21cnbao@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712922564; a=rsa-sha256; cv=none; b=71erSTAZqX846uo6zkYgM/CL8OsOHmnuO0ly90mBFTs2MKsb6hb6cVEXb+MMaduuLSI75d Ef5lzqmaCbpAqAKejvG5Kb/yjXHh/nDDUcQK7F2fQ8/5gMcwYmlWcLMcCkPd3Qtja+qb1B J/HP/EhzFoeDID3tLvxbBOGv1Wv+EmE= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=fn1dpIG+; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf11.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.210.169 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=1712922564; 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=rsGNE4XVP3pLkOAKr41E6LqkIK87UvM+YC6wxpcMFv8=; b=7Y+j8Iokcoku5OQhxoUKMh4ndKlGg0s891L2dXwc6uZ7LelpfazEN8Mo0BlYLyeWOvly2Y Z+lvzp2ED9jqykUbBTgVSwktGc4Zx/yUETYs7z+0mWgeoBTaS3zlDRa9sYZqy+4OCRKCLI go8rsYQsoUnZSf1gJKOmQ65WF+0YqPU= Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-6ecf8ebff50so567750b3a.1 for ; Fri, 12 Apr 2024 04:49:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712922563; x=1713527363; 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=rsGNE4XVP3pLkOAKr41E6LqkIK87UvM+YC6wxpcMFv8=; b=fn1dpIG+P/GTzZVvVEv++4xFq4GJzIDza8JAHMrva86D2XCHEGvJHOQpJQOQFzy/AU Fg3gBLhMo5BwWTP+xOcQ5p2vFehElDECLQfkcqcwXUFdArzzkfE2HK0EdzMFzAdlP69p UzO1Wbh7vz0kzwgSswV4B9rHHbiAI2FQulFRZf7gMXHSURiA/y6YUkGL86fjsZ/8ySHE 9ZkzJoX4bmNyFdBeSHsS8WBoipc+KK2qBf1KogjqWKITwMGtY+6GETWbm7tktArvfPI8 aZPyz3EVBFJNVoKA/5lHBcdlYN0Z7YYbYJZBvRPamqnm5iKyuMJGJ+Varygz0Grbw5SN D8+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712922563; x=1713527363; 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=rsGNE4XVP3pLkOAKr41E6LqkIK87UvM+YC6wxpcMFv8=; b=AkmG/c4yaQ+h8K/9Rr1dr53aQQwr3qE54ulazWMFel7putw+rZesMweyVCRA3exlOe Wr9l/rv0adYEx9/qi+BgBiCiJDhXBtCaJVFsn9pJ6gZ8MDVeAVBO2aWrMhJIL4e/Xu5p nJkZButv40vPPZKc3SFmmTVd6XfWKgKs4+9+Wb9Ccz6OANYuX+Fs6XdrnlPitXLRUqtZ a9APSABXpgydDBQnCA2+cfGnKF9424uTq0krSx2u8D4bEqtVbVj7X2ML7bJgQQ58+B2B NWGHu+n7vUlGG6FRW63Cl2vBymBVSCOsLiUQgoyG8QU4uucSzLsQ6cdUe0S1JqnMLWVr SjRw== X-Forwarded-Encrypted: i=1; AJvYcCXvAbrRQDR3QyOJslny8w06YxAclvfHzwRKUQU+7NvJN7janHMIOIAnKDPSS/ymy7ZkRYThjoBKCv6GQk7kJn7c91s= X-Gm-Message-State: AOJu0YwFsLQZV+Gcv/nA9GhrExqFBcFKH76alhsPq7dIrf1spkMwdTUc hD31S8nTc0yTqfRFxy/WqXNLJ1Dbww+GSjHylGHtraxoMxwXZwNj X-Google-Smtp-Source: AGHT+IGT5HsRUdIKeuS97P1LcQaXZ4m6uHGIP6/+AXNUFnrOjD3L9oLUEEO5s/R9jaTkOrY3eJcOCw== X-Received: by 2002:a05:6a00:10c7:b0:6ed:825b:30c0 with SMTP id d7-20020a056a0010c700b006ed825b30c0mr7228196pfu.15.1712922563594; Fri, 12 Apr 2024 04:49:23 -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.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 04:49:23 -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 2/4] mm: add per-order mTHP anon_swpout and anon_swpout_fallback counters Date: Fri, 12 Apr 2024 23:48:56 +1200 Message-Id: <20240412114858.407208-3-21cnbao@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412114858.407208-1-21cnbao@gmail.com> References: <20240412114858.407208-1-21cnbao@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: AFA1840007 X-Stat-Signature: 5tohhzxboziwbuuf5tr191q9szk9c3x9 X-HE-Tag: 1712922564-800296 X-HE-Meta: U2FsdGVkX18ozebbXdLdCtT1PeAYFDPzIEwXuL4MIQLJwR6XSkWJl+XZQaKP/fu5RJEHoFqH6g17CFszNvy2E3fYMPwS962AUHhLH2waSkWq+zAHVJ8RL9tVrRGPw2d39ZdQVL1BayPywPH10jXzO8ROMLZE/0GdKdEY3h+JJ6YoWV65TU61LdQ3bDkjCqknfDqYzcPdYSVVEI+q026UosxE+wdzN0jzTRr+dU4mtTxMZHnIn+Qahc0+CaGiuoYhuTseVryCkYOf4yJEdcCAeMehABvlAxQdPJQGf/h2utvle2QjCfjnZQq51UQtrstBQgugOI1e4Wgr8ElNFHyQGh0cgXBhUvt8dZHfgtk9sYoqJ2ldlsQfWfFqQglPm5CH/D6cOgTU3adwViVj7SuSh20ezktcMPMyjIIzW75z3WP9vm1qsgWuJP4ZMkW67Jj5X6XhRff2nn77WsL8budB2l5OYxTKdrdgg+5y361QCSHoq5xZkKd5PiWqTHO8mn0FrSxkkusz8sfeBmiSaX2IDWf2pEUg1zaES8wKDhp02TNybUPOcNnsnsIy82zLG4IMhuBviFF28ktz6qXbeYVft0hJ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2eO43nmt8cYqQ04ufRtMfZjPRuIsvUrmls2Lz9xnVv8Aq/ErOfwbH7uVvH9B4TQJhjHL4cIkOOM81qwq/mvCcYs12UZlAqgaQtXZMLnIhmoW2A6DjcKcv4ehRCRsmRraWSJSyj3Wi90FET/RbhF8UvfmZ2dIC+ApS8vmksY54ttWv304VkiA== 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 Reviewed-by: Ryan Roberts 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 Acked-by: David Hildenbrand --- 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 d4fdb2641070..7cd07b83a3d0 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 dfc38cc83a04..58f2c4745d80 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -555,11 +555,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; From patchwork Fri Apr 12 11:48:57 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: 13627659 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 C2840C4345F for ; Fri, 12 Apr 2024 11:49:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 394036B0095; Fri, 12 Apr 2024 07:49:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 31CA46B0096; Fri, 12 Apr 2024 07:49:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1956F6B0098; Fri, 12 Apr 2024 07:49:33 -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 EAFF36B0095 for ; Fri, 12 Apr 2024 07:49:32 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 80B2480EB7 for ; Fri, 12 Apr 2024 11:49:32 +0000 (UTC) X-FDA: 82000709784.27.A81BE4E Received: from mail-oo1-f54.google.com (mail-oo1-f54.google.com [209.85.161.54]) by imf22.hostedemail.com (Postfix) with ESMTP id C1756C000A for ; Fri, 12 Apr 2024 11:49:30 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=GMLAYQLh; spf=pass (imf22.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.161.54 as permitted sender) smtp.mailfrom=21cnbao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712922570; a=rsa-sha256; cv=none; b=op1HdXKFLCZs/OawrpjSjUtuOakskN04Er/jui/CYdUtFuHNqbSze3BRWJgu8ZWgDNvN6n ccJa8kutFP94h34RuZiV0M2n4mjOC3HGPQWZtOnW8fOwN4T3IVo3bTAbiewedxd4zoZBu3 XTm1hHDVvjArHQTyji7XHBQfind9aKo= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=GMLAYQLh; spf=pass (imf22.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.161.54 as permitted sender) smtp.mailfrom=21cnbao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712922570; 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=Dh6hvogc8WrNbjngKn7rl7SAnmLGjB7yuHqyvbwFdGE=; b=y2qBhYOivQOUTsB94VK+HaU1aYOgTvTCUrqFgNf3mlbCcbcYCz23zByvH0urQSM2RbkkQ8 XvzLtnjpPcmX/2f4LJmklnrt2hNN4eH++uwcvHZd6qH9JqXRQiQSvjMcbzIe4RUJK07dEd orEtnn7/tDkB1C5LFJcNFeOvHtjQf+U= Received: by mail-oo1-f54.google.com with SMTP id 006d021491bc7-5aa2551d33dso514283eaf.0 for ; Fri, 12 Apr 2024 04:49:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712922570; x=1713527370; 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=Dh6hvogc8WrNbjngKn7rl7SAnmLGjB7yuHqyvbwFdGE=; b=GMLAYQLhGAOgd0YqAv5DKI/WQFn+FfOfAO715dPoPh8ab+odFWwWy6E+6kYopxYhTw GsmgaSmZXQ1aT7qfcmzmJ1X4f8rX2sRnnbnhb9VzGqYtbFV/b5hP6fN96wQysANuayM1 v9wFiHpM7HtVSYSI+ijLwkoc3Tex8FCCUA87D8UEydIV6vRheh912jByhDb3Jhud6PoJ WQQtQE3/ggcVrBNurG19uUKm5a2942A0kb9zyLj7uy9o+4B0yHJcfZoLlFO4h09Eq036 Qhta/wzp4hiDdgUswE/zdC2SEehm8PyRDnBTMtiTNJt0b/IKWmkVGIFZzXqy9Ltc1RCX FJsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712922570; x=1713527370; 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=Dh6hvogc8WrNbjngKn7rl7SAnmLGjB7yuHqyvbwFdGE=; b=Bx7UR7k/0co7hufOodYXSgPY1HDzWrIFIlapQ977BGRYxW06nLO9Szie14+ELHKQCt CsvhU2Xwhg1fkzfTH9Ny7d20aZIQ2shf30Hw/DwX5aLT1BLUDQpeXk8HEtdGjfd4vU3b 3ias44yleDZ027rItfPE2HDdwpFifqkMjWRROwfzinXVrI5fSIS0oYJHDT6upv/Zh05N K7bZ4kU8n6yKi4+pF+Y2y1dUBWyiqSaywM7Rh3nhj8nbRgXYfXjQsAodf4s9SSuOGFmk TZMKiRlqDeuA5tN+BoCV76wS2ibs9DLQoNYYHA8fm62ep/2JS76jkCsmlw6lSsaJhACn aIpQ== X-Forwarded-Encrypted: i=1; AJvYcCW7tFo9Qd1+DwOipZVTGzDpY13l1fVmHd9uHyjyZ2Y1Zj1czstRwb/o83BjfOiI9Lyhfo0K+AJRPVuvTc/0FoGLo+g= X-Gm-Message-State: AOJu0YxC4YPTX5lGMviUGteIbBBzACTmNX35zX4TTfj5jY+389ncRDRT KXuk3jkPI5qAl2XpbXECLGmk1lLaXcShKyNAmhcUlVVzmGEuMePG X-Google-Smtp-Source: AGHT+IHSbMtHAQIh+PfqRG0gW0Y1lSnuI10KtMX9wyKQO0P5Kw6DL1x3fzgwy290LKu7YQyO4BqMtg== X-Received: by 2002:a05:6359:4608:b0:186:2a96:a5b9 with SMTP id my8-20020a056359460800b001862a96a5b9mr2626632rwb.6.1712922569322; Fri, 12 Apr 2024 04:49:29 -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.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 04:49:28 -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 3/4] mm: add docs for per-order mTHP counters and transhuge_page ABI Date: Fri, 12 Apr 2024 23:48:57 +1200 Message-Id: <20240412114858.407208-4-21cnbao@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412114858.407208-1-21cnbao@gmail.com> References: <20240412114858.407208-1-21cnbao@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: C1756C000A X-Stat-Signature: cbtgssawxa35im98hf9dnd6yjf6mj6ht X-Rspam-User: X-HE-Tag: 1712922570-623778 X-HE-Meta: U2FsdGVkX195gqCchwFVZbl05YRpP6JB/vdAYvr/xTzgqwb41/BG937Iz2jGQGtqVSI5XahIW5pKtGd7zEGoAElafMenAzs3mvJwZoIqzNSuMcdZtD9yzohtAE948DZIl4A/cXHW1hCNDEbBV/g6CEkPCKAYyEUsUYmtvxVxFSrxpkBO5hunOI588wOiLiqrpwaCKbu3ZFFpj2kSxrGjfeky/HrJcQYAEr1ewHK2c8tGoEFX3I+geDBZxlfaMPv2WVMQKBBUCEERjD1xvlzbp7d77fTZPtn5EMAoly0yu+QvXsWpSRONoH6vFON3J1FpYRiqnkWwcWcH9r7Z2ldvq+ZIKn5z+uFo3Q0dpN3XET7N0LvbW1PMuHxlAiDj1W4hWwofKyfz1QBDT2dzykWcUwwqkH9RzJxaCCDYdVYVC6ix42QNUhVYFEKboUyk6sK0RGl4cYiv3EjmenAbxJ9lOiKhvvNgjJki1KGE/4Ci4+TuoPj5L7YPftnYMPkjosG7f+zH3JvA/5acvk8J+joaw/56uj4wnidfTKIlB86ZvpW5Fkz4uyuY3X8H9o+OwEwI1Lm/cSCPcSLnOOf7Cb/iv2SV4F5O7HQlsh86HIEoRogJGdU3GcudnxaPPY2huGwVdOoJVT9UWeMy38JE8w7RVvPwxmVJ48LoEaniMn2vFBAyOojZZKMGkXAB9o7zzSg3Erp16RaBJX/wjlZzygRk7p9+w8r+0CEbDKxECIK7BUB/XFx2Iun+8zRN053jEbBgfdYUyJYDa+4098GdK/T0PzUXpcyLdqURn+6z2IgP5XhsVNMSPY9AJZdfngrayvP0y/r+pFEcxO73q8oo+Lvpf16b+fZJglBLdrUXmiemIDYRbF0+ULNDMkVZnhFQNdOAZaQnWVzymq3tovulBADOrOyRZhq13ad0BhwnLdCvuDbSCTcP763O4hYEugPl04mjWOh1DdBkArgforXeLCN xh/WhoYj pGPDP5nIWdy5Xi9PHw+feCkrP6vY2ShGHRJrlLSLjMbUsobvJxcya5gkKJqeY0AYg3L909HTBmuJ7Rn993gpYSAPECVn5NIUuVh1sR8FaFlUXss1ioHUpj9LywNyMiA5b7K+auPUBecWndz3CzTgkSyofMJTfnxesWOOX 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 patch includes documentation for mTHP counters and an ABI file for sys-kernel-mm-transparent-hugepage, which appears to have been missing for some time. Signed-off-by: Barry Song Reviewed-by: Ryan Roberts 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 Cc: Jonathan Corbet Reviewed-by: David Hildenbrand --- .../sys-kernel-mm-transparent-hugepage | 17 +++++++++++ Documentation/admin-guide/mm/transhuge.rst | 28 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 Documentation/ABI/testing/sys-kernel-mm-transparent-hugepage diff --git a/Documentation/ABI/testing/sys-kernel-mm-transparent-hugepage b/Documentation/ABI/testing/sys-kernel-mm-transparent-hugepage new file mode 100644 index 000000000000..33163eba5342 --- /dev/null +++ b/Documentation/ABI/testing/sys-kernel-mm-transparent-hugepage @@ -0,0 +1,17 @@ +What: /sys/kernel/mm/transparent_hugepage/ +Date: April 2024 +Contact: Linux memory management mailing list +Description: + /sys/kernel/mm/transparent_hugepage/ contains a number of files and + subdirectories, + - defrag + - enabled + - hpage_pmd_size + - khugepaged + - shmem_enabled + - use_zero_page + - subdirectories of the form hugepages-kB, where + is the page size of the hugepages supported by the kernel/CPU + combination. + + See Documentation/admin-guide/mm/transhuge.rst for details. diff --git a/Documentation/admin-guide/mm/transhuge.rst b/Documentation/admin-guide/mm/transhuge.rst index 04eb45a2f940..e0fe17affeb3 100644 --- a/Documentation/admin-guide/mm/transhuge.rst +++ b/Documentation/admin-guide/mm/transhuge.rst @@ -447,6 +447,34 @@ thp_swpout_fallback Usually because failed to allocate some continuous swap space for the huge page. +In /sys/kernel/mm/transparent_hugepage/hugepages-kB/stats, There are +also individual counters for each huge page size, which can be utilized to +monitor the system's effectiveness in providing huge pages for usage. Each +counter has its own corresponding file. + +anon_fault_alloc + is incremented every time a huge page is successfully + allocated and charged to handle a page fault. + +anon_fault_fallback + is incremented if a page fault fails to allocate or charge + a huge page and instead falls back to using huge pages with + lower orders or small pages. + +anon_fault_fallback_charge + is incremented if a page fault fails to charge a huge page and + instead falls back to using huge pages with lower orders or + small pages even though the allocation was successful. + +anon_swpout + is incremented every time a huge page is swapped out in one + piece without splitting. + +anon_swpout_fallback + is incremented if a huge page has to be split before swapout. + Usually because failed to allocate some continuous swap space + for the huge page. + As the system ages, allocating huge pages may be expensive as the system uses memory compaction to copy data around memory to free a huge page for use. There are some counters in ``/proc/vmstat`` to help From patchwork Fri Apr 12 11:48:58 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: 13627660 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 0B148C4345F for ; Fri, 12 Apr 2024 11:49:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 937ED6B0098; Fri, 12 Apr 2024 07:49:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 89AB26B0099; Fri, 12 Apr 2024 07:49:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 713496B009A; Fri, 12 Apr 2024 07:49:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 503636B0098 for ; Fri, 12 Apr 2024 07:49:38 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id EBD81140E69 for ; Fri, 12 Apr 2024 11:49:37 +0000 (UTC) X-FDA: 82000709994.20.C617CE8 Received: from mail-oo1-f44.google.com (mail-oo1-f44.google.com [209.85.161.44]) by imf06.hostedemail.com (Postfix) with ESMTP id 08BB318001D for ; Fri, 12 Apr 2024 11:49:35 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=kenCTHg4; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf06.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.161.44 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=1712922576; 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=JkmaL5dnbNToitX+dr2yruhYVAPZI2DFDH1TSVGRV7w=; b=UplS5XYicJUsEhMMytaC/QSmrY8jPQ8eDo8Jg6ZFj/zRMO6017iB7wQRkeodpVW9vZpbv9 ELNdRGjnFndSdrDmowGleTwa7mvqlB9w0IRyzcSy/3RBOJmNGi7kj7zJGR8Ra3FiYgXg0U uSqC6rWVpqVDTqpQOtkE9zViw8dmyGQ= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=kenCTHg4; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf06.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.161.44 as permitted sender) smtp.mailfrom=21cnbao@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712922576; a=rsa-sha256; cv=none; b=04Fe02XsfHN8RpU9ZDDWoahT6VaVvYuFqjN512MAaEypo6AKUbW3SurrOam6Shf20WkqtE +KxGFzGM4AXEqRQvguRVsdFH4IHJ0CPRbdv+LXxzgKNJCNf+YiL7eP37PIYO5dLnI4aivK 5JQvrQVbNsu9pOHxns0jf0TGHOW1l/w= Received: by mail-oo1-f44.google.com with SMTP id 006d021491bc7-5aa12c21ff4so542266eaf.3 for ; Fri, 12 Apr 2024 04:49:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712922575; x=1713527375; 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=JkmaL5dnbNToitX+dr2yruhYVAPZI2DFDH1TSVGRV7w=; b=kenCTHg4JNox/5yKNWJoSDq/G/ni6445oi1YsJw6RnlD8+BY2Z3UsHyModJ/T7xOQR jjN9VkwMT+hhxXe8b3XugbSNskq8t+Tcd6fAzDqtcxVtTh7fO/hg9IPGqsw7TIsQ1l7l kIkljOt0QzpfP7wLmlHV4raAxh04w5R6U91SWRRoOs5V6rHZGefBctkKKyv6Sd3QH/Bv fsj00qSQ1YTkzV4pUpuNbMoMO5nU1pbE07ckSRBZ02Gt/yLOUhBu3A58T2FXA1FaIz9X oEI5vAkqs79cT7WnTb7DAPGZOHfFmWEjpW7uNfWo6eBjNRTudnT37PgL1wzMRj2wABp1 ZxEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712922575; x=1713527375; 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=JkmaL5dnbNToitX+dr2yruhYVAPZI2DFDH1TSVGRV7w=; b=NMlHh3Xp+4Gc1MOoxUTFDm40ZOFKCscofHt2hTIZfemFxOnDfPgQWRBc71/cgONrDU OdJpeDe9C6Av1gcTd9nP9xbH1ff5XgtBT2eoA2MtLozBJEnaih1TPPkv54lzew1qlroH 7KN+4dUUMaXXVLwlc1XVRHX6dF6U9MZ8rdHsMuaNUIWL95wKy+acUDpiTKWJIh0IAlqk 3p1iH4u9yFKrqRtfmBgtYFDdnWZyknTXbPtqAWnbTHEt/jxVlL0ME+0rC+P3doCFuwvt Eleok56NfBGD+GL8eQ9Bc1/vWOqSjUPA30TYjbilWC6VjIOPX5wT85hLwTHuVf9lJ/GF JiQw== X-Forwarded-Encrypted: i=1; AJvYcCWxCCZZhTimkBxHhc8GTBCXqTs7y0Y8/7AKeCgfnaZ1HZ+6t8qbKd+SL8JFTQtia9O2Dk2ZzfAHrPDcd5diK+D3PC8= X-Gm-Message-State: AOJu0YwxeI0hR2g5HuZiegf/sZCoukOqQCiU/0wJq66gVIOyMcL7R81K YrM5eiLvUQy19YorWQx7KuDhLoaDPhZBbcm0C56M+p/+Tq/SKMBG X-Google-Smtp-Source: AGHT+IELpsWoBmGsNvBBR/x1yJEqJQU0ioXXjh7/o28t3fv1i7+x6sXnF0k1SDCwzsvXK5vX3cvAmg== X-Received: by 2002:a05:6871:b27:b0:22e:a204:9bb5 with SMTP id fq39-20020a0568710b2700b0022ea2049bb5mr2485122oab.53.1712922575076; Fri, 12 Apr 2024 04:49:35 -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.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 04:49:34 -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 4/4] mm: correct the docs for thp_fault_alloc and thp_fault_fallback Date: Fri, 12 Apr 2024 23:48:58 +1200 Message-Id: <20240412114858.407208-5-21cnbao@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240412114858.407208-1-21cnbao@gmail.com> References: <20240412114858.407208-1-21cnbao@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-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+1o7vYP4 VgTC9s8C 3Zgz7Bu3EhL7BwzZJZlA+pqxADzyvsve9oqWi+SRNZqdEx9GX/rhdYBaB/rBBvdF7lAzc8inj+ikAvaEMMe0lCuPOqedZkV4YtN+z0uuMnvl+T4Bdh48tyIIrZ8Bv7RwtoZnYf5C0kw+Swf+PdReQ08e+pbbnzpchja6Lyh6OVh44UvJIPZE1KlkWUghDCZ/L5ZW4Gjv48l1LC2EDGPK3JA17+V0udnIe3F3g3T0FTJSZwDoeJRLdIWMJw9hMJI8CsUcFrZhaboUJc76weoHEWMOE06sIcWgS04hWXauJOpUZr6ydK3WlCn4amPaKEI5BJMpD3Jf0MWmMNwlkTt7KhGcGsCf/TQAsTvq7hMK2LtDKns0ojCU3+uGdgLLEN0LkrlfZymAElsv14tZf6PqUgE22ifakRH+VYv+ifB4U4fJAd+xbbzzxrIaq+4x22uvcl7tt1xRN4jUHhO90Is5HaB11N3fKKF4R9CIP6EWwZFLzBlH90nQ7MGfvnrsxwLZQbOBEg+frDN3En1m1PJU3BDMATDpFSN0GGa+tn9ioI10ys9cZGXsi+mF+J57/O17DQxHADjfRhAH7M3WlssovgTcleWa+z3NCX98VeCn35N6fbm1J5zKyXdH2r/O16W0YGia3JRwR8uqEUxAq7/SdDLmHF9jhZLBDp/XUobl4kInvfm183EOKRZSsNB7oRbRg77PsuKRcHrPJYpZ0rjsS7EF5/uVgIhJtZpIreiYM7bAxoBENzVX4feAvy8/zqNyl1FX88NjHyt75SOttUVtNQVCY8rUAf9dusIWKO6kqzAF0cPN0XeMHVDV0x1ClAxTAnNc9NmySlAAB/+ewWYxkyzXTiW2za5m74XCKtEowr5jiCwnG8Zkgk7KUCGVLWUnomiWu3Lm6u3gq2E4= 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 documentation does not align with the code. In __do_huge_pmd_anonymous_page(), THP_FAULT_FALLBACK is incremented when mem_cgroup_charge() fails, despite the allocation succeeding, whereas THP_FAULT_ALLOC is only incremented after a successful charge. Signed-off-by: Barry Song Reviewed-by: Ryan Roberts 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 Cc: Jonathan Corbet Reviewed-by: David Hildenbrand --- Documentation/admin-guide/mm/transhuge.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/admin-guide/mm/transhuge.rst b/Documentation/admin-guide/mm/transhuge.rst index e0fe17affeb3..f82300b9193f 100644 --- a/Documentation/admin-guide/mm/transhuge.rst +++ b/Documentation/admin-guide/mm/transhuge.rst @@ -369,7 +369,7 @@ monitor how successfully the system is providing huge pages for use. thp_fault_alloc is incremented every time a huge page is successfully - allocated to handle a page fault. + allocated and charged to handle a page fault. thp_collapse_alloc is incremented by khugepaged when it has found @@ -377,7 +377,7 @@ thp_collapse_alloc successfully allocated a new huge page to store the data. thp_fault_fallback - is incremented if a page fault fails to allocate + is incremented if a page fault fails to allocate or charge a huge page and instead falls back to using small pages. thp_fault_fallback_charge