From patchwork Fri Aug 9 19:10:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13759156 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 6B1E6C531DA for ; Fri, 9 Aug 2024 19:10:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5A3E16B0092; Fri, 9 Aug 2024 15:10:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 52B7E6B0095; Fri, 9 Aug 2024 15:10:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3A44B6B0098; Fri, 9 Aug 2024 15:10:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 1ED9B6B0092 for ; Fri, 9 Aug 2024 15:10:28 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 9E1EFA13F4 for ; Fri, 9 Aug 2024 19:10:27 +0000 (UTC) X-FDA: 82433648094.21.C09706E Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) by imf14.hostedemail.com (Postfix) with ESMTP id DE6F2100023 for ; Fri, 9 Aug 2024 19:10:25 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=Hvk4qxSQ; spf=pass (imf14.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.182 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=1723230573; 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=fxeU4Jq2TXL16ukpSAmTNaQg3Gap0zA2EvWYWTBfBg0D/n8kICZvkKihKkwApOClfoDgFn vHRa0udZtn6MhXxwRZbvjDuQUksvtgTI2vqHIHju5D7/EgXO5ZB5S+a3duXa6Bxevd7hn3 Exkom9z3V0Sr04qFAyXLsqWXKiwiC7A= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=Hvk4qxSQ; spf=pass (imf14.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.182 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=pass (policy=none) header.from=soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723230573; a=rsa-sha256; cv=none; b=Oh/dFKU+X87xGcRxbtxTmLjzfFa8Zy3/hTJLXzT7V6EKX1XmB4tQg9hAtGm7W9ZhsCw0p1 7mdYZT7GpyrznkEM/PlJ2staLl93yYWnxsRoiWlekFpTBf4NC9A7Ue6FglOKQuSinx/KS9 QEIL3mdLA6c3GKXCEdFJX80Pf9g57GQ= Received: by mail-qk1-f182.google.com with SMTP id af79cd13be357-7a1dcc7bc05so158050485a.0 for ; Fri, 09 Aug 2024 12:10:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen-com.20230601.gappssmtp.com; s=20230601; t=1723230625; x=1723835425; 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=Hvk4qxSQ85WMpL4cV1r9Kkat32rMQGmvATDfE66G1Qts9eVxcZZLpmbuXdYau+BjnV kq1EZKj2xKfjxcdHjdFgAMZwqCSwt28vcs2uk98hd4NITKhcWZ/ByQWkQ83lI97lW+Zu ta7p2u01G7HjFMG1y2ZRypd0VOMooR+wkuvszEK93KUZzdih1zPN+tRoHwAmUWQBJziK xIT2ZGnkAqyP+Cebe19w9ztDJrfrL8aQ9DK1srf3eSKdR+aAhphCHWCSyoPI7SIuXkHs W/V639iCm96Yk4dfdfXAYNy+V71I3z1fUDF1MX7QbEvC0Rvs0Z3s70XxJPlusWilXFb5 n+Eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723230625; x=1723835425; 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=mZyL7tj7xqhRHB6ITWm7jCZTs3hGp98QJEvuwJzcMVu9eo0lOXacEJUonxkzuIj8Mk goQgfgGozXx68qCkAqG3iyDYCH0kESzv72/aYLy1sa7/O1tJwOQAhBm45UD/2SY0bsAd hJAitzhSbtA+LzxENLQWEh2eYpjHKeIc6L77zNZuirpJCh2Vr+5NTRz4NYveiz+QbDO0 QRvD5p8uQWVEMHX/YoVSm4BF4J7zWXzn9bSoGbJ+apaeyuLhaX7SIVMxrZFQahW31rGp 3A3aJBKpul9kgqmk2+spxx034lwzQxRMSBjdHb2+V6A28HgLh6xc0aL4UZWflLQ4Tkso Bq7A== X-Forwarded-Encrypted: i=1; AJvYcCVt9Y1CRmz3K8F6+xAPibM5DxIo6T54DnFABbIM9P59Ekj0PWdfcz6wJLazzMU8G75PpAju52RXPo+Lr4r8kdYPyDI= X-Gm-Message-State: AOJu0YyYvGfy06c1vPyasqVbul/ogDNVBn62MSD4Rvp7/rin+1F8cGFd J8q43TPVOGk8yxvSmTCxzWgOt0mpzVakDSwrYJzpkAZN108Aw5gcJmmHxhzuanC8NmbF4659025 O X-Google-Smtp-Source: AGHT+IEpJ4kA1QWE3b+JfVVjir9Z6DC5086gWvGsdlrOs2CaZZLaGQY0jZT/CHJjcUlLTfdiOhrm+w== X-Received: by 2002:a05:620a:2486:b0:7a1:d9a6:a9af with SMTP id af79cd13be357-7a4c1860cf6mr306443585a.68.1723230624911; Fri, 09 Aug 2024 12:10:24 -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 af79cd13be357-7a4c7df5a55sm5522085a.86.2024.08.09.12.10.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Aug 2024 12:10:24 -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 v5 1/3] mm: don't account memmap on failure Date: Fri, 9 Aug 2024 19:10:18 +0000 Message-ID: <20240809191020.1142142-2-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog In-Reply-To: <20240809191020.1142142-1-pasha.tatashin@soleen.com> References: <20240809191020.1142142-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Stat-Signature: izbjeopw8myz5td9sfqxy3wkso6amf1i X-Rspam-User: X-Rspamd-Queue-Id: DE6F2100023 X-Rspamd-Server: rspam02 X-HE-Tag: 1723230625-256792 X-HE-Me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ZLlw0uBHltS4uq4Ai5JVxOCGDTqQ2kltm/ofD++8QzVU6+WboMX5nxlF6RgrzQcQmnL9IhL9J1mkwege4DfIOM3gwxrDNJKFnmCx1ylUjSIGY3rJ1jSUBSnVJVgJsNJHeI2t14Mui6qFFiGgFQyjB9332cYMaISAn6UwV/eRaUCUYo2sXY0QxU5kGPj/aaYviUJxplbwq6stjf/jimVJg322Skbxed6f0R7VM4WNCz7A3n4sXddGgFV2/SC3H2UUsWiuklke8r3mkzPgOqHTlwBARdnBEiwIhwYfKsMLTRoWTxLzUWGL7FCN5GB2OScArYYjKVfPIHOBtiBI07hcoC2L7hnOXqoyyF/clxCr/CdcOLQ== 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 Reviewed-by: Muchun Song Acked-by: David Rientjes --- 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 Fri Aug 9 19:10:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13759157 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 84B60C3DA4A for ; Fri, 9 Aug 2024 19:10:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 491876B0095; Fri, 9 Aug 2024 15:10:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3A5A56B0098; Fri, 9 Aug 2024 15:10:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1D00D6B009A; Fri, 9 Aug 2024 15:10:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id F2C086B0095 for ; Fri, 9 Aug 2024 15:10:28 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id B86311A13DD for ; Fri, 9 Aug 2024 19:10:28 +0000 (UTC) X-FDA: 82433648136.24.79497DC Received: from mail-qk1-f174.google.com (mail-qk1-f174.google.com [209.85.222.174]) by imf28.hostedemail.com (Postfix) with ESMTP id E17BAC000F for ; Fri, 9 Aug 2024 19:10:26 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=ERGOn3wQ; dmarc=pass (policy=none) header.from=soleen.com; spf=pass (imf28.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.174 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723230573; a=rsa-sha256; cv=none; b=BRtMy4ZJm/aNPVLgt94zSQupFuKSUtwGVXidTobhT0oLP79W4LSrHJKOEbLgHEoKYQfSS8 fwdny4UU/5BHVF+p1UpJpgWLSuBdJ140vI1581Dto+4rntx3Kb0XRyW2Ml8r8jKvu3H3lU NcL2GJADESHlhKOBP59JkypGcXpdnHY= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=ERGOn3wQ; dmarc=pass (policy=none) header.from=soleen.com; spf=pass (imf28.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.174 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=1723230573; 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=gDvms9T6MxTADOWyeqlGsrri9pz592+CY2RkeRJgrNo=; b=nk1Xa5gdnOto1KJClzJQnqcCBJ/T05jHQiFDdX2DScBQRU3SzGkkg48sVGc/x+p6WCro89 DZpUt9DiQf0zVHo0e1modGJqp7ixC5Kar0+/uQg3VgcZN99D+zVjsbu8As43zdfnaa6MtB nsazOTX+dlToY+EQhKbK+fK6dbYULCc= Received: by mail-qk1-f174.google.com with SMTP id af79cd13be357-7a1d81dc0beso145990785a.2 for ; Fri, 09 Aug 2024 12:10:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen-com.20230601.gappssmtp.com; s=20230601; t=1723230626; x=1723835426; 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=gDvms9T6MxTADOWyeqlGsrri9pz592+CY2RkeRJgrNo=; b=ERGOn3wQPxU2mm7E2Pww9a7SvjwWDDL/xAmvJrjcy/e+gGnxbD6dnOMZVoN+Xwfoo3 1/DQrw+xM4evucZdOVaYgHb9usq6C7bPLK2eM1Znme4u+3l8AQOYKt0o12mv5IK0Pjpe URWr/olGMHC8pjflH15TCWhF+ip9KIqEfT4EHyrb4Aqk+AbM6R2ImK64HlVgp4sy5iKt jYvLzuL6O0pHlcWKgDBhEmvmPYJWwLeW+PDZ2FN3FF0oQ6ZxJz7T4+aybAIvTtWw+oLO N9aLOeZSiMZOVqKe4xPZhMGAg21lMo8ZWtA8FL0qq1KzPTeKzZSQaHrA0odMpxOeteos WKsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723230626; x=1723835426; 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=gDvms9T6MxTADOWyeqlGsrri9pz592+CY2RkeRJgrNo=; b=ntWPxA3asALONsiH6Xd8FZyfqCNWHADrGyQOmqNq2vzJUh6V+pw7yFXQ2zUfGmGCcb ABgSu1/TZLIX6WbBA0C5jkCDsf19fa+Snmew2Zq8SIsOVHbzh6gMW4plRgseoXCH3RAS F1/22tp3QZQRjFj6YUtxEdgW35KjxcRj2JMXYHE16B7XfxlkIm58ClhxNomyuQdbas5i Rc5FiGpZ3++WNgckSqUQgeKx8hMT/Xas4ST2YKZRAckuWWRvjXn18aeUO6T8hQhXexhz pbOn4W6GSDsOtt0BxlNvfAZ8S2DuCGesw87VSVo50XFCajVKJwxd2RtP+WQqRYk0WJ47 Azpw== X-Forwarded-Encrypted: i=1; AJvYcCV2nmdoKjVWIo/ggJaNWtYL8gfStk6hOdoR0XiUvV7Iz0b7b8um+DPeDiHvaUtrE1AKjy6mJDIHrFtye0AwRi1Am+o= X-Gm-Message-State: AOJu0YwbtkVqiz/e7Px0/oQrb1D7JYaT/e98f6WEP7lfi9+ubsI8vA9d vrWMK75eppWbTajJe0FjVwv52lbMSzqZdjuT3dNwfhbVIoMB1hpqPDwktXvkfFg= X-Google-Smtp-Source: AGHT+IFVg6UC1VsS2RarQnkmKfDpYYqkAoGLJP6WPhI6t59slYlLQRhsj/YpVmXHJEFlokfsL93xgA== X-Received: by 2002:a05:620a:2495:b0:79f:67b:4fdc with SMTP id af79cd13be357-7a4c1791fd1mr330555485a.2.1723230626022; Fri, 09 Aug 2024 12:10:26 -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 af79cd13be357-7a4c7df5a55sm5522085a.86.2024.08.09.12.10.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Aug 2024 12:10:25 -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 v5 2/3] mm: add system wide stats items category Date: Fri, 9 Aug 2024 19:10:19 +0000 Message-ID: <20240809191020.1142142-3-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog In-Reply-To: <20240809191020.1142142-1-pasha.tatashin@soleen.com> References: <20240809191020.1142142-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: E17BAC000F X-Stat-Signature: nczbx5gx5hh3ab9ho17316e9ib6qgp5b X-Rspam-User: X-HE-Tag: 1723230626-415501 X-HE-Meta: U2FsdGVkX1+4pJE7ZjkYKPXOlHjtBuVVNSFD8pBIhR7A8G8k3DR95ATJob9uGSu7FvgSlcEi2NkrXsB4RW13l7sp1R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IwnIFSUF1TK6m6z0lXluRBENHxaAlTcXWSMGuzvYAMWMlQzwpoG3NQwMfhZPVUMlOtXGKmlCTJnAgImOvKmZ1RApYj2jaKc9reagVSb3IhCGhNKiLpLYqq6ZzUf4I6+ks99EgTdT1+CTgJdOr34kUAhKWm0ogNOh4b13JUCKGPSQfMrZEjg2qKRD0FYAlMuPqWdtQSWgQOoY52mW+pDJaRDKvxWl31urNeR2tYJRTWU 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 Acked-by: David Rientjes --- 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 Fri Aug 9 19:10:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13759158 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 1BB8EC3DA4A for ; Fri, 9 Aug 2024 19:10:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0730D6B0098; Fri, 9 Aug 2024 15:10:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F3E4E6B009A; Fri, 9 Aug 2024 15:10:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D1C206B009E; Fri, 9 Aug 2024 15:10:30 -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 A6CE76B0098 for ; Fri, 9 Aug 2024 15:10:30 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 2A78AC14A9 for ; Fri, 9 Aug 2024 19:10:30 +0000 (UTC) X-FDA: 82433648220.05.AC5BFF5 Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) by imf20.hostedemail.com (Postfix) with ESMTP id 47BF91C003B for ; Fri, 9 Aug 2024 19:10:28 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=oGRavLrb; dmarc=pass (policy=none) header.from=soleen.com; spf=pass (imf20.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.169 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723230574; a=rsa-sha256; cv=none; b=AJYw339IeDhjBQvzMs3h2ZYqFVAdGB3oQopV8LBNQKznvMvte5VirL5COi88+Ej7xLUb+T uBiAGvopBpr0unVZ5wAQ0r7H79HVRVos1VkrIF3Y/0axcmRzAp+NVelOgGXYpog45eukY1 TG/gcCys0aB16z/jiRjTFFuszeV3aDI= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=oGRavLrb; dmarc=pass (policy=none) header.from=soleen.com; spf=pass (imf20.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.169 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=1723230574; 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=7scNbfOD3UNvIo9y0T+pYKNfJFgM2C7HW5kYHlU5U7s=; b=d2SBwdRmCFHB/jT71ucikSntx3X1nnrUG1ZMTf22XoRJyhxwHZ1XBp1V7wfEhMXeVavAvD dAwAw9sDk11HBScTSj002vKIsFLLTTDU5drFDlgZCc6aKN4uqZULskz9Y/ubWQRm/idgLO wIYnNOYgWcFWqsqigb9y/TLeCCWdczs= Received: by mail-qk1-f169.google.com with SMTP id af79cd13be357-7a1d436c95fso153039685a.3 for ; Fri, 09 Aug 2024 12:10:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen-com.20230601.gappssmtp.com; s=20230601; t=1723230627; x=1723835427; 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=7scNbfOD3UNvIo9y0T+pYKNfJFgM2C7HW5kYHlU5U7s=; b=oGRavLrbF7S6wPl4F4hWHGiL0Es/TjlnDpuT1CErEcPlpuvoNuDaIA4vUvF9nKjR8J v/5zrWkrwrJdGoFUKSOnAzcT94x+1LD5eLVt/EIsI7hybnZ/n8uOu6HaKOsHTHYSwmjy /A+iGppAV17TAgv3UCWROhTv2EWdOvotPnRhLjZ32GofmtL7uYTG9mOTRnnqwVPLeHRZ CmR+n3eE6p7w4Cnk92wpPXeItbtcaL/r2YMPaXnOOYZfINVsFVOzRoHJOgw3tjIFx0xd hJVt3mvRQ56iy4eZ3ZexkVdgQZTTjkFtosCIAdL0CXTYneE5aSyQhSGskYOyvCrt+34Y PRTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723230627; x=1723835427; 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=7scNbfOD3UNvIo9y0T+pYKNfJFgM2C7HW5kYHlU5U7s=; b=GAkIwfwnFkKjcjKTNRHmSzKDL9qwPS558hGCtsaHNS87qMXcZaJNJaKKjQD+Gb0ZW7 krso3Et1JvDdjVPCci9D7IMYXub8XeMD1B3ee30wKlT5Xrd/VgSBWW+FOIr1MASObly6 VU5cEnGtjXK2W602zlte8nsWI4fM1CGwS+I/DUQbj+5TmB9Rn09gAMvwF0Q30ZWPGwR/ uv5USh8rSDuSkqvK6KNy8j/9+fb1gLXSM90cNL+zeUwhCFh8o0JQlqPG1YVaZUdqU4R4 uo8QQlkzaYLA3lieieG9inONcdOvCPgYQXp14YMrHGapzyFSCjAwQn3iWMQIugNOmFwL /XIQ== X-Forwarded-Encrypted: i=1; AJvYcCUprT8fl4F0MH3Q8JVSFUk4zqHBTLIu2P7gxxYIE1CXuBYWFvMBJo6oo4zzwHkjWRuOre52UeJIunz7FCiwd2c2M8Q= X-Gm-Message-State: AOJu0Yw6/Bs/RNuFqVYYQORxE1b5F2zsYRcASEka+q/gJ0v3HAEJeAnr mkr7H12W54/Bkv6bRicINsB3YX8POj+eAkL0QoxywVyKiURgfAbxikllAqnjtDI= X-Google-Smtp-Source: AGHT+IG+izZuVqrrLECU59ZUsz/j/pq6H+/mhN6LagU3A3JWt/ctLE0qFWvHYBV7BwQjZPC1c0cfJA== X-Received: by 2002:a05:620a:2456:b0:79d:5f67:a836 with SMTP id af79cd13be357-7a4c17aafddmr317308185a.26.1723230627259; Fri, 09 Aug 2024 12:10:27 -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 af79cd13be357-7a4c7df5a55sm5522085a.86.2024.08.09.12.10.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Aug 2024 12:10:26 -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 v5 3/3] mm: don't account memmap per-node Date: Fri, 9 Aug 2024 19:10:20 +0000 Message-ID: <20240809191020.1142142-4-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog In-Reply-To: <20240809191020.1142142-1-pasha.tatashin@soleen.com> References: <20240809191020.1142142-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 47BF91C003B X-Stat-Signature: wdc8t6a5rcq7xt37c5to5aobffggn8zo X-Rspam-User: X-HE-Tag: 1723230628-173066 X-HE-Meta: U2FsdGVkX19uQP4lqaHmDwBVt81anUR0/tEadT2Sly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iGGU9OXC067A0zQ4OlNjmMoNxLIitfPpq3UfA6DiSsswAAj+jUKiCbtd+f57IZBognF7XwrCGquckmc/gtznDBMS6twrm93+w65hW3BL8TVNHuvIQ0j4eE8LPXMNlS06TQ40cYjMp3nhIMtHRHZwTjZtfTiG5pnV4ygMsvl3PBNeWO6nJpQHYEJsMvy+DT77bFVh7b6LRq44k5P3b4fraq515EqwuNZLSdakR+Zb+zapEgaNcaFcXUHhO048PtLSBuSHYVmzUC3zZfBdrQnhPNSr+LT1Fws5Mwewro2PJkzcx9GhpTk9KwJOmfOcDBIRCovGdXp8iCVJDF/2TxAzya2Y09zzdJVOqeJvUm9kqLFUTAtQsfvgdA1hBvoUcQWawZnGANHNQ== 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 Tested-by: Alison Schofield Acked-by: David Hildenbrand Acked-by: David Rientjes Tested-by: Yi Zhang --- 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 | 46 ++++++++++++++++++++---------------------- 9 files changed, 41 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..9eb77c9007e6 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_PAGES, /* page metadata allocated through buddy allocator */ + NR_MEMMAP_BOOT_PAGES, /* 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 memmap_boot_pages_add(long delta); +void memmap_pages_add(long delta); #endif /* _LINUX_VMSTAT_H */ diff --git a/mm/hugetlb_vmemmap.c b/mm/hugetlb_vmemmap.c index 4f51e0596197..0c3f56b3578e 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)) { + memmap_boot_pages_add(-1); free_bootmem_page(page); - mod_node_page_state(page_pgdat(page), NR_MEMMAP_BOOT, -1); } else { + memmap_pages_add(-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); + memmap_pages_add(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); + memmap_pages_add(nr_pages); return 0; out: diff --git a/mm/mm_init.c b/mm/mm_init.c index 75c3bd42799b..f9a60ffc5532 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)); + memmap_boot_pages_add(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..641d93f6af4c 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)); + memmap_boot_pages_add(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) + memmap_pages_add(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; + memmap_pages_add(-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..edcc7a6b0f6f 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) + memmap_boot_pages_add(DIV_ROUND_UP(end - start, PAGE_SIZE)); + else + memmap_pages_add(DIV_ROUND_UP(end - start, PAGE_SIZE)); return pfn_to_page(pfn); } diff --git a/mm/sparse.c b/mm/sparse.c index e4b830091d13..0f018c6f9ec5 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)); + memmap_boot_pages_add(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))); + memmap_pages_add(-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..e875f2a4915f 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1033,6 +1033,24 @@ unsigned long node_page_state(struct pglist_data *pgdat, } #endif +/* + * Count number of pages "struct page" and "struct page_ext" consume. + * nr_memmap_boot_pages: # of pages allocated by boot allocator + * nr_memmap_pages: # of pages that were allocated by buddy allocator + */ +static atomic_long_t nr_memmap_boot_pages = ATOMIC_LONG_INIT(0); +static atomic_long_t nr_memmap_pages = ATOMIC_LONG_INIT(0); + +void memmap_boot_pages_add(long delta) +{ + atomic_long_add(delta, &nr_memmap_boot_pages); +} + +void memmap_pages_add(long delta) +{ + atomic_long_add(delta, &nr_memmap_pages); +} + #ifdef CONFIG_COMPACTION struct contig_page_info { @@ -1255,11 +1273,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 +1845,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_PAGES] = atomic_long_read(&nr_memmap_pages); + v[NR_MEMMAP_BOOT_PAGES] = atomic_long_read(&nr_memmap_boot_pages); v += NR_VM_STAT_ITEMS; #ifdef CONFIG_VM_EVENT_COUNTERS @@ -2285,25 +2305,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]); - } -}