From mboxrd@z Thu Jan 1 00:00:00 1970 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 08308C433F5 for ; Thu, 28 Apr 2022 12:13:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 61D436B0072; Thu, 28 Apr 2022 08:13:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5CC276B0073; Thu, 28 Apr 2022 08:13:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 445886B0074; Thu, 28 Apr 2022 08:13:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id 357356B0072 for ; Thu, 28 Apr 2022 08:13:52 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 045252A4F1 for ; Thu, 28 Apr 2022 12:13:51 +0000 (UTC) X-FDA: 79406179104.06.933E381 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf07.hostedemail.com (Postfix) with ESMTP id E71E640066 for ; Thu, 28 Apr 2022 12:13:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1651148030; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=peo0ScnOD/kREKuRjyBJPvH3MAbi5TUpXP5WbTNJH+g=; b=TGiYsfY3/QAFMhTiQ0tNsPP+6k/qdxZlCF3y3u6SNtycqRnwUl1lmfZMjUttvUCKRGo4fp sMj10klfPcH/tcJXcxThi/3eH7km1ziz9LCTczXCBugHn2+0T5Dw7yJ+L/IZOL0Cu+KmZL eWiLhRO586Ght2a6NMhEcOWooF8nH3M= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-563-NbffUmV8O3iba4r2DyCNyA-1; Thu, 28 Apr 2022 08:13:49 -0400 X-MC-Unique: NbffUmV8O3iba4r2DyCNyA-1 Received: by mail-ed1-f71.google.com with SMTP id l14-20020aa7cace000000b003f7f8e1cbbdso2645556edt.20 for ; Thu, 28 Apr 2022 05:13:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent :content-language:to:cc:references:from:organization:subject :in-reply-to:content-transfer-encoding; bh=peo0ScnOD/kREKuRjyBJPvH3MAbi5TUpXP5WbTNJH+g=; b=Zb3ifLM0J9tOxf7JnIzCwwV/JJUPF13gMW202pEdkxL4su904ioAyDI8orlCUxPO/f ZmodD3mC8sU7Ig61EGSxKYUyGI2p0FWJDhZ8tI1WXTIBafGpRGGD6YfKlIvXflLnN8IX LSVAmwoNFlHh8uAgLTtb+l3UQ/x6nWN5ZHsq5QkMbypzDIIAciRyVBBs4+alsVRNG+Md WOpeA0cXKUOQ2FMkN6iOmSDX7Db6rcxk61lIlrvfUimEyDXa0IMMoLtroE1oqEXh1fgX MVmcxrph/EhO0Em8ZnyzZDdN0SS8pcHr2w5NWEn5+ZMrx/6dlK3Ry7GqtCOdoWLHq/SF auvQ== X-Gm-Message-State: AOAM5309c5HIPd2EqtIUJV0Tifp/k6K9G8PImqdrXgtg3YNIcD0MGNhy FPdP2TKpyqsvSlcVs3j204Dl1PEDAOQkiTIuLbfEMLtdcb13KiT4X1faZfGpVEpsgkActNembnp uyMG8bCCfkVQ= X-Received: by 2002:a05:6402:2309:b0:41f:a5a9:fe13 with SMTP id l9-20020a056402230900b0041fa5a9fe13mr35794023eda.123.1651148028302; Thu, 28 Apr 2022 05:13:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyWtRVzz9fglE7R6LGmifRxKTF/DA9SAlgj9lilGJMS+YqAMwvtx7BmKuyQwqme/iq0QpQoA== X-Received: by 2002:a05:6402:2309:b0:41f:a5a9:fe13 with SMTP id l9-20020a056402230900b0041fa5a9fe13mr35793998eda.123.1651148028036; Thu, 28 Apr 2022 05:13:48 -0700 (PDT) Received: from ?IPV6:2003:cb:c708:ef00:7443:a23c:26b8:b96? (p200300cbc708ef007443a23c26b80b96.dip0.t-ipconnect.de. [2003:cb:c708:ef00:7443:a23c:26b8:b96]) by smtp.gmail.com with ESMTPSA id cy19-20020a0564021c9300b0042617ba6386sm1461422edb.16.2022.04.28.05.13.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 28 Apr 2022 05:13:47 -0700 (PDT) Message-ID: Date: Thu, 28 Apr 2022 14:13:46 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.2 To: Oscar Salvador , Andrew Morton Cc: Michal Hocko , Wei Yang , Miaohe Lin , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20220307150725.6810-1-osalvador@suse.de> <20220307150725.6810-2-osalvador@suse.de> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH 1/3] mm/page_alloc: Do not calculate node's total pages and memmap pages when empty In-Reply-To: <20220307150725.6810-2-osalvador@suse.de> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: E71E640066 X-Stat-Signature: gnkqd7mo5rhd5daxz9sp181pjjokzqa1 Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TGiYsfY3; spf=none (imf07.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-HE-Tag: 1651148028-66214 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: On 07.03.22 16:07, Oscar Salvador wrote: > 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 Sorry, I'm late with review. My mailbox got flooded. > --- > 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; > + Just a NIT: E.g., in zone_spanned_pages_in_node() we test for !node_start_pfn && !node_end_pfn In update_pgdat_span(), we set node_start_pfn = node_end_pfn = 0; when we find an empty node during memory unplug. Therefore, I wonder if a helper "is_memoryless_node()" or "node_empty()" might be reasonable, that just checks for either !node_start_pfn && !node_end_pfn or node_start_pfn == node_end_pfn > 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) We have another size check below. We essentially have right now: " if (!size) goto no_pages; [code] no_pages: zone_init_internals(zone, j, nid, freesize); if (!size) continue [more code] " IMHO, it would be nicer to avoid the label/goto by just doing a: " if (!size) { zone_init_internals(zone, j, nid, 0); continue; } [code] zone_init_internals(zone, j, nid, freesize); [more code] " Or factoring out [code] into a separate function. Anyhow, the change itself looks sane. -- Thanks, David / dhildenb