From patchwork Mon Apr 22 07:02:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baolin Wang X-Patchwork-Id: 13637718 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 71BC7C4345F for ; Mon, 22 Apr 2024 07:03:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D5BEC6B008C; Mon, 22 Apr 2024 03:03:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CE1AB6B0092; Mon, 22 Apr 2024 03:03:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B83D46B0093; Mon, 22 Apr 2024 03:03:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 95FA16B008C for ; Mon, 22 Apr 2024 03:03:06 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 443CF120A4E for ; Mon, 22 Apr 2024 07:03:06 +0000 (UTC) X-FDA: 82036275972.07.DDE9084 Received: from out30-118.freemail.mail.aliyun.com (out30-118.freemail.mail.aliyun.com [115.124.30.118]) by imf23.hostedemail.com (Postfix) with ESMTP id D3AA8140018 for ; Mon, 22 Apr 2024 07:03:03 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=goBv34hw; spf=pass (imf23.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.118 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713769384; 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=0SsdcViQ2lxDH4gZYEPPhvXdWD/avqV+Env2Q3pLz7o=; b=vBzhKrxG5yido2dpEZuX+cP61DhCfytKqh5NN6YNBDDQeqpdWbe0qyaDEZjqpbsWYzBNb1 y2LqozkJba4O/dttsS1x9CjGQuP77h9BLzkqIUIN9nCAyudz3YTcbtisoQG3WQCmq4zcem jgbPTeeNpMwdVP7HaJwHp3tEFttgmRI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713769384; a=rsa-sha256; cv=none; b=Nu/dYOObz7ix33LIiICOtyxfq6jggWEm4XRaTpFq9+E6i6msWhwA15BRSIP4x04y/kea9e MH+KA+KqpfebxBaCgVmatZbw3lgUEcZ3OzQAUqlR2J9f4PV8+qBecdt7lt4x5FTT1WsI2q ygdqW3J2aA2oG+c8GamnTJbZSEnbfAc= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=goBv34hw; spf=pass (imf23.hostedemail.com: domain of baolin.wang@linux.alibaba.com designates 115.124.30.118 as permitted sender) smtp.mailfrom=baolin.wang@linux.alibaba.com; dmarc=pass (policy=none) header.from=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: MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: D3AA8140018 X-Rspam-User: X-Stat-Signature: mebjxygoe686b8w9dp7h81x43irsy4ya X-HE-Tag: 1713769383-416963 X-HE-Meta: U2FsdGVkX1/4OO/TaZbafvgraospcfnhbEWtHa5RVv0AeSZ8a1Xd3aBQRto0DlF3u+HAKLmbXofH9rE1nYZGh5ODUx21ro5q87x5b+m9aA9EmcLUYt60u9mz8kNaVIkZ4JfvpBVlqHEJ/m+IecdFoytneNlIttWv1d6EioAouhOc+roUdS7jXhZWRTpSy90GtDHPFa9LldIvOi/JQck8ia31skTGO7cVt7E6FGmJPeDawIoHXvqy51Jvku0DfFegtPxZ7e5OSUvxtwUSBfnla+Epn4cY6cUElqS1zcn19y+feEbyVL3LY1sJNIbyAQfcW9KIOYIqT05r8ydZKLxwujqgV3sa50gFxgle5zWPL/LjUYpJIhHDFey+em6svrke0iHu+q/YR6k9WpUCoObFaYZbdJIixm9IMT+rVVhb0DmOVTWsJQ4zUEjytks5qtrxL+ft6uhCjjJ3WZRntwUYaB0x2oGQ4z4F6VDw8vyeYVFirLOiS/2P0wwZiGDBuQWNaZiI1ktoncxB5UpKi9VOR5cStMmhbB7e5Ur35GLbbr1FM5RCZzhm3dqGe3BeWdTfv6/Y31XIrfbs9eRnDjFy3RfhOHklBQZLbW3rqYZ+1gtDpwUk8dNVqMep/W1mKh3AA/2lo/jl/1c+98faNkQ5L4l4gG77nS4c+2pTWtZlcJ0Ps1/wlBqc9tsf6dTLOKe4GqbWROnsZBvQSPScBVTKQKhUdpV32CyLsA+Cf6TgHz9iVQVShDJKfyJ3veVaBmICmljai9G62KyPIjIBAkQlMJDxkNnG7H1QG5qMkgDnXZK5GbiW45qJwKteQ6+eZK8aVEPl3QpduFj5sMSLdZymBGIfKrBSUm0YKAT/3AIuKQtoVmL0lj/Tq30xnqY75bH14scF/YC+pFU9arG31moC2knORg3ese8Fvmrmab+rEJT6akruc1FNIGUlHTjQopp9pYaxTBF7m1oo/gvR8jb F3v8LP7j LwBwOR7R4eUNCTMZzt2s0U1xvC/xHu4zdMG3mMphh2qWa0hTiQc+kC415htKiZjrWpXbDwDRYkq3UJ7VAq/OP87TmG8pgUhpwEy97EXXfWZ+d0E/70He99tqqRx5Vq+keBoEsQ1GrknkfT4uP3eEbZ4N8gVM58PVF3BImwXYT5vBEZEKPp4Lwin3d4Jk6RKh1P1hyaI0S4RtIwawOwlt5MekFgGoXoqRWfbViIPw10xkOnR0= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-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 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)