Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3449975iog; Mon, 20 Jun 2022 21:21:43 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sw//kq6sxMS/OqzzSV5Pyip0wYMLLe0/uIVx/RZEmQmThSw7fzrtL03zvOos6zGoDVIPl6 X-Received: by 2002:a17:907:96a8:b0:711:56b8:f72b with SMTP id hd40-20020a17090796a800b0071156b8f72bmr24819426ejc.152.1655785302944; Mon, 20 Jun 2022 21:21:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655785302; cv=none; d=google.com; s=arc-20160816; b=CL41uv1Yde5/DFvJ0LgJ7Lwg1l4AqZ8jCOuef+1i3fTa/m7czj3UxmAA+D3kBpwKSl bGgBh3h2kxXNvJIhzHdI59Z6tHh8utgHG6jZ32PtZkM8L/AbvZ4K+NFW9AD3Sw0fGwMz d2pCqOrFo5AkrPthsA0QpPX+kdXsBZVIRavBaR0GUv9rm7GbUY7WMSxKXqtT2kLZkOf3 R05SZfJoN2nu6NVWkDrqC/Knr5TglGVANHHIhrJD1lytYWAqJpGyt15GrI9spsMVka8M ShooWm7C1d0WEk342IYxpwEqM/+yV/QBmDXXAF+oB+qoxBX147o8+qgfHJiY1VFedqO7 XxDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=RD4sy+2BaX5dGg7b7ucLGgHHapq1SLtKUacFvTEnfcw=; b=tUe/vDwPYTR/KB3C56yF2l5ifq10AIyS1jYxR17RaIAYF18DWtp4ILhWTcUCYDF7dm C+t/eHwMK/PN67mBmpaBDizxObT8sGLld6U9S3vjhkvg8ID9GykXcUWowTaNGERmTXvt xVLN7KjeJC9sY0sUIr0ONRnyjdDvXCyjsJ6jU+jmqCd7/DM8BlPiCfBV2KdeC/dlcLCT CIVx7emxete77PL8acXdCQmyFR+qqfGLmaZwNZ29c4cLkOAsj/3A7/4ICvsEYv1JI+Tt rePaw3LEL9oR4fnol1tw0EHC4BSqPHcc32rUSJsjZYKmoEmVtFe6HqaJV3kfKOZurQGs h0/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=QjIquwJY; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id du10-20020a17090772ca00b00711f646bb8csi13260655ejc.916.2022.06.20.21.21.17; Mon, 20 Jun 2022 21:21:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=QjIquwJY; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344260AbiFUERl (ORCPT + 99 others); Tue, 21 Jun 2022 00:17:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242636AbiFUER2 (ORCPT ); Tue, 21 Jun 2022 00:17:28 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B56925ED for ; Mon, 20 Jun 2022 21:17:27 -0700 (PDT) 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 | 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); -- 2.35.3