From patchwork Mon Apr 22 07:02:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 13637720 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 DD7D0C4345F for ; Mon, 22 Apr 2024 07:03:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 850896B0095; Mon, 22 Apr 2024 03:03:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7D7BA6B0096; Mon, 22 Apr 2024 03:03:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 684AB6B0098; Mon, 22 Apr 2024 03:03:08 -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 485926B0095 for ; Mon, 22 Apr 2024 03:03:08 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C6C1EC09A1 for ; Mon, 22 Apr 2024 07:03:07 +0000 (UTC) X-FDA: 82036276014.12.D26CCFF Received: from out30-118.freemail.mail.aliyun.com (out30-118.freemail.mail.aliyun.com [115.124.30.118]) by imf03.hostedemail.com (Postfix) with ESMTP id E119420021 for ; Mon, 22 Apr 2024 07:03:05 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=FaxMVXv9; spf=pass (imf03.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.118 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713769386; a=rsa-sha256; cv=none; b=iGhiNo0o4pHdCHFUjFzWBYRT1HxgHUVpka9ppj+8gtw0ugVAVC2chosGxy6N1WBJjGO6Ks yra5LJjpEQGDO5DrGw7eKfPwZKgzT+YGCEju3EPPlGzViyP2J/8h5+XaiKgR6bsypg8m3k ckkvLAXr3bAPZ/LNuKMCsa+NQQ2GmPo= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=FaxMVXv9; spf=pass (imf03.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.118 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713769386; 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=wvGbdG/PyCf+R85lbGysoGrudwoqTXGK9KleQ+1X+Xo=; b=qxsr6pm6fbShsPJXaMV5X2O/FwXpPvxA7ip8nlYjdV9ilKAd6XGudlkg7UqJErYB/au2fF 5Fb64IndoG3e8VnfD8YrTH+tm1qkUoZhv66hniaJjrnA2Z7rvf7b2l1tQYribDZfco96uO R3FQRD60Znh2b2SHMQKXD4L4S1A/oeg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1713769383; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=wvGbdG/PyCf+R85lbGysoGrudwoqTXGK9KleQ+1X+Xo=; b=FaxMVXv99zb2IRvGSjadM3i1YeJTdWrY8tELEhoEGzy7MIYUzM1bfJYkw2ZObXp+KBxtwnC/o9t52yihjyVwNANo8YtArlXehxDkKn+yxBmQ7LA4F23vUPINCuAblvZCNiqaDBxPj2S0XqgWxiQa7V03dw4ym40E+4q/JmkmkYc= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R421e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046056;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=13;SR=0;TI=SMTPD_---0W5-amM8_1713769381; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0W5-amM8_1713769381) by smtp.aliyun-inc.com; Mon, 22 Apr 2024 15:03:02 +0800 From: Baolin Wang To: akpm@linux-foundation.org, hughd@google.com Cc: willy@infradead.org, david@redhat.com, wangkefeng.wang@huawei.com, 21cnbao@gmail.com, ryan.roberts@arm.com, ying.huang@intel.com, shy828301@gmail.com, ziy@nvidia.com, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 5/5] mm: shmem: add anonymous share mTHP counters Date: Mon, 22 Apr 2024 15:02:43 +0800 Message-Id: <05d0096e4ec3e572d1d52d33a31a661321ac1551.1713755580.git.baolin.wang@linux.alibaba.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: E119420021 X-Stat-Signature: pci8jtp9duiasa9i7usr45u9xodedbtg X-Rspam-User: X-HE-Tag: 1713769385-246326 X-HE-Meta: U2FsdGVkX1/4wcPYIuv6AGu8Ch0LVY9q4xv63u1tnSKJDzaQMP8rcMsQ4fKn5Dzkrh94c6f0lsImYHaiOm0tLaGrqkY06cz0Kc3M92HUJKuMHDjYJ1cCccJ8ZG3TGBgni2g299lMY2G6nZYv+EdtN/klRTUabb5CawMZYZr7qOIYD4b6vR2mdleABMtwDXr7eP6SklLyyhrsiPi34qkgLvZeQQ9h67L07YRuHF86e/ZoQ1EW/qlYVadxPkMMJWyVvutQerwLMREEygOoqvQ/q7EVlCVRZRnPGZsF8KUSUxok1BD8P61tNDWAPvJ5Bt+SDCLP8UHmPIeT5+DoMstdAIAjpVCFlZBIDoTHw3165+LQUEYr7J+0HKmIIVNTCpn28L9ZwjsF+GT18OrRHo1TX/2lwIE8dVlqDwlT3/G3fxPH4A7OZeisbhDAeGti60PR/4uiBztSe2glvY1VJ8C5gizYSdYUXthFnx+6+e9p0re7GgkO6jpaNp8b7Qk4mrBX5wCpPvsRZ1VdpgWzSUijFyKQOlTzcjAx6BdbrG+dV9p8YQkPHXY3TTrbv5DXUZw4/uK1xduVmGX7+WR7gu4ZMYBMdu5lUquTNDLyp7gCe4g+esnN4WYPJ7pepsC6sgHiE0x67hXtQBkmvm3W9JU8NOfJynxdD5jVP7WHrEJFKaZb57ZKLxl/lj3oH37YQFRvnwr8fmQ48bru9ee92XkYdh++JFl7D1cV4wdAY/Mj4b9tA54ItBn48noH68fLZRNJ6hKSf3+j5AakVxFmIeeMBeZ99d9bq/4eCvNHO4xE1CI+hs4Bm2qqveLVrrWgPB1Mu7QbOzdWmocJ2KXOpMuyWaWZuokVj41i/FHCmdqvbM2lrBttrd8pyFs6LzRyhDrOa9tVOdQRFiNycMBIGB3Jj5DUYyvppJi+ 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: Signed-off-by: Baolin Wang --- include/linux/huge_mm.h | 2 ++ mm/huge_memory.c | 4 ++++ mm/shmem.c | 5 ++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index 26b6fa98d8ac..67b9c1acad31 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -270,6 +270,8 @@ enum mthp_stat_item { MTHP_STAT_ANON_SWPOUT, MTHP_STAT_ANON_SWPOUT_FALLBACK, MTHP_STAT_ANON_SWPIN_REFAULT, + MTHP_STAT_SHMEM_ANON_ALLOC, + MTHP_STAT_SHMEM_ANON_ALLOC_FALLBACK, __MTHP_STAT_COUNT }; diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 9e52c0db7580..dc15240c1ab3 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -557,6 +557,8 @@ DEFINE_MTHP_STAT_ATTR(anon_alloc_fallback, MTHP_STAT_ANON_ALLOC_FALLBACK); DEFINE_MTHP_STAT_ATTR(anon_swpout, MTHP_STAT_ANON_SWPOUT); DEFINE_MTHP_STAT_ATTR(anon_swpout_fallback, MTHP_STAT_ANON_SWPOUT_FALLBACK); DEFINE_MTHP_STAT_ATTR(anon_swpin_refault, MTHP_STAT_ANON_SWPIN_REFAULT); +DEFINE_MTHP_STAT_ATTR(shmem_anon_alloc, MTHP_STAT_SHMEM_ANON_ALLOC); +DEFINE_MTHP_STAT_ATTR(shmem_anon_alloc_fallback, MTHP_STAT_SHMEM_ANON_ALLOC_FALLBACK); static struct attribute *stats_attrs[] = { &anon_alloc_attr.attr, @@ -564,6 +566,8 @@ static struct attribute *stats_attrs[] = { &anon_swpout_attr.attr, &anon_swpout_fallback_attr.attr, &anon_swpin_refault_attr.attr, + &shmem_anon_alloc_attr.attr, + &shmem_anon_alloc_fallback_attr.attr, NULL, }; diff --git a/mm/shmem.c b/mm/shmem.c index 8b009e7040b2..4a0aa75ab29c 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1706,11 +1706,14 @@ static struct folio *shmem_alloc_and_add_folio(struct vm_fault *vmf, pages = 1 << order; index = round_down(index, pages); folio = shmem_alloc_hugefolio(gfp, info, index, order); - if (folio) + if (folio) { + count_mthp_stat(order, MTHP_STAT_SHMEM_ANON_ALLOC); goto allocated; + } if (pages == HPAGE_PMD_NR) count_vm_event(THP_FILE_FALLBACK); + count_mthp_stat(order, MTHP_STAT_SHMEM_ANON_ALLOC_FALLBACK); order = next_order(&orders, order); } } else {