Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp1255468lqh; Mon, 6 May 2024 01:47:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV3d5eLcu5+amy/Ifv8IzLSwPY0hotnkglEGl+HElzKm57jFr+9Ui8oSuN2wUqxy4deEm5SG/srfKCh1SvA3mZAI1FBewdMBv9OD3394w== X-Google-Smtp-Source: AGHT+IGc15fWlxstWJN5MQrIXniuSpZ11c4S0f5hBYjgYO0345+jdDMPwODJdiIpJ6XnEagde3VD X-Received: by 2002:a05:6808:f8c:b0:3c9:6a50:9dd with SMTP id o12-20020a0568080f8c00b003c96a5009ddmr4451142oiw.25.1714985268215; Mon, 06 May 2024 01:47:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714985268; cv=pass; d=google.com; s=arc-20160816; b=b25cKuUjYOGa1DueAwkhK7PzLHSzj/vLvo7r5npPgy++juoPnoMcTtItuSFc9r1NZ+ sUXxccwVq2A7+iq/mAjAqz6Q6QQL5flP81cuZsIHNR0pWZeySvAqcKyeaiYnE7e+JRV3 bMs1HkZPs+5iFUsn/vU/UykqimWJDuHk2FsxLvI5R0lrNDR2bhbmQn5O9dIfiajoMloh Ri7egh4VBDs1rez90PwEnL28WWRnCiXxqx6Yi4o8S3kp/Di8JDvnq3WG6Xmw2rG1x5v8 YT+k1Y5Lk7Ocu2tSwyX0fQCFGPspalnABtxxZ7sEm4dI87hnZIbHN50vQRyasVmsR15K H+ug== 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=aUksnnssWSvRHZu6SVpR2z8swC3sgIQdPUjmp/ogrf0=; fh=QbwS3auWn4deePzqcQEgPh0o+FZG4BOPGyVFHXP9ySY=; b=rmn36h9r8o4LrbvvWY6AcHdk5aaRSqHZIL41eFmM2KsMe6vs3q1hCCPk/McPJjrYIz chjN/OmnhujSh/pMAea1d6r8VEA5DD3Qay+hsK1x7UakCLMTNJzuu0zJEGbHo6BzEVv/ 4VlsCU4Sp5eS6B0jWQPF4ZWHGmFPGzmN+haL9cvDLF9loPdOVMqOtCpgMkb/LG9SotDn ZH8t18qNRPvluCO7lx2woKF3l8VlZzoL+92OZGhJfq6HH6hqe9fNMatIK5u2tsPCzhtE Icj76anTQo3ICMvsyVTUnx6J0i1RGKSBHO6tYAUr8NwyoXXSCycUKo2DFqeiJeV8UZdH ptQg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=ARCWruIb; 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-169522-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169522-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 sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id f14-20020a056a001ace00b006f3e97fc4fcsi7960815pfv.131.2024.05.06.01.47.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 01:47:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-169522-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=ARCWruIb; 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-169522-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169522-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 6CE4028273A for ; Mon, 6 May 2024 08:47:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 577B1142902; Mon, 6 May 2024 08:46:56 +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="ARCWruIb" Received: from out30-101.freemail.mail.aliyun.com (out30-101.freemail.mail.aliyun.com [115.124.30.101]) (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 60DB21422D9 for ; Mon, 6 May 2024 08:46:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.101 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714985215; cv=none; b=k1LQ6eDrzPJP2oGH0OmoEQ819aSTwapD4BJI+LKTW9E6o2nyopqyianbEJwCDvYt+Hi/SFZ7WkSENRZshfwtvDXl88YnNHL7Y1NKpJyhB4Kp05rmLHQyJkwDdph1ZhciNDhymJMIl++XONWHOWBJKo3Jd4nCLhoRK9vgCQlY+ig= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714985215; c=relaxed/simple; bh=aXZ3X5BsKkhtjbzkDsuZ2qmB5MEnQRxlo7XdIgbTI/w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=d8o3Zk4cxCPLbCJLthfYjO0Rxnmo2G2JMnnAH9uIZ4nH37Yt3Bwl7pD4wv7LeoBshoc+8d3aM7TU13vART7woMDopjYP1MeoOT/R4GPIubzcXGmuhx1yjgXnp0SYRfdJ6nIeOkY5izqeUgyM3AMlgEP9KT3nNoT7wQu1HkUkJ+Q= 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=ARCWruIb; arc=none smtp.client-ip=115.124.30.101 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=1714985211; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=aUksnnssWSvRHZu6SVpR2z8swC3sgIQdPUjmp/ogrf0=; b=ARCWruIbNbLap1Zvf8QiIb609LrCzQXRyRWkpUh1wRWfe6eNKFHF7I4hUdge5LH0/NBbgnU9kBAD4jZD5wZIDY5kj4ILhW4W7Ulb57n2wbUgmEurGTeafF4yZijdSlIFQFiOJ7DWraO6pi1j/uUFZ4RET6HSbVY863X6a9AxtsE= 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-contentspam033068173054;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=14;SR=0;TI=SMTPD_---0W5w3v7-_1714985207; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0W5w3v7-_1714985207) by smtp.aliyun-inc.com; Mon, 06 May 2024 16:46:48 +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 4/8] mm: shmem: add THP validation for PMD-mapped THP related statistics Date: Mon, 6 May 2024 16:46:28 +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 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) -- 2.39.3