From patchwork Mon May 13 05:08:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 13663020 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 32B07C25B5F for ; Mon, 13 May 2024 05:08:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 45E926B015A; Mon, 13 May 2024 01:08:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 39A556B0256; Mon, 13 May 2024 01:08:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 17D976B025A; Mon, 13 May 2024 01:08:45 -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 DD9896B015A for ; Mon, 13 May 2024 01:08:44 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 975E3C0ADE for ; Mon, 13 May 2024 05:08:44 +0000 (UTC) X-FDA: 82112192568.07.6EFECEF Received: from out30-101.freemail.mail.aliyun.com (out30-101.freemail.mail.aliyun.com [115.124.30.101]) by imf09.hostedemail.com (Postfix) with ESMTP id 4CEDD14000A for ; Mon, 13 May 2024 05:08:41 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=srFSmgNC; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf09.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.101 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1715576922; 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=aUksnnssWSvRHZu6SVpR2z8swC3sgIQdPUjmp/ogrf0=; b=Dos5LPLyh5g+Vjw182q/aJ+N1Zio2C3UWBKuGtJ9MzT06vf8FZuI9cEC5a6kA/Z8DLtXMo Ev3uEiF++YHIwPNmFyC8ZfJw6sqX0Zy/PeLhMMptpd9y4m/Yyt1jlzCjFb1+BrSayoAa7X uzWrl7yYREvrAbi1xXscAhx7iwTJIi8= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=srFSmgNC; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf09.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.101 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1715576922; a=rsa-sha256; cv=none; b=2JAI+O1gEi01kE3B7VmLlRSIM9NRC3HldLb1SCqsGMgJP9X+LhcIdCospOo73FbOaB772U F80/zgFYtBgdwUHVU6XwFwmE9ISjLHtHs+/CNWDzgtKdL33VZXTPfnN4Ypvjhkwx6b1yVf Dx9kx4PUegLcDGNZoHIJiMd9YDzE+30= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1715576919; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=aUksnnssWSvRHZu6SVpR2z8swC3sgIQdPUjmp/ogrf0=; b=srFSmgNCQAoX3A57O4gWlnWXqQmz46ne38nEDzmfEKo51vZif83UxWegLppk3TLr9WSnqctHrYlNTOiRRZAUTyBoCF5/f2a0lIZMDVzBhgmhQAueteKYbI1YMZkeDR7wkaMwbUJ18ElttmZIdel5+hIhZ1uQu1A+y1YgVHRIhjc= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R101e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037067113;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=14;SR=0;TI=SMTPD_---0W6HNn3X_1715576916; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0W6HNn3X_1715576916) by smtp.aliyun-inc.com; Mon, 13 May 2024 13:08:37 +0800 From: Baolin Wang To: akpm@linux-foundation.org, hughd@google.com Cc: willy@infradead.org, david@redhat.com, ioworker0@gmail.com, wangkefeng.wang@huawei.com, ying.huang@intel.com, 21cnbao@gmail.com, ryan.roberts@arm.com, shy828301@gmail.com, ziy@nvidia.com, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/7] mm: shmem: add THP validation for PMD-mapped THP related statistics Date: Mon, 13 May 2024 13:08:13 +0800 Message-Id: X-Mailer: git-send-email 2.39.3 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 4CEDD14000A X-Stat-Signature: xnoyqqn5fwjei6fb1d63eqsg779cwpwp X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1715576921-546283 X-HE-Meta: U2FsdGVkX1+9ioT4igAtPv7MLsTKFX5bKtHfIRcWgPygESV9KJGdOXp7o3Um5EpVH5StUn0hlFWUGth+mr/9ScOHhRvoZyLP5AhgvzuZKufWtIu7CEL9yXlhzyzNpGnSuxjQvMZoz+jVX0o6QcvfW+wHmI3+vcIotSLSNwTzmtIO3b8N6LahrrnHpGVxtOv6CjPm3IYFS92fi1LGQWvPlFCXwZq2LSPGnIZ3azUFU/sVjCmEoYwfm3GRshZRBBnt80jKdh1A0jXnXxqf4Ki0YOfToXDLwzCPrv4JbjE797r7w8UvvVXKZdE8qGae9iWDjs4S0aU7tvEzwz9gJH8CyWHyNS1DnmoBUA+NJVHscmy6xqkqusbjNpy2DdztQljmzsaiDnE2JnffmuXoz2huVor9qvpowM2FLNHHzK/CmQ8STh3itsd3QaICQcLCW8f1b6lL1n594zeLvhy7Td2Q5GSgLEVVH9qPG8q1205rfnHGXTrvqVnq0euDm3kOYraSlPvIW9QPR8oq/8fk6xEGmSzxHHtue36uofgKFVuN6HLv3YSbWpUF/H/qfTT8X2/lfl/T6TKsBYlt6C3oIHS2MRXY1WTI5URcYyLZ3fuWEUF3IXvp2mvwuXUanL4Ee3xKL8AYRO1UmoPsRGk8vMdiBg8vwB8EbI/mo95N7FY2vq15RMZsxJ4FOqfIRR4OmxxeeD8xGoF/Rt0jPL0hzkBvWGyy3e8JfUg1wa0UuXF7Zx4B1dW5XyJsw0vbq88B8ulc8UJAJG23Jn8Db0cTL6xv/3EE41XYsMnI74iN2vvD1Wp3T3JLKClz3Jdpx50ntVU/F7cUQQnId8TQ80UnRG8IuHmqqOQsI5SbrjfrV1QnUwBSjDpEWS9jKilhrGsiSbM1n2rzVkPtNonA+RmCc+6mIjzmviLntcrqqQhEAs7Wzdt5TtdwbgHK6GyCJSA2wAI1UZuR/oFOfsjU/WJfqLA ZF5ovUDu mpDoYadszm0qratKSehACXeL7N69B3dqXm2dIQyh6nZZJIkFnZuFoQQdYf2bphhgcrV7Hd2iGUSA2QMEGDdDB6QuL4C8eFmuXxRHOylRE0qezI57tGYK/6aIoK6E9FVukVsLxiN3Omb7D3CkIC2cSoIr1qwRE/Cn9irkEISZBeQYfkqNLmqZX8Du62Yx1DGep2i47/ZOsLgE+AZy8MK156QJortk18w1ey/Xcrj22J/MoLGFpPvVr89n0pUElIu0lJ8Wax0PowlyZFuV6i3xcxLcQLq9AqBwgqy7jO13G6qQb8s8= 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: In order to extend support for mTHP, add THP validation for PMD-mapped THP related statistics to avoid statistical confusion. Signed-off-by: Baolin Wang Reviewed-by: Barry Song --- mm/shmem.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index e4483c4596a8..a383ea9a89a5 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1661,7 +1661,7 @@ static struct folio *shmem_alloc_and_add_folio(gfp_t gfp, return ERR_PTR(-E2BIG); folio = shmem_alloc_hugefolio(gfp, info, index, HPAGE_PMD_ORDER); - if (!folio) + if (!folio && pages == HPAGE_PMD_NR) count_vm_event(THP_FILE_FALLBACK); } else { pages = 1; @@ -1679,7 +1679,7 @@ static struct folio *shmem_alloc_and_add_folio(gfp_t gfp, if (xa_find(&mapping->i_pages, &index, index + pages - 1, XA_PRESENT)) { error = -EEXIST; - } else if (huge) { + } else if (pages == HPAGE_PMD_NR) { count_vm_event(THP_FILE_FALLBACK); count_vm_event(THP_FILE_FALLBACK_CHARGE); } @@ -2045,7 +2045,8 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, folio = shmem_alloc_and_add_folio(huge_gfp, inode, index, fault_mm, true); if (!IS_ERR(folio)) { - count_vm_event(THP_FILE_ALLOC); + if (folio_test_pmd_mappable(folio)) + count_vm_event(THP_FILE_ALLOC); goto alloced; } if (PTR_ERR(folio) == -EEXIST)