Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3530311ybb; Tue, 31 Mar 2020 07:08:11 -0700 (PDT) X-Google-Smtp-Source: ADFU+vu/tx18C8V55edroRV6vuk/4mmF7pSw+AcvkTtwmhCEcIAT9pwnzKFFzo9R6FlZ0dcMrcv/ X-Received: by 2002:aca:484c:: with SMTP id v73mr2050512oia.138.1585663691604; Tue, 31 Mar 2020 07:08:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585663691; cv=none; d=google.com; s=arc-20160816; b=SbviimO+eQzUl6fXBwa5FBTfl38w3uHVwYS3g0wJUhMyZXwHc2RV/bE0p67G2mDfo2 X89e0rI9tGb0BHHMbhWbSBJBAObiyDSyLqaZbUqZw7e1ZlIEOehiozymw2QNGsfWCjap LmbyP0S6qQWly2p5rkQwHtsH4n1/2h6uH2rOcAMm52mrrooVs8mK+IHHKOB23VSVdZXB M36mGWMfsboxoU2TVFKPSaLb8LyA8iyEdFXSFwUI4vMglZWUtvyLXD5D4J/mkMXzbXlK YiTI034A7WWgkrLwot/x9caeOzLNsBSebfgFVPsqcCGBSz6SoHjGlLUwJvncICA4eitu OmRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=KCZob0/LBRxC1X3ExJ7YgbkD9QNtWVeW3MS6pGS5Hm0=; b=xoo/ROFEeMBRggWpvkjlH1IlOeUV1XKPX3XOufLGlC1s2/jTU/63/YtraI4JAjfG4P 3TF/Eeo/3FIomtSn5i/fXl402VO9WjsodSSg4nuq92hqhqzCH0wvZvc8NmwwoToIyDCm Hg9zGKpNVKQDSsiO0WeHX8sOcI66gmhid/JJlnk0kW53i5e26zfqjrG56t37X0eKjGTf JJVB5FGfQPwhxsC8G0vQzQoejkc5XKibBjNtmUj/swxhLRJtIUVX8kCxCHbnK6kXLGaQ Uep8qTvCqqDUpCWHvIIlQCB0JR2hSiMLcyVRWsyWCE1MsvIZW7GenudlGjODomm+kguw YJBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Tbe4haT2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a12si6678798otf.272.2020.03.31.07.07.44; Tue, 31 Mar 2020 07:08:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Tbe4haT2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731057AbgCaOEe (ORCPT + 99 others); Tue, 31 Mar 2020 10:04:34 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:59476 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731048AbgCaOEd (ORCPT ); Tue, 31 Mar 2020 10:04:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585663473; 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: in-reply-to:in-reply-to:references:references; bh=KCZob0/LBRxC1X3ExJ7YgbkD9QNtWVeW3MS6pGS5Hm0=; b=Tbe4haT2uNeVSYm5cIj191ydfjEGWKQnCdLg6G013xj2jKU0imXQzCD9plJy5KnG5725Qp 4UAvSmfs/cpJveo3irvqLwYyZ4atBGw6HXmGmSzmPlavVVcLtEMzHhZuqObyMNfWn6ZA4B /QqL6MY+1C/U8Bv5XaWLKCN1J6BsQSo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-354-La1ubasMNmmujyoYcqk85g-1; Tue, 31 Mar 2020 10:04:29 -0400 X-MC-Unique: La1ubasMNmmujyoYcqk85g-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 18D9E108E9E2; Tue, 31 Mar 2020 14:03:39 +0000 (UTC) Received: from localhost (ovpn-13-64.pek2.redhat.com [10.72.13.64]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0102960BFE; Tue, 31 Mar 2020 14:03:34 +0000 (UTC) Date: Tue, 31 Mar 2020 22:03:32 +0800 From: Baoquan He To: Michal Hocko Cc: Mike Rapoport , Hoan Tran , Catalin Marinas , Will Deacon , Andrew Morton , Vlastimil Babka , Oscar Salvador , Pavel Tatashin , Alexander Duyck , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , "David S. Miller" , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , "open list:MEMORY MANAGEMENT" , linux-arm-kernel@lists.infradead.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org, x86@kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, lho@amperecomputing.com, mmorana@amperecomputing.com Subject: Re: [PATCH v3 0/5] mm: Enable CONFIG_NODES_SPAN_OTHER_NODES by default for NUMA Message-ID: <20200331140332.GA2129@MiWiFi-R3L-srv> References: <1585420282-25630-1-git-send-email-Hoan@os.amperecomputing.com> <20200330074246.GA14243@dhcp22.suse.cz> <20200330175100.GD30942@linux.ibm.com> <20200330182301.GM14243@dhcp22.suse.cz> <20200331081423.GE30942@linux.ibm.com> <20200331085513.GE30449@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200331085513.GE30449@dhcp22.suse.cz> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Michal, On 03/31/20 at 10:55am, Michal Hocko wrote: > On Tue 31-03-20 11:14:23, Mike Rapoport wrote: > > Maybe I mis-read the code, but I don't see how this could happen. In the > > HAVE_MEMBLOCK_NODE_MAP=y case, free_area_init_node() calls > > calculate_node_totalpages() that ensures that node->node_zones are entirely > > within the node because this is checked in zone_spanned_pages_in_node(). > > zone_spanned_pages_in_node does chech the zone boundaries are within the > node boundaries. But that doesn't really tell anything about other > potential zones interleaving with the physical memory range. > zone->spanned_pages simply gives the physical range for the zone > including holes. Interleaving nodes are essentially a hole > (__absent_pages_in_range is going to skip those). > > That means that when free_area_init_core simply goes over the whole > physical zone range including holes and that is why we need to check > both for physical and logical holes (aka other nodes). > > The life would be so much easier if the whole thing would simply iterate > over memblocks... The memblock iterating sounds a great idea. I tried with putting the memblock iterating in the upper layer, memmap_init(), which is used for boot mem only anyway. Do you think it's doable and OK? It yes, I can work out a formal patch to make this simpler as you said. The draft code is as below. Like this it uses the existing code and involves little change. diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 138a56c0f48f..558d421f294b 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6007,14 +6007,6 @@ void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone, * function. They do not exist on hotplugged memory. */ if (context == MEMMAP_EARLY) { - if (!early_pfn_valid(pfn)) { - pfn = next_pfn(pfn); - continue; - } - if (!early_pfn_in_nid(pfn, nid)) { - pfn++; - continue; - } if (overlap_memmap_init(zone, &pfn)) continue; if (defer_init(nid, pfn, end_pfn)) @@ -6130,9 +6122,17 @@ static void __meminit zone_init_free_lists(struct zone *zone) } void __meminit __weak memmap_init(unsigned long size, int nid, - unsigned long zone, unsigned long start_pfn) + unsigned long zone, unsigned long range_start_pfn) { - memmap_init_zone(size, nid, zone, start_pfn, MEMMAP_EARLY, NULL); + unsigned long start_pfn, end_pfn; + unsigned long range_end_pfn = range_start_pfn + size; + int i; + for_each_mem_pfn_range(i, nid, &start_pfn, &end_pfn, NULL) { + start_pfn = clamp(start_pfn, range_start_pfn, range_end_pfn); + end_pfn = clamp(end_pfn, range_start_pfn, range_end_pfn); + if (end_pfn > start_pfn) + memmap_init_zone(size, nid, zone, start_pfn, MEMMAP_EARLY, NULL); + } } static int zone_batchsize(struct zone *zone)