From patchwork Thu Oct 20 21:53:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 13014050 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 97336C4332F for ; Thu, 20 Oct 2022 21:54:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 341538E0007; Thu, 20 Oct 2022 17:54:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2F1B78E0001; Thu, 20 Oct 2022 17:54:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 192D58E0007; Thu, 20 Oct 2022 17:54:31 -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 0C10B8E0001 for ; Thu, 20 Oct 2022 17:54:31 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id DCCB91204E4 for ; Thu, 20 Oct 2022 21:54:30 +0000 (UTC) X-FDA: 80042682300.21.524260E Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) by imf14.hostedemail.com (Postfix) with ESMTP id 8CE20100023 for ; Thu, 20 Oct 2022 21:54:30 +0000 (UTC) Received: by mail-qk1-f181.google.com with SMTP id s17so849611qkj.12 for ; Thu, 20 Oct 2022 14:54:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=tvfEueXv3MPyKUTDqbsvcgdPv0lPq1HvhYO0pg1lxgg=; b=ffixkJKdZbTCBgQd/yyyoLEt9enHtHJdBGSffjbahVDco4N7boG7mqHf4g6HNIWDRV TUF2h3/TlW1N88JPvCgjd5FjVNusNzYKuIyp8TGrBY9OXkwOzi7zUpMXlULvLJUWJ8W9 avv5kHbuJnwKwgHuWuDXHdm9QYpgnsiEKcZEFOneAtsv2+MP3U8dOTOOGDD1USkrXOCt Iqv8+KZIqj6eh2vmChJHacuLhyL1e4qs7ooWBZUnlQp/Eb7vo1cQiMKoyTJrkOBKnZSP ZtvvP6oZGVyoOyC7Bt9iXv+x4vQtDi9ovBXsTNzCOqpI7rcL0jEiTpC70OvnjYfdeMAU hhHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=tvfEueXv3MPyKUTDqbsvcgdPv0lPq1HvhYO0pg1lxgg=; b=TOY144V+ulHh0yLGYDMJwP54Fu5jAPBL7R/SBCbmZPbPpsrM7Sk5SkcWaHRR8OyG7B dyXcb7tKGw/WXo9VPEHGIGZhJ6IispxTj70PE2Bq948MnDci67d2phObk+Y9GWfG3AEt JU+egAa17pFRBWnQZUSARZJqIcHhSrXAsr5RkJfuWrkoilhcRWQnWicfEAhmGxmMC43g diSPAAhrcGfGa9oHnuavDvNhG1uwf6DXXJ7OstBW/RlD0Jocjglte1Lc+IgBwA24RWqp bEK2cqs2/GCvMxJDnfMYUAX/+SN0+up8lQ8kALE9CO4hd/ZPf562ysX8ihcWvhHj2pYz 7YSg== X-Gm-Message-State: ACrzQf24uVQLhn2Ve7rGZXqAeGBtBcislZ+Cd1FOPfZGE+lFSwPNmYfb ytiG9xDspeCc0duZ0RQ1Rrw= X-Google-Smtp-Source: AMsMyM5Nmw4C772V70Q+LmwGPXj1++mwiH027m+RB4IR5T/YT15ihOIWJHuJ1fNCaKZtV3P9KumgYA== X-Received: by 2002:a05:620a:2b91:b0:6ee:bc07:24c with SMTP id dz17-20020a05620a2b9100b006eebc07024cmr11239651qkb.64.1666302869881; Thu, 20 Oct 2022 14:54:29 -0700 (PDT) Received: from stbirv-lnx-3.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id bj41-20020a05620a192900b006bb29d932e1sm8121067qkb.105.2022.10.20.14.54.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Oct 2022 14:54:29 -0700 (PDT) From: Doug Berger To: Andrew Morton Cc: Jonathan Corbet , Mike Rapoport , Borislav Petkov , "Paul E. McKenney" , Neeraj Upadhyay , Randy Dunlap , Damien Le Moal , Muchun Song , Vlastimil Babka , Johannes Weiner , Michal Hocko , KOSAKI Motohiro , Mel Gorman , Mike Kravetz , Florian Fainelli , David Hildenbrand , Oscar Salvador , Joonsoo Kim , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Doug Berger Subject: [PATCH v3 3/9] mm/page_alloc: prevent creation of empty zones Date: Thu, 20 Oct 2022 14:53:12 -0700 Message-Id: <20221020215318.4193269-4-opendmb@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221020215318.4193269-1-opendmb@gmail.com> References: <20221020215318.4193269-1-opendmb@gmail.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666302870; a=rsa-sha256; cv=none; b=3v6vkeCaBJd18yBPWtbbJkgyPB2F5b2MUikEx1YwoHyqTzsSf1pg/S5hSAz3dyX6GzjWRs 6/yVE0JWhhujCPWHXAEPzEAkS/YFVx6R7yCzVEAayoIq840T4ABNIFrkNrBdoG0GFO36f/ n6CqQ4BEa4do09XGJXsSlCACc+83RnI= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ffixkJKd; spf=pass (imf14.hostedemail.com: domain of opendmb@gmail.com designates 209.85.222.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=1666302870; 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=tvfEueXv3MPyKUTDqbsvcgdPv0lPq1HvhYO0pg1lxgg=; b=Z0Bb5t7ilYLQiKoGH2skh6pYfYvBZsrPC9CLsLBtwBpro6u0kXhSOkndd71r6taJkUs3KM lMIk5w+sMtaq/cMo8gYqwmMDGuffKzS6RTwb3fceuqXTBHv+Bp8k6UI+TfF9jT4CiecZH0 vdxE0LyfjbTnzCW2iMeJ4Uwz0Usep4U= X-Stat-Signature: 9bmc8nng5418k919u7n1sbyetbpxjme5 X-Rspamd-Queue-Id: 8CE20100023 X-Rspam-User: X-Rspamd-Server: rspam03 Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ffixkJKd; spf=pass (imf14.hostedemail.com: domain of opendmb@gmail.com designates 209.85.222.181 as permitted sender) smtp.mailfrom=opendmb@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1666302870-884189 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 92908c51f1c3..2f7b88d78bc2 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -7548,8 +7548,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, @@ -7560,20 +7559,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;