From patchwork Sat Mar 11 00:38:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 13170540 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 D22AAC6FD19 for ; Sat, 11 Mar 2023 00:39:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5E10E8E0005; Fri, 10 Mar 2023 19:39:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5B9066B0074; Fri, 10 Mar 2023 19:39:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 47F6F8E0005; Fri, 10 Mar 2023 19:39:57 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 3739F6B0072 for ; Fri, 10 Mar 2023 19:39:57 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 2029CC01D4 for ; Sat, 11 Mar 2023 00:39:57 +0000 (UTC) X-FDA: 80554760034.27.92C2D9E Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) by imf08.hostedemail.com (Postfix) with ESMTP id 59D3E160007 for ; Sat, 11 Mar 2023 00:39:55 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ACBZmz9T; spf=pass (imf08.hostedemail.com: domain of opendmb@gmail.com designates 209.85.160.181 as permitted sender) smtp.mailfrom=opendmb@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1678495195; 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=1BQ3Tu4Fh7Zw0bEuz451Bf6KjfFz+vAaaszEEJUUChw=; b=4bzhVfYSjc+FLdR3krYFS5WtFq2XTYo22nNRV/7Vb+S8f82I0kRguwL1LNGo1ds0L63hY6 qeVVNGnqz4/szgOD6T8kN49whB00lygdvFt9S/hdUa93CYLAWCS1+Jrm5DxspLiUJUVov2 NRPH57B3MITCCe6buVctbvTmG2drEuk= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ACBZmz9T; spf=pass (imf08.hostedemail.com: domain of opendmb@gmail.com designates 209.85.160.181 as permitted sender) smtp.mailfrom=opendmb@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678495195; a=rsa-sha256; cv=none; b=sQzYC6GcKmNSq7kEO3wtrW30BnnWkw/gnf7iQfPnHBjeeq3JdrcH214PzH/B5kDAlpYmL5 WeY5wqU7N3Rkkgt6urrVa++z5VDmMfgHWfK2GAWbqZnaXNg+sWpuxrSK/qsqSq3p32XCSX pzGk+psiypJZMwjhUOpA9/nXjX2F6ec= Received: by mail-qt1-f181.google.com with SMTP id c19so7679548qtn.13 for ; Fri, 10 Mar 2023 16:39:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678495194; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1BQ3Tu4Fh7Zw0bEuz451Bf6KjfFz+vAaaszEEJUUChw=; b=ACBZmz9T+fOJ/er2MQetIFMNgeRLKnusO2uR98YFrcykpO+2zcEzh45d0mpQn8L8jZ cdR/zhSiqUdc+7AlJATmoMf24jV3C/a2RsALpIVpVApX7OZzvi2A5rlaFFLOoM+4a+Iu cmlDmVB6VWydoOGSTEEfkLhgMkdb8XzoDjcQk2fg+HQnJYwd+s4LvbFXcehweSegHqMN qGoJLqVGKKRZcSfMSqbYZaOJYXZtrhVIS58QLZE1cpB/NF+nc7muaTC4uG6RsPAN/amf FfNftp8lhVc0lAl1X0hPzYaMUxdq1qzm2P450TpVFNj2Fc9ZAuorzU1Nl1iW7OagYS9k XYQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678495194; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1BQ3Tu4Fh7Zw0bEuz451Bf6KjfFz+vAaaszEEJUUChw=; b=Uzg2cMjzeapOW+Flp3SyjarX+61D/XQoRSF+aEmy8hLuhlP3Ig5GnSVTNHmqENY/Eq LbYt43LFpY4tHiT5sduk7kNTAFfZjtR4jrcZL23CGJTF3tweUbtv5jg3tnGUfdm1ekrv 4Pj5IuBH/te1N/EIsJcsEaBHeyEv/IKJroJH+N9uGRNvJ858WOoCElzBAixG+tGUm/HE 2NK1dnu8vjEeRFo+ux9cHVpDF2keUFQNzwVNDVHby8V/nXOscYD0u30o1eIvLFfehuFE DxuUip+YtcNscqeHCxFiCx2gvCBN+oqNpBVSamtORDRm62tLg9WegXgKc0exCWgP/S9L 8iUg== X-Gm-Message-State: AO0yUKW7uQByuF5/+5Ws8L9L/Z3IP++rAj1F5mOOBODun73H5Ymxaz1G eo8u57cmgFjnAgX6f/dUkMg= X-Google-Smtp-Source: AK7set+MmuySHwc8FcDbJGZpaVLU4HCrie7tiN1VA0TeZDeCtzqts9IA4rg4ydaSqQ297OiyWnJ7pQ== X-Received: by 2002:ac8:5a88:0:b0:3bf:d8ec:a9fc with SMTP id c8-20020ac85a88000000b003bfd8eca9fcmr11747709qtc.52.1678495194581; Fri, 10 Mar 2023 16:39:54 -0800 (PST) Received: from stbirv-lnx-1.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id a5-20020ac84345000000b003bfaff2a6b9sm868874qtn.10.2023.03.10.16.39.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 16:39:54 -0800 (PST) From: Doug Berger To: Andrew Morton Cc: Jonathan Corbet , Mike Rapoport , Borislav Petkov , "Paul E. McKenney" , Randy Dunlap , Neeraj Upadhyay , Damien Le Moal , Kim Phillips , "Steven Rostedt (Google)" , Michal Hocko , Johannes Weiner , Vlastimil Babka , KOSAKI Motohiro , Mel Gorman , Muchun Song , Mike Kravetz , Florian Fainelli , David Hildenbrand , Oscar Salvador , Joonsoo Kim , Sukadev Bhattiprolu , Rik van Riel , Roman Gushchin , Minchan Kim , Chris Goldsworthy , "Georgi Djakov" , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Doug Berger Subject: [PATCH v4 3/9] mm/page_alloc: prevent creation of empty zones Date: Fri, 10 Mar 2023 16:38:49 -0800 Message-Id: <20230311003855.645684-4-opendmb@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230311003855.645684-1-opendmb@gmail.com> References: <20230311003855.645684-1-opendmb@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 59D3E160007 X-Rspam-User: X-Stat-Signature: pza8ewwihht3xrpafa4acfax4kqn7esy X-HE-Tag: 1678495195-452734 X-HE-Meta: U2FsdGVkX18ovq1sMhluDGNPVibbh3kd9MwO3YuMr6A1cZk4/ZPeWtPkxR1RA0mBekVgO2AzF8aHipqcqmARQIK0jUEn38UHTH77CDa0NLay+dCK9IHGyiuB4BzTTf3JPG0OEVDIQyluOoLD5f2kvG6xoP5IGK+ZmRPLcxfuVTnS9wW6nwRm5t0MvZjfgoeqnOjcUg/88uDUDmmxGXe56WNjlRF1Lz3diHHuNgZ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ZvbR1C+ZzPNdzCwOuQsio4VseNGjqpd0K2EZe5xQ3JwZwa3bgITE6Z/sQPQJtsQcNAmYYJECGWMuS+bFmqWHU2rciA490ZT16LxHFI1YuAZbRC3dgn5bF5ZFxD8pfVjjU9o2x6qllb9v9R/JMhaHVBNWDv0dHFpDko2Eea0iAx6rkQCyRCo6aRqZM3JXQ1rue9b121nx81rDmExLdpphN1eXzKg3HRG48FsACUw1R5cajzT0rBIMpMltYY5vbZXsNiLxEdigu+XFadB1e2hAnIGmVBQ/w/Uo= 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: If none of the pages a zone spans are present then its start pfn and span should be zeroed to prevent initialization. This prevents the creation of an empty zone if all of its pages are moved to a zone that would overlap it. The real_size name is reverted to just size to reduce the burden of supporting multiple realities. Signed-off-by: Doug Berger --- mm/page_alloc.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index b1952f86ab6d..827b4bfef625 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -7592,8 +7592,7 @@ static void __init calculate_node_totalpages(struct pglist_data *pgdat, for (i = 0; i < MAX_NR_ZONES; i++) { struct zone *zone = pgdat->node_zones + i; unsigned long zone_start_pfn, zone_end_pfn; - unsigned long spanned, absent; - unsigned long size, real_size; + unsigned long spanned, absent, size; spanned = zone_spanned_pages_in_node(pgdat->node_id, i, node_start_pfn, @@ -7604,20 +7603,21 @@ static void __init calculate_node_totalpages(struct pglist_data *pgdat, node_start_pfn, node_end_pfn); - size = spanned; - real_size = size - absent; + size = spanned - absent; - if (size) + if (size) { zone->zone_start_pfn = zone_start_pfn; - else + } else { + spanned = 0; zone->zone_start_pfn = 0; - zone->spanned_pages = size; - zone->present_pages = real_size; + } + zone->spanned_pages = spanned; + zone->present_pages = size; #if defined(CONFIG_MEMORY_HOTPLUG) - zone->present_early_pages = real_size; + zone->present_early_pages = size; #endif - totalpages += real_size; + totalpages += size; } pgdat->node_spanned_pages = node_end_pfn - node_start_pfn;