Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp335324ybg; Tue, 28 Jul 2020 07:16:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzocE4apLL1h76VcjgR09zjCs7/HEpUJ9fcfaIr10uO5J8uWBcpYzkjbidEwCQhHwDLAAag X-Received: by 2002:a05:6402:3137:: with SMTP id dd23mr10680464edb.230.1595945799956; Tue, 28 Jul 2020 07:16:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595945799; cv=none; d=google.com; s=arc-20160816; b=gEgshSjvZId1b6+WArQL2+bAJq0EtRJl+DJQ5lLssEm0SMkwWqFkSYvIdu7kWyTreZ 67k62fvRSaFtpUagohY/KRcjpBBc9NsbxyPFV3v37ggOt3dTUhrJGK2uCcswD7w/2Vv8 rh99JZ+8fj56tWp6JP4bjwZbksR7D76ncb3HzVntY1dlaj4oJaR/0v7Ljd/A1yNXP8Kc pU123vMICbpI2skNFHsOqsn4QBIUoxf9WB6e49EuTK9KucQ5ROALJBAaq8weXegGNY8v jCQPGn6k+j2WFCWWgCv27tBHo5TY6CbBrd9niKiAvQ4IvRBgpmwh+jiTfaSebxFMPSFi hU0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=fjUCMEwVRFUwKqF1DRAC93IF9L7iUyjw2vkFgXuGN7I=; b=xnNVcRfRaeOGtFBheq/GZGWLAc7HMxP9iTomfpgrPhAiLGoTt+Qohf+rTnevYu+uyR OBffKHZSfb2SFTE8TKPloBgmIj7ZqJsrT/6U5hgHtXZIrT6+LUaaeLWafi0SFL0uFnpu 18oxAZAFVqidDg/UdhfvKowXV13824HY+xf9Qz0xZg17DYPZTgYhwvklUi1A+kmg5B1g EIjigKFZZK5FrMlYhz7U6NgedYMy/vnHd3/IBme/dFQbDHqJ0eJAQ7lXQeGGsV4D2wlP 8rPt0Xta/EZh1LMyAcWw+ZB5YzmaSyhDsTOj8JEzOoj7WtKFKievWuLg/sBXLI2w4CLH fRKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QgGc4X7Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bq8si8475343ejb.52.2020.07.28.07.16.17; Tue, 28 Jul 2020 07:16:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QgGc4X7Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730343AbgG1OPW (ORCPT + 99 others); Tue, 28 Jul 2020 10:15:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:42926 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730012AbgG1OPU (ORCPT ); Tue, 28 Jul 2020 10:15:20 -0400 Received: from kernel.org (unknown [87.71.40.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7BC04206F5; Tue, 28 Jul 2020 14:15:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595945719; bh=lUPY2x+FC7QKHEsbHiDvmWaDq+mpMmmwkd+OggYom1s=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=QgGc4X7YUZ1ckDx2DS7TV0wJ9kprJKWkAHEon+OMgHl2R1sb+tkMTAcVnCBfWfbCy 0OtC+wiVDREvJNkkA1XcIE7jDME0kzNs1q63GPOaIsM59WTD15P6atSjYRp+nh+npo fGSf3gFWEKzBxONEs1GYYDPsR5qUaUEQHRNOUSzo= Date: Tue, 28 Jul 2020 17:15:04 +0300 From: Mike Rapoport To: Baoquan He Cc: Andrew Morton , Andy Lutomirski , Benjamin Herrenschmidt , Borislav Petkov , Catalin Marinas , Christoph Hellwig , Dave Hansen , Ingo Molnar , Marek Szyprowski , Max Filippov , Michael Ellerman , Michal Simek , Mike Rapoport , Palmer Dabbelt , Paul Mackerras , Paul Walmsley , Peter Zijlstra , Russell King , Stafford Horne , Thomas Gleixner , Will Deacon , Yoshinori Sato , clang-built-linux@googlegroups.com, iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-c6x-dev@linux-c6x.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linux-xtensa@linux-xtensa.org, linuxppc-dev@lists.ozlabs.org, openrisc@lists.librecores.org, sparclinux@vger.kernel.org, uclinux-h8-devel@lists.sourceforge.jp, x86@kernel.org Subject: Re: [PATCH 14/15] x86/numa: remove redundant iteration over memblock.reserved Message-ID: <20200728141504.GC3655207@kernel.org> References: <20200728051153.1590-1-rppt@kernel.org> <20200728051153.1590-15-rppt@kernel.org> <20200728110254.GA14854@MiWiFi-R3L-srv> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200728110254.GA14854@MiWiFi-R3L-srv> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 28, 2020 at 07:02:54PM +0800, Baoquan He wrote: > On 07/28/20 at 08:11am, Mike Rapoport wrote: > > From: Mike Rapoport > > > > numa_clear_kernel_node_hotplug() function first traverses numa_meminfo > > regions to set node ID in memblock.reserved and than traverses > > memblock.reserved to update reserved_nodemask to include node IDs that were > > set in the first loop. > > > > Remove redundant traversal over memblock.reserved and update > > reserved_nodemask while iterating over numa_meminfo. > > > > Signed-off-by: Mike Rapoport > > --- > > arch/x86/mm/numa.c | 26 ++++++++++---------------- > > 1 file changed, 10 insertions(+), 16 deletions(-) > > > > diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c > > index 8ee952038c80..4078abd33938 100644 > > --- a/arch/x86/mm/numa.c > > +++ b/arch/x86/mm/numa.c > > @@ -498,31 +498,25 @@ static void __init numa_clear_kernel_node_hotplug(void) > > * and use those ranges to set the nid in memblock.reserved. > > * This will split up the memblock regions along node > > * boundaries and will set the node IDs as well. > > + * > > + * The nid will also be set in reserved_nodemask which is later > > + * used to clear MEMBLOCK_HOTPLUG flag. > > + * > > + * [ Note, when booting with mem=nn[kMG] or in a kdump kernel, > > + * numa_meminfo might not include all memblock.reserved > > + * memory ranges, because quirks such as trim_snb_memory() > > + * reserve specific pages for Sandy Bridge graphics. > > + * These ranges will remain with nid == MAX_NUMNODES. ] > > */ > > for (i = 0; i < numa_meminfo.nr_blks; i++) { > > struct numa_memblk *mb = numa_meminfo.blk + i; > > int ret; > > > > ret = memblock_set_node(mb->start, mb->end - mb->start, &memblock.reserved, mb->nid); > > + node_set(mb->nid, reserved_nodemask); > > Really? This will set all node id into reserved_nodemask. But in the > current code, it's setting nid into memblock reserved region which > interleaves with numa_memoinfo, then get those nid and set it in > reserved_nodemask. This is so different, with my understanding. Please > correct me if I am wrong. You are right, I've missed the intersections of numa_meminfo with memblock.reserved. x86 interaction with membock is so, hmm, interesting... > Thanks > Baoquan > > > WARN_ON_ONCE(ret); > > } > > > > - /* > > - * Now go over all reserved memblock regions, to construct a > > - * node mask of all kernel reserved memory areas. > > - * > > - * [ Note, when booting with mem=nn[kMG] or in a kdump kernel, > > - * numa_meminfo might not include all memblock.reserved > > - * memory ranges, because quirks such as trim_snb_memory() > > - * reserve specific pages for Sandy Bridge graphics. ] > > - */ > > - for_each_memblock(reserved, mb_region) { > > - int nid = memblock_get_region_node(mb_region); > > - > > - if (nid != MAX_NUMNODES) > > - node_set(nid, reserved_nodemask); > > - } > > - > > /* > > * Finally, clear the MEMBLOCK_HOTPLUG flag for all memory > > * belonging to the reserved node mask. > > -- > > 2.26.2 > > > > > -- Sincerely yours, Mike.