Received: by 2002:a05:7208:2202:b0:86:316c:7444 with SMTP id s2csp2366418rbb; Tue, 4 Jun 2024 03:18:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU2mpHtbA+74tLhWo5dEuHXWsghNurbmwtgtznK//YVJQCwAw+34gcw2u2e11P38XZ+uyZnf//dZkeYA9+a9rojHGA9tbZ48/VwTvixWw== X-Google-Smtp-Source: AGHT+IFxKn+v4kHAH6qtzOlACfRA3eHUg7uFI1xToxc2RA6/0KaqbOMr9FzVhVpz10N0HhKTV7fr X-Received: by 2002:a25:dccd:0:b0:df4:43f6:5b75 with SMTP id 3f1490d57ef6-dfa73be9600mr11959722276.24.1717496321269; Tue, 04 Jun 2024 03:18:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717496321; cv=pass; d=google.com; s=arc-20160816; b=oBwLBH11EUtJnhsJONh6oPtYbs8yIXJyAA4om9TLoe2JQxzdyJ98BXSh0SOnHHKLkT t3RQ5BcYeMlUy2kYL7HUmlSduXKYmAeTij+z/kbzj1PMET7gisprHeZEAaQ5aezmRoR6 +ZcTy2wY/12gUzx576lzpoVrOOCiYiWLTII+fVJAmMqxvW+NF2altoRO4LMa9NpnIPtF Bo21mqZYisd9gXnSzmhcjzmzZCtNnT8mgZC2kPqCBL9Jnjxeq5jfQAPRPk0+uWRA4e92 rOCeKvuMqa/tuit3PcaOJIiv/zXrvXNs1NAa5dWf0qq1efhR4Mz4LA7n63s+9chgORfg W4sw== 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=rfA/FbqZISlGYVYhkhICYY39Z7gVOs3XPr1xdIFumR96JxQiKZ5eAKip8Vx5zonIvS NnHWU7fXnvlc86/N3gG/AcM4SnLLwSVNCRGiQxKkMkDxbv6G3AQ5vb647Alz5gnOBlnX G9ATFQAE1xQnORg+WHXSMlQucmkA7b5Pv8KFI44An9UAcSrX28gzcM8HMAiCJt5/9JC1 ThmrBqAUzVPO6ePtX2Uw64AI4L1EIfLo5CnrKFcr/pt0QCqu2y5Nl1DTD4N/N5ul83/0 H2gdLUYgFFt/SSRUfZdWwaTL72HeNWuM+9IpOIw/myHvlLhBsPP0d1PwDvvtg1DBimsl skxQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=nOZPNs9n; 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-200413-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200413-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. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-43ff257ef4asi103541141cf.525.2024.06.04.03.18.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 03:18:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-200413-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=nOZPNs9n; 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-200413-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200413-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 06E501C22478 for ; Tue, 4 Jun 2024 10:18:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3B0C3145323; Tue, 4 Jun 2024 10:18:19 +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="nOZPNs9n" Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) (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 139551420DB for ; Tue, 4 Jun 2024 10:18:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717496298; cv=none; b=pYz1/DKRBY4KrH5yJ4i12thry2JHMtw3Nw0dc8P3oE+IDZIsFHe5Zul01vIZqc1BJFbXb8bMGtKz91wcN2SsmoXazUjyE9TMmm67jMetoHmlJQxKCazWjhe5o1vTAkBVmiL65TReadEj3y+iYtzpsS3MtOwKYHty/zFxn24mTUI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717496298; c=relaxed/simple; bh=7IKpLQeAk/PwE+XF6sHfhIKOPcGYzFBQ1rJnTW0WlxY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DaLeaO0L9vn0ugD1dQvchpGHXxbzFbizGB46fDpBk8+Q+FkntJnRGUiHc4Eg30vS4N2r0fhnjpiHAvF8Z+oLzLEzikIkNeTK+4/MeiFZ/caGsT1HOSGMiwcVHMdJyyQnH+RXTMC1IyBkSMFNys3i5I1Pa0GJhNf/B8qiMhSrIMc= 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=nOZPNs9n; arc=none smtp.client-ip=115.124.30.130 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=1717496288; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=sk0VCEBLx9HEPQafud6f811f0Tz6WgnTKVbuudZtsuE=; b=nOZPNs9nldMQxiTMNVnUvfS14W4ayDuzqRWlYz3ohfyYzuOhYt9pqAOQvCTDx/AR++bczUfQwfns/vBlibSs0ubKQqWgv8kr5d+7l2lN3CyK2EUYbe3h03ELK8QgdhJwADum2HYpT1prnHr081bZvE/ep0kEe2Wdjc0ubkBGPb4= 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=maildocker-contentspam033037067109;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=16;SR=0;TI=SMTPD_---0W7qooIK_1717496285; Received: from localhost(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0W7qooIK_1717496285) by smtp.aliyun-inc.com; Tue, 04 Jun 2024 18:18:06 +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 v4 2/6] mm: shmem: add THP validation for PMD-mapped THP related statistics Date: Tue, 4 Jun 2024 18:17:46 +0800 Message-Id: <337ad58a839cbdef4ecd446c22ffcf8c9dcfd9af.1717495894.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