From patchwork Tue Jun 21 04:17:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 12888671 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 4DD99C433EF for ; Tue, 21 Jun 2022 04:17:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C88106B0073; Tue, 21 Jun 2022 00:17:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C38048E0002; Tue, 21 Jun 2022 00:17:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B00D58E0001; Tue, 21 Jun 2022 00:17:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id A319E6B0073 for ; Tue, 21 Jun 2022 00:17:27 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 7601E21055 for ; Tue, 21 Jun 2022 04:17:27 +0000 (UTC) X-FDA: 79600933734.01.8FCC44B Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf10.hostedemail.com (Postfix) with ESMTP id 09D96C0096 for ; Tue, 21 Jun 2022 04:17:26 +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 EC40821F36; Tue, 21 Jun 2022 04:17:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1655785045; 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=RD4sy+2BaX5dGg7b7ucLGgHHapq1SLtKUacFvTEnfcw=; b=QjIquwJYZLJwTxi8gcPBkW+f69EjNnNYPBikE5v9wlMM3rIlFRqPVmr73cSWXS4cS6RxXj 7rUVLuGDQ3cUv3csK4AiMecz0Y4ZhKFjxx2nHMBPJiC1zDuaAIZfNNy76s82Y0Qzn2BZF3 +9B3tltxCldl3aiF+QSDUqFKxJluNSM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1655785045; 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=RD4sy+2BaX5dGg7b7ucLGgHHapq1SLtKUacFvTEnfcw=; b=HG3iaJAln/w9mHkkdLgaE/tOq2y/oW+ySyN7n5ei2te6jezSoii+28guvjax8/oQuSAK+d Hab1RlMU5t859oCg== 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 8670813A37; Tue, 21 Jun 2022 04:17:25 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 6G3hHVVGsWLLGwAAMHmgww (envelope-from ); Tue, 21 Jun 2022 04:17:25 +0000 From: Oscar Salvador To: Andrew Morton Cc: David Hildenbrand , Michal Hocko , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Oscar Salvador Subject: [PATCH v2 1/2] mm/page_alloc: Do not calculate node's total pages and memmap pages when empty Date: Tue, 21 Jun 2022 06:17:16 +0200 Message-Id: <20220621041717.6355-2-osalvador@suse.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220621041717.6355-1-osalvador@suse.de> References: <20220621041717.6355-1-osalvador@suse.de> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655785047; 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=RD4sy+2BaX5dGg7b7ucLGgHHapq1SLtKUacFvTEnfcw=; b=n3+57sJcNrlOxwSUgHCSEowkjrCh/XUuVDkyksIpclmiOKlX1O+sJ9Gt8MQgqvujNvxnl8 lqf74SQRgomIpnkVqX8+bjxYEnKD/kNADmfaQyuxB34TWgaSQYgc6/WhUdZo9xmJ9FEufV v97vYKvuVurZgiDedHxs048gdf7qBIM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655785047; a=rsa-sha256; cv=none; b=6aS8b1Me33eTPr7qbadBEm1LRIpP2AGh7XLukL4RcJr/2NazwT6n5yVAB6UqOIaaLQzOCr atAB2tTseL/v5QRtj13Po6T2xYYppfKFX07p3Lw5lUa7INsjuvBvc+azFJ4lQ/42uc3IUM 8y5glY+ycQSeib5iwn9Sj2CCPh9AEo4= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=QjIquwJY; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=HG3iaJAl; spf=pass (imf10.hostedemail.com: domain of osalvador@suse.de designates 195.135.220.28 as permitted sender) smtp.mailfrom=osalvador@suse.de; dmarc=pass (policy=none) header.from=suse.de X-Stat-Signature: xo5pko9bpfd1oket68mqywetum8x4z9s Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=QjIquwJY; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=HG3iaJAl; spf=pass (imf10.hostedemail.com: domain of osalvador@suse.de designates 195.135.220.28 as permitted sender) smtp.mailfrom=osalvador@suse.de; dmarc=pass (policy=none) header.from=suse.de X-Rspamd-Queue-Id: 09D96C0096 X-Rspamd-Server: rspam02 X-Rspam-User: X-HE-Tag: 1655785046-865913 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 Reviewed-by: David Hildenbrand --- mm/page_alloc.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index e008a3df0485..2b9b2422ba32 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -7361,6 +7361,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 (pgdat_is_empty(pgdat)) + 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; @@ -7393,6 +7397,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); @@ -7610,6 +7615,12 @@ 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) { + zone_init_internals(zone, j, nid, 0); + continue; + } + /* * Adjust freesize so that it accounts for how much memory * is used by this zone for memmap. This affects the watermark @@ -7647,9 +7658,6 @@ static void __init free_area_init_core(struct pglist_data *pgdat) */ zone_init_internals(zone, j, nid, freesize); - if (!size) - continue; - set_pageblock_order(); setup_usemap(zone); init_currently_empty_zone(zone, zone->zone_start_pfn, size); @@ -7730,7 +7738,7 @@ static void __init free_area_init_node(int nid) pgdat->node_start_pfn = start_pfn; pgdat->per_cpu_nodestats = NULL; - if (start_pfn != end_pfn) { + if (!pgdat_is_empty(pgdat)) { pr_info("Initmem setup node %d [mem %#018Lx-%#018Lx]\n", nid, (u64)start_pfn << PAGE_SHIFT, end_pfn ? ((u64)end_pfn << PAGE_SHIFT) - 1 : 0);