From patchwork Thu Aug 8 21:34:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13758205 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 45D0AC52D73 for ; Thu, 8 Aug 2024 21:34:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8433F6B0092; Thu, 8 Aug 2024 17:34:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6DF686B0095; Thu, 8 Aug 2024 17:34:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5583E6B0098; Thu, 8 Aug 2024 17:34:43 -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 39E066B0092 for ; Thu, 8 Aug 2024 17:34:43 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id DF3ABA5AB0 for ; Thu, 8 Aug 2024 21:34:42 +0000 (UTC) X-FDA: 82430382804.10.CC7DACC Received: from mail-qv1-f44.google.com (mail-qv1-f44.google.com [209.85.219.44]) by imf13.hostedemail.com (Postfix) with ESMTP id 2B2BA2000B for ; Thu, 8 Aug 2024 21:34:40 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=PkhhTpYY; dmarc=pass (policy=none) header.from=soleen.com; spf=pass (imf13.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.44 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723152808; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=2Zfyh9sb1bnT5AOZDmCrIADGqpbj2HcF73SygbadHf0=; b=kHrcphK12rIXJ1RI3dq7STUnh+g/KAYEiPFV0zhDo8ECIUWDabND4ATLanRFPHhJy0R2eU EcUMsZscTU36R3QfFc0tb4Gv14LPXugku7JPzZm5Quhf6yaZ1U3mySsO91lFhikh2OEd2Q Z9sg1eF3lDCPJI6JwMS0Ulo3xUXGUu8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723152808; a=rsa-sha256; cv=none; b=IZvOr53vI4iLW1iEnUNzoRFKNPaqNe0j8GfEuANC7EOtB+9uqc8euzeIAkjXgN7s49oS8Q FxHv4WPHjKSpF+P1EKB+W2/gCzmpe3iAXILECMY/BDLFNHU6yn7dLeXGq2/psXvG5Bl8Z3 uWu/qg20A33PCd4kkPIy4xxGbylIx7U= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=PkhhTpYY; dmarc=pass (policy=none) header.from=soleen.com; spf=pass (imf13.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.44 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com Received: by mail-qv1-f44.google.com with SMTP id 6a1803df08f44-6bb987d3a98so8027606d6.1 for ; Thu, 08 Aug 2024 14:34:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen-com.20230601.gappssmtp.com; s=20230601; t=1723152880; x=1723757680; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=2Zfyh9sb1bnT5AOZDmCrIADGqpbj2HcF73SygbadHf0=; b=PkhhTpYYomC0wCJdnX6+Vdt8fyVz1ZQI6WJJgXRHG4xZsowQBYTvwU+h2whbWQuDdM vdLudsWUQu+kJx6YeJLHR3LlOTVFAX3Gg4ezc0QjD6o3yW3ukXQDVYBS9HP4/DdrGljc t/SUFJ0OnXyR2PxBLRxctiATUrDM08EpCJYZbCoZd5srnT57u4xyU/011lCN2pU5iPpI 8LdgiXYus5cHlATT9fGwCVppcr2VrSSBHEo53uWZDFfSmrLiPT5Wr0jxa5Y20qtY8hMF 3TGzc+sYG6rlxJgUtDFOWg2337+WiGz8HwMQIeMJn2mnlvNRbieNC5D93aKOO0cpIHpZ Mdbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723152880; x=1723757680; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2Zfyh9sb1bnT5AOZDmCrIADGqpbj2HcF73SygbadHf0=; b=Ezsqyg7xtLlDKwSnd62tbmsHeDfnn5ZI9wnuvOsPiAuPGHYikkhrlsWIyNRfWRMblD N/xnG8iqu6AXYyFighQnEnUZj8rR4acOm1RLbihPU0xAA+8vAC8Kx1dp/y5V0WZUvG1I ENUhcF43ytXW1hgHjWjjrolGZIchcy5/Yy90wCwm7SsKpb2JTKFaNU9A3WMpkbxyk4qW ueUmEasR0s/nNzgGU0p5EGlSoBDx+avOQsvITTrqbJJjS/HldfsJ4FUX+8WUfyq8Z+ge MHABjk6XD8gPWx3bHbUAHjHHqxoAhzpb4quyyU3o2rM9uvaP/Ukn4D9d8/YfMtzwjltb +9UQ== X-Forwarded-Encrypted: i=1; AJvYcCVuUR5Epv+UEKtvx8nlyHaIWeZBvk34IvBjGFt5NJmMYIyFB34dyEDWD2M1dhlC2iP6L6BCdKvGRnxjv5xBo2aDIHY= X-Gm-Message-State: AOJu0YzdhEzTP3nmLJN57ZUPnHdM4WLtDABgT3vHfzT7DXMCz5mcPw+B El8ahgrRE2CL8iF9R2vwcu/xjQs659RAJC8TIn+RnMZ6NkQetCNbftfGxv0CrIU= X-Google-Smtp-Source: AGHT+IEYrhxVpzTUFHMNv2JCMahxEtnVaIB4zBU/Fd+nkSIIYgPtSTnsyB+XCR6jRJ7P++5L69WPeQ== X-Received: by 2002:a05:6214:2b99:b0:6b7:a87b:e9b9 with SMTP id 6a1803df08f44-6bd6bda461fmr32485766d6.48.1723152880168; Thu, 08 Aug 2024 14:34:40 -0700 (PDT) Received: from soleen.c.googlers.com.com (118.239.150.34.bc.googleusercontent.com. [34.150.239.118]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6bb9c762bd1sm70205026d6.29.2024.08.08.14.34.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 14:34:39 -0700 (PDT) From: Pasha Tatashin To: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-cxl@vger.kernel.org, cerasuolodomenico@gmail.com, hannes@cmpxchg.org, j.granados@samsung.com, lizhijian@fujitsu.com, muchun.song@linux.dev, nphamcs@gmail.com, pasha.tatashin@soleen.com, rientjes@google.com, rppt@kernel.org, souravpanda@google.com, vbabka@suse.cz, willy@infradead.org, dan.j.williams@intel.com, yi.zhang@redhat.com, alison.schofield@intel.com, david@redhat.com, yosryahmed@google.com Subject: [PATCH v4 1/3] mm: don't account memmap on failure Date: Thu, 8 Aug 2024 21:34:34 +0000 Message-ID: <20240808213437.682006-2-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog In-Reply-To: <20240808213437.682006-1-pasha.tatashin@soleen.com> References: <20240808213437.682006-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 2B2BA2000B X-Stat-Signature: 7ukgmaonpizwjs8jjtahjz333xtohz13 X-Rspam-User: X-HE-Tag: 1723152880-203032 X-HE-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ZCR4gn+Vs+RtcCnniD2gWmpVug+vc4y7nwepxDaPrGtO/KgqGY3MvDjNgcQjNhTuO9enQizdfjdBVVMgl3F87fG/Rq2WfgcByA2+IEzWN31H2ePtoHrCqW06cwz99Z2doOAVAl0aG4dUxsbSbeJArH+eIGP/dXNHpJcBo9dQbxxNqh3o5lvgy05Kx5Nmd1ZNAyQ+UYcQ2UY0gGOYp863ERaH/mFa+5CdPGE6B+7wNjAoYHJ6CD5iIj3bBumskQfWgfRqtIV/66uCV6d+HPmJQ+4e45U8cC8Ot/PYj7Bk6lCVkuCo6U6H+D1JYTdgtQk3SwTuEzpU2F2yEWpT0oR6QuA== 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: When we fail to allocate the mmemmap in alloc_vmemmap_page_list(), do not account any already-allocated pages: we're going to free all them before we return from the function. Fixes: 15995a352474 ("mm: report per-page metadata information") Signed-off-by: Pasha Tatashin Reviewed-by: Fan Ni Reviewed-by: Yosry Ahmed Acked-by: David Hildenbrand --- mm/hugetlb_vmemmap.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c index 829112b0a914..4f51e0596197 100644 --- a/mm/hugetlb_vmemmap.c +++ b/mm/hugetlb_vmemmap.c @@ -392,13 +392,10 @@ static int alloc_vmemmap_page_list(unsigned long start, unsigned long end, for (i = 0; i < nr_pages; i++) { page = alloc_pages_node(nid, gfp_mask, 0); - if (!page) { - mod_node_page_state(NODE_DATA(nid), NR_MEMMAP, i); + if (!page) goto out; - } list_add(&page->lru, list); } - mod_node_page_state(NODE_DATA(nid), NR_MEMMAP, nr_pages); return 0; From patchwork Thu Aug 8 21:34:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13758206 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 309B3C52D7B for ; Thu, 8 Aug 2024 21:34:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6BBF06B0095; Thu, 8 Aug 2024 17:34:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 645336B0098; Thu, 8 Aug 2024 17:34:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4BE3D6B009A; Thu, 8 Aug 2024 17:34:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 2FE106B0095 for ; Thu, 8 Aug 2024 17:34:44 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id B6E2D40155 for ; Thu, 8 Aug 2024 21:34:43 +0000 (UTC) X-FDA: 82430382846.29.531EAA7 Received: from mail-ua1-f54.google.com (mail-ua1-f54.google.com [209.85.222.54]) by imf28.hostedemail.com (Postfix) with ESMTP id F2A08C000A for ; Thu, 8 Aug 2024 21:34:41 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b="gnIvU/Vq"; spf=pass (imf28.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.54 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=pass (policy=none) header.from=soleen.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723152816; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=+YmoLJUzKwh05YDZkUnFH4Q03LnbmDmhfqr83K75cyk=; b=661Szh9dpTT4Bt0dK6cI5heRA6oel3DhCSVm8vSPyGw4XxkIcT87r2T0WMK5Mp5IuCR/8j R/2TauMocMhWb1dDrwKEosvXjQrP8v0AOoXlVGdA7Lun3lklKicOWt9OhuCNSGWIcu7oSd +GSOGeYndiC/NwEKD9Lw0lSjdlcMz4c= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723152816; a=rsa-sha256; cv=none; b=5cN0jQUMXzRfF7UKMX3kj6KnYjo10PqBS30bU43NAxwkG4N6e+8jN96NJP0YZvh601jptc w7X0odd8Ur6wIo0Zz5OHUbvSCJEx05dkdgH5ym4CCwYsd9uSiWyVaSPFCr96GEYuv25ylN 8P/wDrzWDjBXM4McJjpL34FxmjGzthY= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b="gnIvU/Vq"; spf=pass (imf28.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.54 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=pass (policy=none) header.from=soleen.com Received: by mail-ua1-f54.google.com with SMTP id a1e0cc1a2514c-831a5b7d250so494210241.3 for ; Thu, 08 Aug 2024 14:34:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen-com.20230601.gappssmtp.com; s=20230601; t=1723152881; x=1723757681; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=+YmoLJUzKwh05YDZkUnFH4Q03LnbmDmhfqr83K75cyk=; b=gnIvU/Vq0kgZuJimynIF6ky9WjwUxv6P3msvCjlyw3bqc+w96a7nVXyZYBxIfUStmj +LcRO2USoNHXQbxg6ru2F8dbfMvgJp+ASPE14WIzx8f2a8pFBNbe5/NL5gkWNQGfnp/1 ssvGVtp27InGkjMhI57xP9GPhaHbWcJKBIp4OUQFYWk1kJjfBMeVqJ55/Lmk1y1Rx5MY Dc7A0RpB7nnRUTxlbWSDMqBN7x+lRK/B6sUDOyx2nuK1eQikvgDBZTJ/FoG9nTO4w9TN PkH5wGc+n4CoCUqvx28BvjG9Vyg3yUFa50WVm7l/Gbp3bTBm5WfyO5SICVeMahgbDh5V 33cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723152881; x=1723757681; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+YmoLJUzKwh05YDZkUnFH4Q03LnbmDmhfqr83K75cyk=; b=jxvraQvQqGq/G2SGwqFmgCr5BjBEQ8mH3RGO6tFXj1XvmCWcwrGWr3SYVOC5ZqIKLy OkXKBmXNKF/dMlnzxgm+mDrs6udXVOYO5Tib4w64cvPc2LwtQE5pR4bbkt3nCIDtFah2 KokJcoCuOiCiuKTTHoAc7UBvev/H9bIX3YTT72b2oArzJ4yD8mSfNrP9IBlBLAWLKaW2 q9uAGC3oZZcchQPXIspMMQcS+x3ndx4w32mHSvIhE3jPpa3GQ1mbkBpR+ywXXw97Epwd Dl1+vp2Ly/yaPq7eZBgWuW/NSmslcACdQ2bivlyVZkSzZ+Dg1hGOtDzkyt2cinSr6Xd8 DDkA== X-Forwarded-Encrypted: i=1; AJvYcCVTlSmVC1zS9LJTlQAQ+t3BLo6ia2q0nOl/cK+9z+oV4NKcYU/bfcpb1byEDQ0p5Uzr/d1vBViDp1kOriBt3kUBmVk= X-Gm-Message-State: AOJu0YyqSnFOGjKJOifcOIQ34KhI/I7qH25+95dq0/LxajS0TaGfQz9U 4OzEQqusq1FezBcemvWnMk2LXUyl86/P4OiYHUEBb1nmGQib1NyO6YhzlXWpogU= X-Google-Smtp-Source: AGHT+IE4Qv1sn/qov17GIXusF8ykKagazq0LzzEpnGG7EXiIsWLtpNSrGNRu3rLDOXEBkRSnwDDAyA== X-Received: by 2002:a05:6102:2acb:b0:492:ab05:8d6e with SMTP id ada2fe7eead31-495c5b38e89mr3764112137.3.1723152880951; Thu, 08 Aug 2024 14:34:40 -0700 (PDT) Received: from soleen.c.googlers.com.com (118.239.150.34.bc.googleusercontent.com. [34.150.239.118]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6bb9c762bd1sm70205026d6.29.2024.08.08.14.34.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 14:34:40 -0700 (PDT) From: Pasha Tatashin To: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-cxl@vger.kernel.org, cerasuolodomenico@gmail.com, hannes@cmpxchg.org, j.granados@samsung.com, lizhijian@fujitsu.com, muchun.song@linux.dev, nphamcs@gmail.com, pasha.tatashin@soleen.com, rientjes@google.com, rppt@kernel.org, souravpanda@google.com, vbabka@suse.cz, willy@infradead.org, dan.j.williams@intel.com, yi.zhang@redhat.com, alison.schofield@intel.com, david@redhat.com, yosryahmed@google.com Subject: [PATCH v4 2/3] mm: add system wide stats items category Date: Thu, 8 Aug 2024 21:34:35 +0000 Message-ID: <20240808213437.682006-3-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog In-Reply-To: <20240808213437.682006-1-pasha.tatashin@soleen.com> References: <20240808213437.682006-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: F2A08C000A X-Stat-Signature: ibswu3ca979kyr539frknhd91cg9cect X-HE-Tag: 1723152881-391378 X-HE-Meta: U2FsdGVkX1+hq6oHKQQBC5KofwSPrjdEvNy+bENRenLIdf57oRzuGj3y692QonJlOHXSpV5i+5z0Pt/sGKGomX5+4VqiDvcT3roPuLckWxgKFy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tYwDaNVz2XXOk7wqw/SSxq0P86/4o5zcWF72hxHH4fegeVgUP7d5ne1T2L6nSDwbY/Q0TFfrFPPS3yGrFs0OysTzyqZlvsk97pEOcnLB4SecEmsYD7mH0nauZK5cwpi9tWvuAgV/VwWdILhHQbDJBTEhgs5JwbVq9NlEtY3lQDAWKGTkA7ZRp3pEVcy6uhM4cOnN6WITjCv0= 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: /proc/vmstat contains events and stats, events can only grow, but stats can grow and shrink. vmstat has the following: ------------------------- NR_VM_ZONE_STAT_ITEMS: per-zone stats NR_VM_NUMA_EVENT_ITEMS: per-numa events NR_VM_NODE_STAT_ITEMS: per-numa stats NR_VM_WRITEBACK_STAT_ITEMS: system-wide background-writeback and dirty-throttling tresholds. NR_VM_EVENT_ITEMS: system-wide events ------------------------- Rename NR_VM_WRITEBACK_STAT_ITEMS to NR_VM_STAT_ITEMS, to track the system-wide stats, we are going to add per-page metadata stats to this category in the next patch. Also delete unused writeback_stat_name() function. Suggested-by: Yosry Ahmed Signed-off-by: Pasha Tatashin Acked-by: David Hildenbrand --- include/linux/vmstat.h | 15 ++++----------- mm/vmstat.c | 6 +++--- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h index 23cd17942036..9ab4fa5e09b5 100644 --- a/include/linux/vmstat.h +++ b/include/linux/vmstat.h @@ -34,10 +34,11 @@ struct reclaim_stat { unsigned nr_lazyfree_fail; }; -enum writeback_stat_item { +/* Stat data for system wide items */ +enum vm_stat_item { NR_DIRTY_THRESHOLD, NR_DIRTY_BG_THRESHOLD, - NR_VM_WRITEBACK_STAT_ITEMS, + NR_VM_STAT_ITEMS, }; #ifdef CONFIG_VM_EVENT_COUNTERS @@ -514,21 +515,13 @@ static inline const char *lru_list_name(enum lru_list lru) return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_" } -static inline const char *writeback_stat_name(enum writeback_stat_item item) -{ - return vmstat_text[NR_VM_ZONE_STAT_ITEMS + - NR_VM_NUMA_EVENT_ITEMS + - NR_VM_NODE_STAT_ITEMS + - item]; -} - #if defined(CONFIG_VM_EVENT_COUNTERS) || defined(CONFIG_MEMCG) static inline const char *vm_event_name(enum vm_event_item item) { return vmstat_text[NR_VM_ZONE_STAT_ITEMS + NR_VM_NUMA_EVENT_ITEMS + NR_VM_NODE_STAT_ITEMS + - NR_VM_WRITEBACK_STAT_ITEMS + + NR_VM_STAT_ITEMS + item]; } #endif /* CONFIG_VM_EVENT_COUNTERS || CONFIG_MEMCG */ diff --git a/mm/vmstat.c b/mm/vmstat.c index 04a1cb6cc636..6f8aa4766f16 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1257,7 +1257,7 @@ const char * const vmstat_text[] = { "pgdemote_khugepaged", "nr_memmap", "nr_memmap_boot", - /* enum writeback_stat_item counters */ + /* system-wide enum vm_stat_item counters */ "nr_dirty_threshold", "nr_dirty_background_threshold", @@ -1790,7 +1790,7 @@ static const struct seq_operations zoneinfo_op = { #define NR_VMSTAT_ITEMS (NR_VM_ZONE_STAT_ITEMS + \ NR_VM_NUMA_EVENT_ITEMS + \ NR_VM_NODE_STAT_ITEMS + \ - NR_VM_WRITEBACK_STAT_ITEMS + \ + NR_VM_STAT_ITEMS + \ (IS_ENABLED(CONFIG_VM_EVENT_COUNTERS) ? \ NR_VM_EVENT_ITEMS : 0)) @@ -1827,7 +1827,7 @@ static void *vmstat_start(struct seq_file *m, loff_t *pos) global_dirty_limits(v + NR_DIRTY_BG_THRESHOLD, v + NR_DIRTY_THRESHOLD); - v += NR_VM_WRITEBACK_STAT_ITEMS; + v += NR_VM_STAT_ITEMS; #ifdef CONFIG_VM_EVENT_COUNTERS all_vm_events(v); From patchwork Thu Aug 8 21:34:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13758207 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 A34B5C3DA4A for ; Thu, 8 Aug 2024 21:34:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8436D6B0098; Thu, 8 Aug 2024 17:34:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 77C746B009C; Thu, 8 Aug 2024 17:34:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 61D456B009E; Thu, 8 Aug 2024 17:34:45 -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 2AE2A6B0098 for ; Thu, 8 Aug 2024 17:34:45 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id D40621601D7 for ; Thu, 8 Aug 2024 21:34:44 +0000 (UTC) X-FDA: 82430382888.11.60ED63A Received: from mail-qv1-f46.google.com (mail-qv1-f46.google.com [209.85.219.46]) by imf08.hostedemail.com (Postfix) with ESMTP id 1726E16000E for ; Thu, 8 Aug 2024 21:34:42 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=av3BgFtU; spf=pass (imf08.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.46 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=pass (policy=none) header.from=soleen.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723152818; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=kWOlhfAfce+9LYenfYKmrvC1/DBShQ3awKUGjH/tW0o=; b=mVey7LrxLsrs10mCdA/untvkIsX2Z0ePRRghYS4oatzHJLZZiBnN7WdwOxs79xwOhv58UZ t7MfW5oBMclPKWZIUDQYbKxzkNGjJoid44gx4UYpxZgqsEYmJ7FI4SzEhL3H0yJoqt2sGx K1QuZaOakNHV+LBWPU0yAkh5q62fy0k= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723152818; a=rsa-sha256; cv=none; b=iWCZAyUrVuaC0WzoSdH0VH9wAOMXCPkVmQAOlpsupHasfqr5u9JN9FcBemwQHczlX6ZcGm UhwnAW+0GiK86bzZsQB/UTbAAB1oSCuZPJCbTYMU1jv2AWPHOwaCPmw71BxzXQixVLit2y HY5iBcULoHKnSb4U7gPDkqkbt6S7c7E= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=av3BgFtU; spf=pass (imf08.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.219.46 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=pass (policy=none) header.from=soleen.com Received: by mail-qv1-f46.google.com with SMTP id 6a1803df08f44-6b7aed340daso8653626d6.3 for ; Thu, 08 Aug 2024 14:34:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen-com.20230601.gappssmtp.com; s=20230601; t=1723152882; x=1723757682; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=kWOlhfAfce+9LYenfYKmrvC1/DBShQ3awKUGjH/tW0o=; b=av3BgFtU58OIUB4gRjAE+Rq8kfhZ7AlcMzKmveHyKxPyDWk0CNebPeghXZ34yx822/ 5M+ZIjJuCKjrynd02/9jkOIZ53zubvZmTb5vcZA3YlfRlhJ6SJR+afvrvwT9BPcJwedf xmVnrtT6pUGvl/mUYikVFBkafnHK72ESodvWFGhT0g92oqDATIAt/4a1sG/rKYG1Hu1W U9pRLzSY51jtiOYJ4MF+Jf2GJxE3vIbVfDw6OJUiN82QupmG/w8cJrhhe1+9Dl/MAfU4 7v6XPpE+s3up4VEB+vERCBPkqDn0cb3vTkcWNYDYzQa/C5UWY1lHx625on57S6xBPQ1x We1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723152882; x=1723757682; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kWOlhfAfce+9LYenfYKmrvC1/DBShQ3awKUGjH/tW0o=; b=LE3LCsI++9XxBL8s1SLRKQLsVRraxR8zP3flzNr3VSv6InJgIQOkhl1AUi7ZIm/PRL pWfbknCZAA0G1D3CNLiNHCAh+QU6IRuBMT93xqhbkSYxL2pps3j20goDQtrj5ln/SW3c vWzblCEH/78O6YGMyk6yErXwznANOIuZWDV+vbSO8uixRpO9MGKeD8qa1F0FPA111uYH Yb6vWJiKKEul2kWigK38gmILXOpOnSSlsc7K83xjUhQKnTNVlC5C2VTUltqxFXf9jDiV ou065zfCHKAP0x7L+LoeXwZePNNb1C2kocdQjxp48zT2Oi8gtDlpH9NHWNVPHqofn+Ki G/HA== X-Forwarded-Encrypted: i=1; AJvYcCV1DYvTTUxo+Ya9BdwQnVHANctWyQp2HiMNkMW2jDZQ455CWq2dADvozMVLyu9XNa2DpTKA5SktGN9w4LrIw1VDQmE= X-Gm-Message-State: AOJu0Yxu/g+G25aobt9omOZ32mzjjNADN4J8IQp9p2vySSj/xz0Tx0OW Of5EElhfTLlFI8Nq3i+uSJZA8TfNaBjPJL1QTBZbdnf9K9EUH6cKIOL1yfaLt7E= X-Google-Smtp-Source: AGHT+IFiuKAoaUv/Ru7WO2pjfXBkX2yVU/zNkZyXTPPVKMhOqrJp0xprvwJzwpRKdYdERrxf3hNSpg== X-Received: by 2002:a05:6214:2f05:b0:6b5:e60c:76dc with SMTP id 6a1803df08f44-6bd6bce96famr48503556d6.19.1723152882071; Thu, 08 Aug 2024 14:34:42 -0700 (PDT) Received: from soleen.c.googlers.com.com (118.239.150.34.bc.googleusercontent.com. [34.150.239.118]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6bb9c762bd1sm70205026d6.29.2024.08.08.14.34.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 14:34:41 -0700 (PDT) From: Pasha Tatashin To: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-cxl@vger.kernel.org, cerasuolodomenico@gmail.com, hannes@cmpxchg.org, j.granados@samsung.com, lizhijian@fujitsu.com, muchun.song@linux.dev, nphamcs@gmail.com, pasha.tatashin@soleen.com, rientjes@google.com, rppt@kernel.org, souravpanda@google.com, vbabka@suse.cz, willy@infradead.org, dan.j.williams@intel.com, yi.zhang@redhat.com, alison.schofield@intel.com, david@redhat.com, yosryahmed@google.com Subject: [PATCH v4 3/3] mm: don't account memmap per-node Date: Thu, 8 Aug 2024 21:34:36 +0000 Message-ID: <20240808213437.682006-4-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog In-Reply-To: <20240808213437.682006-1-pasha.tatashin@soleen.com> References: <20240808213437.682006-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 1726E16000E X-Stat-Signature: 6qefanuitgxgkfx9hkkdeijux5cwzdo5 X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1723152882-609711 X-HE-Meta: U2FsdGVkX18yWvnP2cB2HjjvBkleDS4BTYag85J8//SfK5TNJOnhRLQWPtO91pP0pJvqDLtj8fCihkHwR0mtAd2z5uSEOUNEr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KBgQ595D20VVLXNtbCZocC8gTe1N/CKl7IVN4rsJsc+yGpFuwBGWE7ISyitVNbORHRHp5H5cvxCV9qBscHpo5xz83OJcyBUJ3QHLpoPkt5eA7h/R5Vbeck4bwB3JLqT8FSjmUy5w3+gKXZe31D3IymOTe4r4WEwk2XT0gir/QlJjTlCL7K8SNeJHH1/9iR3kFiHbnpwG1xUc2F7ERc6LB3cRWP9mv7u0TL5fHOA5bAEBLuCcIXgibjiXpjqFPF5p0yrJlx0D5P40FFmeiRgX3kTwNJ6YVcyMaRKIQ== 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: Fix invalid access to pgdat during hot-remove operation: ndctl users reported a GPF when trying to destroy a namespace: $ ndctl destroy-namespace all -r all -f Segmentation fault dmesg: Oops: general protection fault, probably for non-canonical address 0xdffffc0000005650: 0000 [#1] PREEMPT SMP KASAN PTI KASAN: probably user-memory-access in range [0x000000000002b280-0x000000000002b287] CPU: 26 UID: 0 PID: 1868 Comm: ndctl Not tainted 6.11.0-rc1 #1 Hardware name: Dell Inc. PowerEdge R640/08HT8T, BIOS 2.20.1 09/13/2023 RIP: 0010:mod_node_page_state+0x2a/0x110 cxl-test users report a GPF when trying to unload the test module: $ modrpobe -r cxl-test dmesg BUG: unable to handle page fault for address: 0000000000004200 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 0 P4D 0 Oops: Oops: 0000 [#1] PREEMPT SMP PTI CPU: 0 UID: 0 PID: 1076 Comm: modprobe Tainted: G O N 6.11.0-rc1 #197 Tainted: [O]=OOT_MODULE, [N]=TEST Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/15 RIP: 0010:mod_node_page_state+0x6/0x90 Currently, when memory is hot-plugged or hot-removed the accounting is done based on the assumption that memmap is allocated from the same node as the hot-plugged/hot-removed memory, which is not always the case. In addition, there are challenges with keeping the node id of the memory that is being remove to the time when memmap accounting is actually performed: since this is done after remove_pfn_range_from_zone(), and also after remove_memory_block_devices(). Meaning that we cannot use pgdat nor walking though memblocks to get the nid. Given all of that, account the memmap overhead system wide instead. For this we are going to be using global atomic counters, but given that memmap size is rarely modified, and normally is only modified either during early boot when there is only one CPU, or under a hotplug global mutex lock, therefore there is no need for per-cpu optimizations. Also, while we are here rename nr_memmap to nr_memmap_pages, and nr_memmap_boot to nr_memmap_boot_pages to be self explanatory that the units are in page count. Reported-by: Yi Zhang Closes: https://lore.kernel.org/linux-cxl/CAHj4cs9Ax1=CoJkgBGP_+sNu6-6=6v=_L-ZBZY0bVLD3wUWZQg@mail.gmail.com Reported-by: Alison Schofield Closes: https://lore.kernel.org/linux-mm/Zq0tPd2h6alFz8XF@aschofie-mobl2/#t Fixes: 15995a352474 ("mm: report per-page metadata information") Signed-off-by: Pasha Tatashin Tested-by: Dan Williams Acked-by: David Hildenbrand --- include/linux/mmzone.h | 2 -- include/linux/vmstat.h | 7 ++++--- mm/hugetlb_vmemmap.c | 8 ++++---- mm/mm_init.c | 3 +-- mm/page_alloc.c | 1 - mm/page_ext.c | 18 ++++------------- mm/sparse-vmemmap.c | 11 ++++------- mm/sparse.c | 5 ++--- mm/vmstat.c | 45 ++++++++++++++++++++---------------------- 9 files changed, 40 insertions(+), 60 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 41458892bc8a..1dc6248feb83 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -220,8 +220,6 @@ enum node_stat_item { PGDEMOTE_KSWAPD, PGDEMOTE_DIRECT, PGDEMOTE_KHUGEPAGED, - NR_MEMMAP, /* page metadata allocated through buddy allocator */ - NR_MEMMAP_BOOT, /* page metadata allocated through boot allocator */ NR_VM_NODE_STAT_ITEMS }; diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h index 9ab4fa5e09b5..596c050ed492 100644 --- a/include/linux/vmstat.h +++ b/include/linux/vmstat.h @@ -38,6 +38,8 @@ struct reclaim_stat { enum vm_stat_item { NR_DIRTY_THRESHOLD, NR_DIRTY_BG_THRESHOLD, + NR_MEMMAP, /* page metadata allocated through buddy allocator */ + NR_MEMMAP_BOOT, /* page metadata allocated through boot allocator */ NR_VM_STAT_ITEMS, }; @@ -618,7 +620,6 @@ static inline void lruvec_stat_sub_folio(struct folio *folio, lruvec_stat_mod_folio(folio, idx, -folio_nr_pages(folio)); } -void __meminit mod_node_early_perpage_metadata(int nid, long delta); -void __meminit store_early_perpage_metadata(void); - +void mod_memmap_boot(long delta); +void mod_memmap(long delta); #endif /* _LINUX_VMSTAT_H */ diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c index 4f51e0596197..60a5faa1f341 100644 --- a/mm/hugetlb_vmemmap.c +++ b/mm/hugetlb_vmemmap.c @@ -185,11 +185,11 @@ static int vmemmap_remap_range(unsigned long start, unsigned long end, static inline void free_vmemmap_page(struct page *page) { if (PageReserved(page)) { + mod_memmap_boot(-1); free_bootmem_page(page); - mod_node_page_state(page_pgdat(page), NR_MEMMAP_BOOT, -1); } else { + mod_memmap(-1); __free_page(page); - mod_node_page_state(page_pgdat(page), NR_MEMMAP, -1); } } @@ -341,7 +341,7 @@ static int vmemmap_remap_free(unsigned long start, unsigned long end, copy_page(page_to_virt(walk.reuse_page), (void *)walk.reuse_addr); list_add(&walk.reuse_page->lru, vmemmap_pages); - mod_node_page_state(NODE_DATA(nid), NR_MEMMAP, 1); + mod_memmap(1); } /* @@ -396,7 +396,7 @@ static int alloc_vmemmap_page_list(unsigned long start, unsigned long end, goto out; list_add(&page->lru, list); } - mod_node_page_state(NODE_DATA(nid), NR_MEMMAP, nr_pages); + mod_memmap(nr_pages); return 0; out: diff --git a/mm/mm_init.c b/mm/mm_init.c index 75c3bd42799b..29677274e74e 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -1623,8 +1623,7 @@ static void __init alloc_node_mem_map(struct pglist_data *pgdat) panic("Failed to allocate %ld bytes for node %d memory map\n", size, pgdat->node_id); pgdat->node_mem_map = map + offset; - mod_node_early_perpage_metadata(pgdat->node_id, - DIV_ROUND_UP(size, PAGE_SIZE)); + mod_memmap_boot(DIV_ROUND_UP(size, PAGE_SIZE)); pr_debug("%s: node %d, pgdat %08lx, node_mem_map %08lx\n", __func__, pgdat->node_id, (unsigned long)pgdat, (unsigned long)pgdat->node_mem_map); diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 28f80daf5c04..875d76e8684a 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5755,7 +5755,6 @@ void __init setup_per_cpu_pageset(void) for_each_online_pgdat(pgdat) pgdat->per_cpu_nodestats = alloc_percpu(struct per_cpu_nodestat); - store_early_perpage_metadata(); } __meminit void zone_pcp_init(struct zone *zone) diff --git a/mm/page_ext.c b/mm/page_ext.c index c191e490c401..c9419f6abfa0 100644 --- a/mm/page_ext.c +++ b/mm/page_ext.c @@ -214,8 +214,7 @@ static int __init alloc_node_page_ext(int nid) return -ENOMEM; NODE_DATA(nid)->node_page_ext = base; total_usage += table_size; - mod_node_page_state(NODE_DATA(nid), NR_MEMMAP_BOOT, - DIV_ROUND_UP(table_size, PAGE_SIZE)); + mod_memmap_boot(DIV_ROUND_UP(table_size, PAGE_SIZE)); return 0; } @@ -275,10 +274,8 @@ static void *__meminit alloc_page_ext(size_t size, int nid) else addr = vzalloc_node(size, nid); - if (addr) { - mod_node_page_state(NODE_DATA(nid), NR_MEMMAP, - DIV_ROUND_UP(size, PAGE_SIZE)); - } + if (addr) + mod_memmap(DIV_ROUND_UP(size, PAGE_SIZE)); return addr; } @@ -323,25 +320,18 @@ static void free_page_ext(void *addr) { size_t table_size; struct page *page; - struct pglist_data *pgdat; table_size = page_ext_size * PAGES_PER_SECTION; + mod_memmap(-1L * (DIV_ROUND_UP(table_size, PAGE_SIZE))); if (is_vmalloc_addr(addr)) { - page = vmalloc_to_page(addr); - pgdat = page_pgdat(page); vfree(addr); } else { page = virt_to_page(addr); - pgdat = page_pgdat(page); BUG_ON(PageReserved(page)); kmemleak_free(addr); free_pages_exact(addr, table_size); } - - mod_node_page_state(pgdat, NR_MEMMAP, - -1L * (DIV_ROUND_UP(table_size, PAGE_SIZE))); - } static void __free_page_ext(unsigned long pfn) diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c index 1dda6c53370b..307f6fe83598 100644 --- a/mm/sparse-vmemmap.c +++ b/mm/sparse-vmemmap.c @@ -469,13 +469,10 @@ struct page * __meminit __populate_section_memmap(unsigned long pfn, if (r < 0) return NULL; - if (system_state == SYSTEM_BOOTING) { - mod_node_early_perpage_metadata(nid, DIV_ROUND_UP(end - start, - PAGE_SIZE)); - } else { - mod_node_page_state(NODE_DATA(nid), NR_MEMMAP, - DIV_ROUND_UP(end - start, PAGE_SIZE)); - } + if (system_state == SYSTEM_BOOTING) + mod_memmap_boot(DIV_ROUND_UP(end - start, PAGE_SIZE)); + else + mod_memmap(DIV_ROUND_UP(end - start, PAGE_SIZE)); return pfn_to_page(pfn); } diff --git a/mm/sparse.c b/mm/sparse.c index e4b830091d13..9cc80ba1f7c1 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -463,7 +463,7 @@ static void __init sparse_buffer_init(unsigned long size, int nid) sparsemap_buf = memmap_alloc(size, section_map_size(), addr, nid, true); sparsemap_buf_end = sparsemap_buf + size; #ifndef CONFIG_SPARSEMEM_VMEMMAP - mod_node_early_perpage_metadata(nid, DIV_ROUND_UP(size, PAGE_SIZE)); + mod_memmap_boot(DIV_ROUND_UP(size, PAGE_SIZE)); #endif } @@ -643,8 +643,7 @@ static void depopulate_section_memmap(unsigned long pfn, unsigned long nr_pages, unsigned long start = (unsigned long) pfn_to_page(pfn); unsigned long end = start + nr_pages * sizeof(struct page); - mod_node_page_state(page_pgdat(pfn_to_page(pfn)), NR_MEMMAP, - -1L * (DIV_ROUND_UP(end - start, PAGE_SIZE))); + mod_memmap(-1L * (DIV_ROUND_UP(end - start, PAGE_SIZE))); vmemmap_free(start, end, altmap); } static void free_map_bootmem(struct page *memmap) diff --git a/mm/vmstat.c b/mm/vmstat.c index 6f8aa4766f16..ad82c1bf0e63 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1033,6 +1033,23 @@ unsigned long node_page_state(struct pglist_data *pgdat, } #endif +/* + * Count number of pages "struct page" and "struct page_ext" consume. + * nr_memmap_boot: # of pages allocated by boot allocator & not part of MemTotal + * nr_memmap: # of pages that were allocated by buddy allocator + */ +static atomic_long_t nr_memmap_boot, nr_memmap; + +void mod_memmap_boot(long delta) +{ + atomic_long_add(delta, &nr_memmap_boot); +} + +void mod_memmap(long delta) +{ + atomic_long_add(delta, &nr_memmap); +} + #ifdef CONFIG_COMPACTION struct contig_page_info { @@ -1255,11 +1272,11 @@ const char * const vmstat_text[] = { "pgdemote_kswapd", "pgdemote_direct", "pgdemote_khugepaged", - "nr_memmap", - "nr_memmap_boot", /* system-wide enum vm_stat_item counters */ "nr_dirty_threshold", "nr_dirty_background_threshold", + "nr_memmap_pages", + "nr_memmap_boot_pages", #if defined(CONFIG_VM_EVENT_COUNTERS) || defined(CONFIG_MEMCG) /* enum vm_event_item counters */ @@ -1827,6 +1844,8 @@ static void *vmstat_start(struct seq_file *m, loff_t *pos) global_dirty_limits(v + NR_DIRTY_BG_THRESHOLD, v + NR_DIRTY_THRESHOLD); + v[NR_MEMMAP_BOOT] = atomic_long_read(&nr_memmap_boot); + v[NR_MEMMAP] = atomic_long_read(&nr_memmap); v += NR_VM_STAT_ITEMS; #ifdef CONFIG_VM_EVENT_COUNTERS @@ -2285,25 +2304,3 @@ static int __init extfrag_debug_init(void) module_init(extfrag_debug_init); #endif - -/* - * Page metadata size (struct page and page_ext) in pages - */ -static unsigned long early_perpage_metadata[MAX_NUMNODES] __meminitdata; - -void __meminit mod_node_early_perpage_metadata(int nid, long delta) -{ - early_perpage_metadata[nid] += delta; -} - -void __meminit store_early_perpage_metadata(void) -{ - int nid; - struct pglist_data *pgdat; - - for_each_online_pgdat(pgdat) { - nid = pgdat->node_id; - mod_node_page_state(NODE_DATA(nid), NR_MEMMAP_BOOT, - early_perpage_metadata[nid]); - } -}