Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp1015403lqb; Wed, 29 May 2024 19:05:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXT7/0JH3pxuGnVLKGRlGfqRios7BKSxP0DdBxEvPyD1zAlHIuTsjxghVrxeUdfBP63cWRjE3EpJ8MhRqX5L0LEWNiIx3ohvVk5E1ePCA== X-Google-Smtp-Source: AGHT+IFb36QNoIdeMJLSBOBVoWxV4VPplZ+oFmegGNcoFd1UQvgw2ItWcaUPBAAfzo0xR6B/aBhD X-Received: by 2002:a05:6359:100c:b0:199:29c2:1968 with SMTP id e5c5f4694b2df-199b93adeb8mr79348655d.8.1717034709779; Wed, 29 May 2024 19:05:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717034709; cv=pass; d=google.com; s=arc-20160816; b=FAHymPS62jX4OTGBUFe9VUQ6yJ3g6UPLReYDyb3f/pYfoTSKn/V2gEeXhU7y7+e86I wdGYenWFHJyNGLDnhTjenBc5xKEP2L31+BAiPwlN9hiXLnsZyzRfTjK5mvZtfBPIWFLU rZtBJ+NkJ1GbzJqd5pcJrNaiVqueY4Ig/z+CcePxy/iPpkgSYCv1VGzVbmGp66OgawLX +iICeim3woysS51a0s/SOGPqhYucT5TFvEGH7/duGIiyoYFock+l03K2W05aO3kRkr1g x2dSyyUkRxyLjk8i5+YdBE4J9+LjHwrqNCLk7fsc48+xADuSqV7q48czXIeeKEFHSiZD +LyA== 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=bE0we9/keXqENeJdz2fMdtgEp5YTi+VnoVCnWMdewgA6QOHGCrVsz8ZqV77E6n+YcO c4m7srXmo3xj30mZAe2vVg8sNd9+A8IAgRxKK5OD5tM0yyROErOBqra398hVFFsoHk33 jiqr+1xcdmSbRfx4r42AnDOh3sQk2fKh6MG+22HPNhSnY/oIVSyRhJL8R5QZ4Vg3uO6A ddVajm93o1WyvvuZ3fcnFrzqqbS9qU176rq9NzluloFP+jikcWBdb9JS06OTe3QeriGk upoohwX61a3B0KlBUyzqvso6Co1K+J/Yrk0QXWw7/6uIx8U0oHHsvIV+XIXWslTQvHsI V9ow==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=FjDHHL+6; 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-194869-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194869-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 sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-68221c69f94si11329627a12.160.2024.05.29.19.05.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 19:05:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-194869-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=FjDHHL+6; 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-194869-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194869-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 42B7FB24848 for ; Thu, 30 May 2024 02:04:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 00B331BF3A; Thu, 30 May 2024 02:04:44 +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="FjDHHL+6" 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 1EBF017BA8 for ; Thu, 30 May 2024 02:04:40 +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=1717034683; cv=none; b=hHb7lGiWQ8utALAGzD0NgMVkT1J2fzffqyExjgwQS29xYF3DKXsDYF/uaIyikURCW6QfHtulh3yzOlNzBGUq87o2+Xr303AUNqMXSldChVEHeHTgWF4nsZmpm2NKjFCPT9WNjZfgPtv8yVe3kMXdBzA/6DKZRc6GEULnJQtmiCw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717034683; c=relaxed/simple; bh=7IKpLQeAk/PwE+XF6sHfhIKOPcGYzFBQ1rJnTW0WlxY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gFYoG0Csy67aXVy0Pog0DqBl+Y06V32Xp+GvK4Im7kDrVLElktWOLdfLRHDnpt1X+E9lhqm3eneh88st3ZH79/NkvWlTIMQm3cMNfsL4gGAtx4hI1ThZXCuOEnIMAhQvceUouqi9x6kHGEx8/6438B7X4n+OsOO0VCLmdTsOLds= 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=FjDHHL+6; 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=1717034678; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=sk0VCEBLx9HEPQafud6f811f0Tz6WgnTKVbuudZtsuE=; b=FjDHHL+6nvMQhAE2W0JEM707EeNJXtctxtaTYOaeB3Rykfmw/WBzcom3vory6qXW32nsbgjvti1UnE8j7CUx2Hy+fHF1ylOe6eS/bHScNUsCxsCegrwHy0XF0EVo8T486CFX7oRTLOi9eCdddhb6IgeHDIura768ubziJIHuzgc= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R371e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033045075189;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=16;SR=0;TI=SMTPD_---0W7V1J5D_1717034676; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0W7V1J5D_1717034676) by smtp.aliyun-inc.com; Thu, 30 May 2024 10:04:36 +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 v3 2/6] mm: shmem: add THP validation for PMD-mapped THP related statistics Date: Thu, 30 May 2024 10:04:13 +0800 Message-Id: <9122368aafec9f630190da3023e01337ac49b9cd.1717033868.git.baolin.wang@linux.alibaba.com> 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