From patchwork Thu May 30 02:04:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 13679633 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1ED9BC25B7E for ; Thu, 30 May 2024 02:04:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CA12C6B00A4; Wed, 29 May 2024 22:04:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BF7026B00A1; Wed, 29 May 2024 22:04:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A98426B00A3; Wed, 29 May 2024 22:04:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 848FB6B009E for ; Wed, 29 May 2024 22:04:44 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 292061409E4 for ; Thu, 30 May 2024 02:04:44 +0000 (UTC) X-FDA: 82173418488.20.993C720 Received: from out30-124.freemail.mail.aliyun.com (out30-124.freemail.mail.aliyun.com [115.124.30.124]) by imf10.hostedemail.com (Postfix) with ESMTP id 24131C0020 for ; Thu, 30 May 2024 02:04:40 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=xPoZGVs5; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf10.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.124 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1717034681; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=sk0VCEBLx9HEPQafud6f811f0Tz6WgnTKVbuudZtsuE=; b=ty6528dVJXEmhzcXVGrzuiLL0AndGm4IMLMhTi9OPbDpZ+8h+Owocf7TMnluGiMoWP63Tc o6/R/U0uCJ0G+ZnW6GoqtJlcaGfU074az6yiy3xHRVQTJQcz/Fp17inX+z6l4Gb69iI0fw tlaA+65u3dEj8fj1JzA+KlJ5bV5/ppE= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=xPoZGVs5; dmarc=pass (policy=none) header.from=linux.alibaba.com; spf=pass (imf10.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.124 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717034681; a=rsa-sha256; cv=none; b=5HjkLJ6L2kcFdGqsH/tM+c1kF7SPPSQSwPzaZwBktj1lcjFwjf357UlytyCPY6UlEGYu6y Xm5fzBC37ulfuRAWgkzZrXHuhJdlYcg0ucKT8/50ZNcIWQdW+VlSOLhYanmNKdeSwgzqDj GN0tFF8kiy3A7JQ8xGXVSuL9jqw4QP0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1717034677; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=sk0VCEBLx9HEPQafud6f811f0Tz6WgnTKVbuudZtsuE=; b=xPoZGVs5Ey7WTqrMjEUy10zrl3uAfbvq+XYkNgdoV1p/UeyfgzkeU2b4SckrMtbzxruo9wb+13mJC3vWZLiWvEoorKKW4+U6ZP31Qg9TLy6YjTyhKjcevBvXw/fSXeLtENQhiuTS+Vn9U6mKDDGHzSTbsrs1cLwWQ/fHbc1PfUg= 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: MIME-Version: 1.0 X-Rspamd-Queue-Id: 24131C0020 X-Stat-Signature: 7qc5t1wmp67nmhbxb4rhtiko5qixh6jb X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1717034680-341969 X-HE-Meta: U2FsdGVkX1/TN6xxmExPkokcJ/rBeMeuNBpeKE/D7ri9AMF8hYwOmLEhGXnEQfznCa3D5aPNHPQDUcQHHQXKm4TI/BLJFPDe2YidF/vnfjKAZQaPxbfilw9VDnxaI+BrphLbRmItU3YhUjAwZfbmaoJrXzcsv/rKUbBCAGFm4blQTEYDATBMF63+5GxERlN2jZ8j78s3ZoDV/PkuhB1UGto+egw7OOT0EC5fDZ8pJdTHjXoGZtQLUSDnPx4DUcau/ps3QgnKXrBBpq4wXy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mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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)