From patchwork Tue Jun 11 10:11:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 13693371 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 B4D67C27C75 for ; Tue, 11 Jun 2024 10:11:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DB7826B0096; Tue, 11 Jun 2024 06:11:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D40816B00A0; Tue, 11 Jun 2024 06:11:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BDF696B00A3; Tue, 11 Jun 2024 06:11:24 -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 9F91A6B0096 for ; Tue, 11 Jun 2024 06:11:24 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 4065F1412F9 for ; Tue, 11 Jun 2024 10:11:24 +0000 (UTC) X-FDA: 82218190488.04.ACE6BC4 Received: from out30-112.freemail.mail.aliyun.com (out30-112.freemail.mail.aliyun.com [115.124.30.112]) by imf24.hostedemail.com (Postfix) with ESMTP id 1F48D180006 for ; Tue, 11 Jun 2024 10:11:21 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=G+S8m3CJ; spf=pass (imf24.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.112 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=1718100682; a=rsa-sha256; cv=none; b=vz0UAGhO/yU41/l6gi4LAVSZ5nDKGLdR5AjbVyuAZM/juECyVyEimNVCGq74khktBtjqNh hh7LH8vd+LBXNujrzLoA2KomAYZXV7I5M7mC+iln3kAHstxhSUHKCuT3xwSBYwIn/NNviT uBIkTrIlRMKus3BFTz7yeoDBhMonb0k= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=G+S8m3CJ; spf=pass (imf24.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.112 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=1718100682; 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=sk0VCEBLx9HEPQafud6f811f0Tz6WgnTKVbuudZtsuE=; b=Vd81aBtDGyBcZQr/0gysF2x4hO+2By0P0Np3h/yuy7gMOc970P6IHyGlZgrz5PN6dIpKDE JGVbLL1BFtIx4v4JI/rzFwNjE2LpY4xhmTMcAanMp8QWkbfWhd0omLEGIHtnZGyzr8Tnyq eOxC2vfQYSYchmxbhZbQ/XQiJ3jQGis= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1718100679; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=sk0VCEBLx9HEPQafud6f811f0Tz6WgnTKVbuudZtsuE=; b=G+S8m3CJeaGO/N3L6M/HIQFECjbieubXUYafz8SHfbvukr+zHxZjC7+yrkmKRvRxj22CHcIrRDKBMQ1s1tSrCP813AzIOuhW/3RFu71gmbwIj3oy7wu2P/gk7y44omrPCbRGc3Gjwa5QeAqP4+yMB1F0ycSZD6O1ExuD5yGIZBw= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R111e4;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=16;SR=0;TI=SMTPD_---0W8G1Jqm_1718100677; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0W8G1Jqm_1718100677) by smtp.aliyun-inc.com; Tue, 11 Jun 2024 18:11:17 +0800 From: Baolin Wang To: akpm@linux-foundation.org, hughd@google.com Cc: willy@infradead.org, david@redhat.com, wangkefeng.wang@huawei.com, ying.huang@intel.com, 21cnbao@gmail.com, ryan.roberts@arm.com, shy828301@gmail.com, ziy@nvidia.com, ioworker0@gmail.com, da.gomez@samsung.com, p.raghav@samsung.com, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 2/6] mm: shmem: add THP validation for PMD-mapped THP related statistics Date: Tue, 11 Jun 2024 18:11:06 +0800 Message-Id: X-Mailer: git-send-email 2.39.3 In-Reply-To: References: MIME-Version: 1.0 X-Stat-Signature: fr6yybabeitr5mjx54xkgcrcxwdbhphz X-Rspamd-Queue-Id: 1F48D180006 X-Rspamd-Server: rspam04 X-Rspam-User: X-HE-Tag: 1718100681-890824 X-HE-Meta: U2FsdGVkX19YY9i9Z5DwRllRGYUTIE1TFe1yGudjwZmQp+FvNlNKzfQpvfzXkNJQBraPl9pRTETS3e/0rlJCwQKq5XlIb+XI+mS4shP8SEVxkc3spbvzKxbsZifvYK2jRZN+kI9tT4VuJaqDRsVe8YHiCM6dI2agjW8urB138ebUCu4DrBzc6qSoipkkiTnQWTPanrod5OkQnzXQspn9x0aBdWv8O+1kCy5v7gW6/ysATrbWnf8EZRMibqMgJBEC6IbpUI7a6NAx6RmqYAKXfmh/A1sQrZ9f+B7K5+gQnSIXNIaHUprE7ac8MJRr1yhAB49RRUwfZ48exA4zvAlTrh14199Ezr6sDS9IV1P0AznNTz4tQGQeiEAh/BX9QRDIDl2d1PXE2ehs8kl2mfONzCinnxZim/aLxYP5hPWnZ9xMFyO5yxXjDjtwa1aiLCLAHuoDW67iO0BkpsUSnXnzNBcXjYJ2rCX43bL6eF9bC1+VVjsLkNOrkUOLvhGUxujogaSsb0hsKmnR6J9z4oqPPELY3wOG14ry+/CRvx6jIu7JURJwlnQ1pqKVFiETfx8t6pkR0Whx4xHcR3GeP3ljMKPTkPMTz4GsjtdVS3vMvdA+LxOJmjsziTt4syAaJQw1kclgYjQRToDy52epPTA506WBo3zrub+GBYokHYB5HzSFbTnSGp0snwCPKkW+DqRKaU5RSKtZeD5nn6hYN5CueEwl9hK4JBggspQTb/tNWakM0c5z8ZJIUWCv7FiW3N5lAvtx1WMbMBrozZed+CTZ+tQHs+NExjQMaA9hwyHMDmIhkdEvo91WyOiB7L7UNDlj0kDsRn+iXhK6YY/Lhghy6HD0nHXQsS4sLeMK6/zWsKKBEncNbqOZshA4H14+5/MFfs/L0Z/myEoqocPqFcsMYE3IWaNpGKVuPT8WlBHBxsSVlOV1NqHLXyekZN/qUPPJN2H8akiLWE3e12uz/TD upuquYF1 JANtriOrZr03GlyI/MGJBfga5md2lVdeHWaZjhUdVDkoyNjXchhksCERW+jEPmen0xFuIc4xo+e2XkzgKYmWLU8nMjKsoSAsBqBeGq6GgXmpazTiHzm4omtvAqEgGsEDsro39Kc9uXS55OhdBhn4jhygbTX7GayHzsvR/hodYmR32svbAh/1sxEGRmwYIhTHaKLaR5btaLPys8jRc3bNneCIpBPlmaH6QhCurJ/zE57KGzLMcN706INLDW+tulL2OLkgs58nw+Mj1S3RSdvOAZ9ej+e4NUlYgEmydsD7VQcyXgGQ= 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 6868c0af3a69..ae358efc397a 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1647,7 +1647,7 @@ static struct folio *shmem_alloc_and_add_folio(gfp_t gfp, return ERR_PTR(-E2BIG); folio = shmem_alloc_folio(gfp, HPAGE_PMD_ORDER, info, index); - if (!folio) + if (!folio && pages == HPAGE_PMD_NR) count_vm_event(THP_FILE_FALLBACK); } else { pages = 1; @@ -1665,7 +1665,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); } @@ -2031,7 +2031,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)