Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2077607lqt; Mon, 22 Apr 2024 00:04:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV6E1d41bbbSdXU+rSBUekAMruL4snYPonZOOYwd8nrNKLq6j8mQcyWFh+e+QVFMa5QUdFvWQ0EPrXGXU2CzaNQjmCfc6L0Z1G2fWiARw== X-Google-Smtp-Source: AGHT+IGHs8G+UGQ5GLCaM2g+SZJUgXLfITiUMrsWS8OPkwxExFEoeFvhyxOJm3utz04XVYWh8HUS X-Received: by 2002:a05:6a21:328f:b0:1a7:5100:7559 with SMTP id yt15-20020a056a21328f00b001a751007559mr13740735pzb.32.1713769474217; Mon, 22 Apr 2024 00:04:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713769474; cv=pass; d=google.com; s=arc-20160816; b=lANWu9sig6VXomMaAwR9+ViUECO5cVQvCqE/Qd1kpsKA759HS/JZXhj0qfk5pJ02pz Kh97MACIecJjYmOpSibT8g7Ti56xWZTIoh9dVYf4kNr9LVCsibtyv+ReuTVc9LadxI6v By5X0BDLn8PegpY1s3+DDpjC5XMxXNnQ89ugIHeNAGi7R97VgHfkaEX/d2xOQttKQp69 545Ul8IJttOCl+ztwLmsBL9lP1z8OGfJ2VutKaJYptpWJtzlLl5z3kzN1EzdgWcTLrSb +Ptrr0pSgulfSPmITFzinHDL/FBuIXH6ApgUMEwzWba35I9H/F3YZAFDnv+6Gl1jgrzB Y7OQ== 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=0SsdcViQ2lxDH4gZYEPPhvXdWD/avqV+Env2Q3pLz7o=; fh=g586Og5O/SXhL23QYbFhGrsFvTrke7WPI63lNAC0sdg=; b=vp8X5dja8TYqv9PvDML5TC5MukadwwVrJLvBmZrSNo/w0Xon9rzO3j2ZVGGHGbYkmQ hAOglewKdQHIT11h7BpesNyvc4RgHkT8VXiFC4PhYbC8OEAE9PgcpyJAWI5fZDAHhkop gEKuaswIcnl18U4v/o19aGDv4w5CLOyEF/eRRNUQHuduKdOcJr0oCI42kj49tLs3mdkg jyaRr1WF1SrEqB1MiHCCcXT/oeHOLvBaeqC6Pasy00PSoRORJMb+xNqvTgT8XnJG+Eej dJzA8i71zsmSxreiBbKdhK/p/QaeDeZAEE4vPzd+Vu5iahVCdw4ykUEqNT4xDmXVV68z Lu8Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=goBv34hw; 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-152819-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152819-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. [147.75.48.161]) by mx.google.com with ESMTPS id 131-20020a630189000000b005ee3cfc0a24si7268541pgb.43.2024.04.22.00.04.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 00:04:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-152819-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=goBv34hw; 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-152819-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152819-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 E97A1B21BB1 for ; Mon, 22 Apr 2024 07:03:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B905D4CDE0; Mon, 22 Apr 2024 07:03:08 +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="goBv34hw" Received: from out30-119.freemail.mail.aliyun.com (out30-119.freemail.mail.aliyun.com [115.124.30.119]) (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 A2019495F0 for ; Mon, 22 Apr 2024 07:03:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.119 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713769388; cv=none; b=XNGUCUv/Rgf9EQ3LZu1JjoZZjF9JcN0CxYZpf+tTnbxTyOhP1be/JzPdeE31CUK62HyzQHVtQZAaYybYG1I4iJTfk0sQzU3OwUFCPS6atFackVE8UGdGUtW6UVctbcsZDYIsmRL1jwleYe4BkjVeGTo+8d5L5q5FZkZJqMTyOdo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713769388; c=relaxed/simple; bh=lv5PqU5g2qQjCdgqUVI5mkhEGLV73xIpYwqgswJR48g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PAaWkZpz6bwAgWmBc47wJkI1Td5/La+0OOd99W+rk9ZeF7KL9j41AgmFrJyUfMk6oAds+b0VEncPKFfWcvK4Rdthc/foIb8y9R/UtxG9ekJftYTb/ihAE+2D3QacZFibicOim3CB0Bd/MFwOvAuBOec2w00LYlWvzGx7gQCemlA= 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=goBv34hw; arc=none smtp.client-ip=115.124.30.119 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=1713769381; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=0SsdcViQ2lxDH4gZYEPPhvXdWD/avqV+Env2Q3pLz7o=; b=goBv34hww93Jw8e3t4O4G8/ufkQgeZVJPNDOb3rqoX9XQhrlJAT2O4fZRs9/hlu+FvA1+/mfSnm9tSQr/+tOEHwv1iSKQnBjA66Az/Hv1YLNMWKnQJ1nm6mp9L/LikHGKe32xORmnNg/TCsFSFgoV3UYW3hAY0yMJGjNLb/yA0c= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R121e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046051;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=13;SR=0;TI=SMTPD_---0W5-amKe_1713769378; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0W5-amKe_1713769378) by smtp.aliyun-inc.com; Mon, 22 Apr 2024 15:02:59 +0800 From: Baolin Wang To: akpm@linux-foundation.org, hughd@google.com Cc: willy@infradead.org, david@redhat.com, wangkefeng.wang@huawei.com, 21cnbao@gmail.com, ryan.roberts@arm.com, ying.huang@intel.com, shy828301@gmail.com, ziy@nvidia.com, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 3/5] mm: shmem: add THP validation for PMD-mapped THP related statistics Date: Mon, 22 Apr 2024 15:02:41 +0800 Message-Id: <4107dcc957f3b62a37c83e30ca22305c373ef149.1713755580.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 --- mm/shmem.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 893c88efc45f..b4afda71a3f0 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1662,7 +1662,7 @@ static struct folio *shmem_alloc_and_add_folio(gfp_t gfp, return ERR_PTR(-E2BIG); folio = shmem_alloc_hugefolio(gfp, info, index, order); - if (!folio) + if (!folio && pages == HPAGE_PMD_NR) count_vm_event(THP_FILE_FALLBACK); } else { pages = 1; @@ -1680,7 +1680,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); } @@ -2046,7 +2046,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