From patchwork Tue Dec 3 13:49:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenchao Hao X-Patchwork-Id: 13892513 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 0E91BE64AA9 for ; Tue, 3 Dec 2024 13:50:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 94FAF6B007B; Tue, 3 Dec 2024 08:50:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8FE2B6B0089; Tue, 3 Dec 2024 08:50:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7C5716B008A; Tue, 3 Dec 2024 08:50:03 -0500 (EST) 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 5F87B6B0089 for ; Tue, 3 Dec 2024 08:50:03 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id CEACC8087A for ; Tue, 3 Dec 2024 13:50:02 +0000 (UTC) X-FDA: 82853781066.26.0161E3D Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by imf28.hostedemail.com (Postfix) with ESMTP id A44E7C0020 for ; Tue, 3 Dec 2024 13:49:44 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=bGkNx4JG; spf=pass (imf28.hostedemail.com: domain of haowenchao22@gmail.com designates 209.85.214.169 as permitted sender) smtp.mailfrom=haowenchao22@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733233792; 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:references:dkim-signature; bh=wrWeEjYD6C32kDH9Wy7fR9BLzK2OqNy/5AsIIlJG/qg=; b=rBMzU47pKk9QLSF0IQ8iROTSu2bMdPPSbvE5QgI41pZt84EeLtEQ1oGHBtItX1tLD3WfVh tFOCbN1izB7uOD5988hlRqRctNSIT5igl6w/Z30WILnqeCdqm9YmaXWyAR8wE5rdmutFhZ YZ+MRRBxf38gExAKM8/4hYnkAz1N5BI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733233792; a=rsa-sha256; cv=none; b=Pw5xL7DGaJzL7/rBcgJfS5CfcNP/XLdH94WZortGFzd6DgVBXgwc6EXp9AbnENLGadrTy7 /pM/4/1cJDajn5P25rgMq5UrFjtbOGfzuFflVzZzIGLKbH+5Oa6ARLGwUJMtGdndXLGo2i d36P8Uz7OGpFsLEmhU2bb5X++9Gl8HM= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=bGkNx4JG; spf=pass (imf28.hostedemail.com: domain of haowenchao22@gmail.com designates 209.85.214.169 as permitted sender) smtp.mailfrom=haowenchao22@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-215770613dbso20383165ad.2 for ; Tue, 03 Dec 2024 05:50:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733233799; x=1733838599; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=wrWeEjYD6C32kDH9Wy7fR9BLzK2OqNy/5AsIIlJG/qg=; b=bGkNx4JGneo+MIzcSoZ09yifOpTjc9IIva8QqiON7SVRv/xQ6g89nUHLdZ9Bkys1rl quAUdyKJPux/JINg62w52OkpPooXaYzpPRTzNrurtx3hOgXEF0dNpDeeg1bVbwOt/YnI awWP8K0WuNr4yEGVujqL+PgNV11YmYo7vBLeMFy0YUYMmO+LFzjRiPI8NkI5WY4qkDPU 9aLXjmZEu/vfQDs+FowQgNYRKjirEB3b+vElHhoVzYsHdKCHuKRTNQrZ8UywanK/5z4O 3Llasf68TRdKmyiIhtan+PZegIubX5poEHUeU19mgidcGe3pv5VTqyKxJlujYzgK3cuE qVwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733233799; x=1733838599; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=wrWeEjYD6C32kDH9Wy7fR9BLzK2OqNy/5AsIIlJG/qg=; b=SZ1zNcJo/n88yEOKubcNitXSy3KBehNZ1vN4fyiIi/hC2ToOmRrHj+bRQzqOfCyakq eVDdCnsFTos3CliBXKDwgd3O/zGlpX+fBauJP1bz0/tBxv25BH8E4dfJXtCe22iOhWyG 50ftxalJeST7RSeiW3D0SbBSs2HJwE/CJrWFyxPcYe5v8jGqWK3nluWeBOy5dNo/NdY/ Bqx2OLkKdoQ9dbZIqfK6NaCzly90bK+7wzoNGepO2jB5IrW2EqN1mMwKBRfkIYUKs4xp OuBYZrg71WgSaS0zZUuGQ0hwdW0XbYVTLDIx5z98IvCJsn0dMM7Z56UWd/oAYldiAAnT 2Oqw== X-Forwarded-Encrypted: i=1; AJvYcCX6Qj25E3aI+I+Abavh2UwHSEUICcsSnpOLfan6ojLFvVozYNosjHxKx0kNJ9pFD6+eah8fmJfCIA==@kvack.org X-Gm-Message-State: AOJu0YxIpQflqW6qZ+MYAFh1spFNwZH+7m2O78Nbtz5/OjACWAZ0sfUq 1OUW3VR2KdMGDnhsappZYJngMmGJ4oOvI2sJLuzw0WT6nowI4FEY X-Gm-Gg: ASbGnctFAjy12GemYPxluhUccdJ0QMCfRpUnX9PopQiQBYF88e8us+zxPgc9QLeMISi C0uK6EZcTBJS9J1k0k7QJO6fXmKRcHMWO30tsqWQhSi/4cmxFSTOIivcV9J5qEe6VU//BZgUM4Z 6eK//MYm8BDwy1/WNZv3g1W7TLtAshh1603Gi3QOl0cWDvcikMVAQ0ycpGv+1jwJGa2Ku7FsrRc G5tyMaytxNFNtK9gLtDHHyZEMFXy/S9onsefJ/t/Be66hV+5BOSbx/xcR2LNsyQv48= X-Google-Smtp-Source: AGHT+IGIJBbhiflV+C90jpzpvrzchfkyMrxi/56fWyyZnzCIcxngq76SpJzowglJgC/KJ6dWDnW05g== X-Received: by 2002:a17:902:d2c9:b0:215:681d:7a52 with SMTP id d9443c01a7336-215bd17a76cmr25562285ad.55.1733233799585; Tue, 03 Dec 2024 05:49:59 -0800 (PST) Received: from localhost.localdomain ([43.224.245.241]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-215b46e99edsm16990065ad.80.2024.12.03.05.49.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 05:49:59 -0800 (PST) From: Wenchao Hao To: Andrew Morton , David Hildenbrand , Matthew Wilcox , Oscar Salvador , Muhammad Usama Anjum , Andrii Nakryiko , Ryan Roberts , Peter Xu , Barry Song <21cnbao@gmail.com>, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Cc: Wenchao Hao Subject: [PATCH] smaps: count large pages smaller than PMD size to anonymous_thp Date: Tue, 3 Dec 2024 21:49:49 +0800 Message-ID: <20241203134949.2588947-1-haowenchao22@gmail.com> X-Mailer: git-send-email 2.47.0 MIME-Version: 1.0 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: A44E7C0020 X-Stat-Signature: hz6o9oeds313kfd3qg9do85dztpx8sij X-Rspam-User: X-HE-Tag: 1733233784-629628 X-HE-Meta: U2FsdGVkX18Mz5fNcJAK3knEWo2Z7zQ9iSPr+a1RUcXQ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F02wZf6ey5MfmYSmYI3FhzGubmc+R3eH3QDSpF6oSTuYNY9H2wsxGcGVBSbckXTy6rcUBbN0k3+HpDYQ4W5q//bQN0FTHO7JhcP4NA96jX4FFeWw/aSQrRPXhCG9V4XnkpOf7gnCunBdZA5EblSw8mtKvGU9qDM9xU9vqJqlHaB8xYPYk+mHq+HyM5Lv/lV8boDvhnQlVBXIuKIXxPFQStKhq8bGtsyZDjRKVuDV+izEv542cr2Fvjvv0uXlbuwJo8ytNUCcL7hrbdUGRfJKH6gEZnc= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000856, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Currently, /proc/xxx/smaps reports the size of anonymous huge pages for each VMA, but it does not include large pages smaller than PMD size. This patch adds the statistics of anonymous huge pages allocated by mTHP which is smaller than PMD size to AnonHugePages field in smaps. Signed-off-by: Wenchao Hao --- fs/proc/task_mmu.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 38a5a3e9cba2..b655011627d8 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -717,6 +717,12 @@ static void smaps_account(struct mem_size_stats *mss, struct page *page, if (!folio_test_swapbacked(folio) && !dirty && !folio_test_dirty(folio)) mss->lazyfree += size; + + /* + * Count large pages smaller than PMD size to anonymous_thp + */ + if (!compound && PageHead(page) && folio_order(folio)) + mss->anonymous_thp += folio_size(folio); } if (folio_test_ksm(folio))