Received: by 2002:ab2:69cc:0:b0:1fd:c486:4f03 with SMTP id n12csp241798lqp; Tue, 11 Jun 2024 03:11:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVAGLO9F/vsnzPLjn88N5lknAxeXpprlsH1RF42/ZEIOIegmhQjMhhBTDnjiWXsjBkI3qOA0e7Ao7CZVY0mO/dD1ti7zHw+NVcdF9UVUg== X-Google-Smtp-Source: AGHT+IFNHTP+wOYg+svSfkE++JfZHW3TT5u2uXVO2k5nPJ9BJn4+Vm42fidlRz4Iu/h8YPlb4fAQ X-Received: by 2002:a05:6214:3117:b0:6b0:839e:ba6b with SMTP id 6a1803df08f44-6b0839ebf72mr39593786d6.43.1718100692205; Tue, 11 Jun 2024 03:11:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718100692; cv=pass; d=google.com; s=arc-20160816; b=KSITE9F1PMo9EJqQlVlzIw/xgTzAUZfgmvqKOcUnG74lfdX3iHRcC//2LEHuEyZpnR IOgtqi6/vvEVsYVr98sJQ7qVDcYnZP1p1wB5EQZHPknai1pvwlFXhRwgsi8I2xgbn0D3 thVxpuzrXm908YNdc9geZ090cm5h8VzAQG7gpos1WxM/0zzpMAxXeYMGvEFMvoMTwP4I O2DKnaxdk/DA2igQdBOYo1Hof8oGMj6JKYE3dzCQpEuJZRLMKvGiVG/8IFjpG3YS8CQE mGBfpSZRWOFshWBuk77ofMz5lPj7XXDcKczUnTi03L11wesSGqiwNOzj7gzcQM7SATvp nsYA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=sk0VCEBLx9HEPQafud6f811f0Tz6WgnTKVbuudZtsuE=; fh=d9B6n7k7iFbk3BUsTidzz8lQOS2iyyRQbZ5BNlMEHw4=; b=IENq7lYFGEsovYnJZtPweM9IS7a0ebCCR+/GR/h5BUarIW+pqjn095m/cMIGlIl2NK 2RPJDlrP3CxK/0c9Tm6jduPmzNv1KTtzsSzv1ITRNbPsk57YbXkNtB19fg0Kx2DuXQf6 aCyeFr7bSK02dRfDpcAUGBZ3+mqfe6rzpu4fGDRsdYJAtPoOq+KnE2A7SA2oP6/8ryJv blRw1wMaJofDwHx3Yh2oyrySjRFXGlSc7QNpjfDO+0Oj0/dpA9bHWK+AGJ3vs5bFK0RU u16995fCBv6HLT0+ByXc5/2E8CWedmEQ3/SioL4p4kPlm1Bf+TjcK03H3KADLclMgR07 YlnQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=G+S8m3CJ; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-209612-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209612-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 6a1803df08f44-6b04f681435si125744066d6.134.2024.06.11.03.11.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 03:11:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-209612-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=G+S8m3CJ; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-209612-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209612-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id E6E7C1C23846 for ; Tue, 11 Jun 2024 10:11:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0C5E4178385; Tue, 11 Jun 2024 10:11:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="G+S8m3CJ" Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C9CB3E57E for ; Tue, 11 Jun 2024 10:11:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.132 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718100685; cv=none; b=q+V8ASJwMQ1vMpt0/AJCReUgWkhBen2q/cevKixnFsTKDsWk4noc/4ZpRWSrWh/fFPfwa3yQA4VZS5gvvEQFysM0tCpjtPdNp/0eyMq6b4hoIkMo+EP8/qt8IURH/a5uKoveEw0tMvvaw6MUh3KoQEza4T1eOLc1zHpVTk0kTmU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718100685; c=relaxed/simple; bh=7IKpLQeAk/PwE+XF6sHfhIKOPcGYzFBQ1rJnTW0WlxY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=n5xYzM9nwEK8ooT1/evy29FWXhLPcpJMcIW3Hxv427Zgf/vghvZv8tvSYhJ3Wkct8w/RsfQDZm7S4Ktq6eOyLaoErcCjxCUuJ9vj3rhrcdTfexm8oWhX0em5nHmwLLLFRLPytlFD5fATiDn0SNaGvmyepCPGkrubknps2drBtLg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=G+S8m3CJ; arc=none smtp.client-ip=115.124.30.132 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com 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: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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) -- 2.39.3