From patchwork Mon Mar 7 15:07:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 12771984 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 38C43C433EF for ; Mon, 7 Mar 2022 15:07:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B8BF78D0003; Mon, 7 Mar 2022 10:07:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B3B878D0001; Mon, 7 Mar 2022 10:07:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A03E78D0003; Mon, 7 Mar 2022 10:07:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.a.hostedemail.com [64.99.140.24]) by kanga.kvack.org (Postfix) with ESMTP id 92EBB8D0001 for ; Mon, 7 Mar 2022 10:07:36 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 5E85321A8D for ; Mon, 7 Mar 2022 15:07:36 +0000 (UTC) X-FDA: 79217919312.04.A24CE4B Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf23.hostedemail.com (Postfix) with ESMTP id BFC0E14000E for ; Mon, 7 Mar 2022 15:07:35 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id A33DB210F6; Mon, 7 Mar 2022 15:07:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1646665654; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/+A0bDyvDGXMAEGgLd6HrR1FD9t6zIOokUQHzoAnIiw=; b=Jd6GKQ9CUlQiRU4Ruylo/72Vw/mzoTPXEaHLVjz3U8htklKaWXDhh9ENlGO9pxRJZIBssi xT0bfWbxVcU0t1QCPYCITTJc2yOFlnQI+7wA2EIPrI6tzRst7ssacZ4QAJS7/QVSeAOhNu CpyiHOz9t06tLOWQ+3RF2Nx3Le+5x0g= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1646665654; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/+A0bDyvDGXMAEGgLd6HrR1FD9t6zIOokUQHzoAnIiw=; b=+G0LP7QZV1k0Ud+wRWdG3t4zAkFwL8JaDfCtV/eqHl+PU2FLOf/Dn6GQfw2oJ2vtjkuwN4 Jg/zADZI7rm8fPBg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 27D34132BC; Mon, 7 Mar 2022 15:07:34 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id eAj7BrYfJmLrHgAAMHmgww (envelope-from ); Mon, 07 Mar 2022 15:07:34 +0000 From: Oscar Salvador To: Andrew Morton Cc: David Hildenbrand , Michal Hocko , Wei Yang , Miaohe Lin , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Oscar Salvador Subject: [PATCH 1/3] mm/page_alloc: Do not calculate node's total pages and memmap pages when empty Date: Mon, 7 Mar 2022 16:07:23 +0100 Message-Id: <20220307150725.6810-2-osalvador@suse.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307150725.6810-1-osalvador@suse.de> References: <20220307150725.6810-1-osalvador@suse.de> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: BFC0E14000E X-Stat-Signature: 1y4dq8xuu34psaphok1ohi3hffett36h Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=Jd6GKQ9C; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=+G0LP7QZ; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf23.hostedemail.com: domain of osalvador@suse.de designates 195.135.220.28 as permitted sender) smtp.mailfrom=osalvador@suse.de X-HE-Tag: 1646665655-424814 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: free_area_init_node() calls calculate_node_totalpages() and free_area_init_core(). The former to get node's {spanned,present}_pages, and the latter to calculate, among other things, how many pages per zone we spent on memmap_pages, which is used to substract zone's free pages. On memoryless-nodes, it is pointless to perform such a bunch of work, so make sure we skip the calculations when having a node or empty zone. Signed-off-by: Oscar Salvador --- mm/page_alloc.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 967085c1c78a..0b7d176a8990 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -7312,6 +7312,10 @@ static void __init calculate_node_totalpages(struct pglist_data *pgdat, unsigned long realtotalpages = 0, totalpages = 0; enum zone_type i; + /* Skip calculation for memoryless nodes */ + if (node_start_pfn == node_end_pfn) + goto no_pages; + for (i = 0; i < MAX_NR_ZONES; i++) { struct zone *zone = pgdat->node_zones + i; unsigned long zone_start_pfn, zone_end_pfn; @@ -7344,6 +7348,7 @@ static void __init calculate_node_totalpages(struct pglist_data *pgdat, realtotalpages += real_size; } +no_pages: pgdat->node_spanned_pages = totalpages; pgdat->node_present_pages = realtotalpages; pr_debug("On node %d totalpages: %lu\n", pgdat->node_id, realtotalpages); @@ -7562,6 +7567,10 @@ static void __init free_area_init_core(struct pglist_data *pgdat) size = zone->spanned_pages; freesize = zone->present_pages; + /* No pages? Nothing to calculate then. */ + if (!size) + goto no_pages; + /* * Adjust freesize so that it accounts for how much memory * is used by this zone for memmap. This affects the watermark @@ -7597,6 +7606,7 @@ static void __init free_area_init_core(struct pglist_data *pgdat) * when the bootmem allocator frees pages into the buddy system. * And all highmem pages will be managed by the buddy system. */ +no_pages: zone_init_internals(zone, j, nid, freesize); if (!size)