From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A79C149C60; Mon, 5 Aug 2024 20:37:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722890261; cv=none; b=VyMGhhVCt9F5N+8ZsowL3bmWZaNNs1IUQN1p07TKxi0IEsOkPDp85rT2Eun7TSzwTN5Iiv8fa1LeveyEqJkpX56REfaQiQtIDeL3RJUP4FAsF0XVeQBH47jVcUFftc8XSa3h96K59jg0rE3ECNHbAnPM1f44obhjrpqp6AKVUvQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722890261; c=relaxed/simple; bh=qdRuOti9XNlLltkR78ltAp8iub7ZiaEGkve5ZQKgRXs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Pc04VQjcCngW/HvjKCfRW2IYnMJQ0cmyqcTO1Wc44W+q4zd6W4B5OpnnYGmJpPnKFBmt8AvgBHa3lViJHzJOv2zndQgO9ogdHuZZ+lQ7RlTeOsR50ukTmMnOcU/FaAre5qJFobpaKML6hxJIt09pAoq3F/WxWdgnWzu1zydv5t0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bF0xgt41; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bF0xgt41" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 087EBC4AF0E; Mon, 5 Aug 2024 20:37:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722890261; bh=qdRuOti9XNlLltkR78ltAp8iub7ZiaEGkve5ZQKgRXs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bF0xgt419GbxyCGFRj0fNjByi1OtMInAxUy0fO7kuEExoo6r6jeZMXGjN5ikPGLYH /M1nzHizackmgautp/VnDSLRxQXCurMyrYVEwg5Yf+PdgGkwhSt7ZiA1a6tEsPe3+w oJPfE55fHB91q50vVv1vV9hAXYemhAyhr6OpNgWOOvXUx9/9Vw4S7evidbf87YcNj+ pEPIiDW05PYUn8lRlujrJ1DKbY3WIHytjXuNelSTWpy7nXBiYR1lO2v9ZQh4g3aHrR PgFXkbijAdUJ0BywpuS1YJGB4AvPiLFgG1t0OrXdtLJEh5IFQJb88z75ZKH8cfv8oU ALk7ATW/rOneA== Date: Mon, 5 Aug 2024 23:35:22 +0300 From: Mike Rapoport To: Dan Williams Cc: linux-kernel@vger.kernel.org, Alexander Gordeev , Andreas Larsson , Andrew Morton , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christophe Leroy , Dave Hansen , David Hildenbrand , "David S. Miller" , Davidlohr Bueso , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Jonathan Corbet , Michael Ellerman , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Samuel Holland , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , Zi Yan , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-cxl@vger.kernel.org, linux-doc@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, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, nvdimm@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org Subject: Re: [PATCH v3 11/26] x86/numa: use get_pfn_range_for_nid to verify that node spans memory Message-ID: References: <20240801060826.559858-1-rppt@kernel.org> <20240801060826.559858-12-rppt@kernel.org> <66b1302ce5fd3_c1448294d3@dwillia2-xfh.jf.intel.com.notmuch> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <66b1302ce5fd3_c1448294d3@dwillia2-xfh.jf.intel.com.notmuch> On Mon, Aug 05, 2024 at 01:03:56PM -0700, Dan Williams wrote: > Mike Rapoport wrote: > > From: "Mike Rapoport (Microsoft)" > > > > Instead of looping over numa_meminfo array to detect node's start and > > end addresses use get_pfn_range_for_init(). > > > > This is shorter and make it easier to lift numa_memblks to generic code. > > > > Signed-off-by: Mike Rapoport (Microsoft) > > Tested-by: Zi Yan # for x86_64 and arm64 > > --- > > arch/x86/mm/numa.c | 13 +++---------- > > 1 file changed, 3 insertions(+), 10 deletions(-) > > > > diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c > > index edfc38803779..cfe7e5477cf8 100644 > > --- a/arch/x86/mm/numa.c > > +++ b/arch/x86/mm/numa.c > > @@ -521,17 +521,10 @@ static int __init numa_register_memblks(struct numa_meminfo *mi) > > > > /* Finally register nodes. */ > > for_each_node_mask(nid, node_possible_map) { > > - u64 start = PFN_PHYS(max_pfn); > > - u64 end = 0; > > + unsigned long start_pfn, end_pfn; > > > > - for (i = 0; i < mi->nr_blks; i++) { > > - if (nid != mi->blk[i].nid) > > - continue; > > - start = min(mi->blk[i].start, start); > > - end = max(mi->blk[i].end, end); > > - } > > - > > - if (start >= end) > > + get_pfn_range_for_nid(nid, &start_pfn, &end_pfn); > > + if (start_pfn >= end_pfn) > > Assuming I understand why this works, would it be worth a comment like: > > "Note, get_pfn_range_for_nid() depends on memblock_set_node() having > already happened" Will add a comment, sure. > ...at least that context was not part of the diff so took me second to > figure out how this works. > -- Sincerely yours, Mike. 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D188FC3DA7F for ; Mon, 5 Aug 2024 20:38:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=g88SwNQSqNmprQLxFADQDwZsEAGrJP39M/r4XUjncEI=; b=XmzU92eWpE+e4E tgl5cvW5eGTenblsbUblwdo4XHVn8eQT7M/nAiZ9f07T5mS3K3JJX+/9TTBezUfa92sIwt0OJ5OVb 7ek1SZ0hxgZE+aUDP8EtTe9vSsfeQGolzU40feYGiFgW1+EpQ93j0oAowoFW2/M4/z4lrLqPdXvU+ 5S/wC4vYh1JsILMkQT9w3TubucxNK1/BeWgOSkhTzaEgOUM4lQv5EBwsFk5XyhzmykcxEUvQgW/ss 74Z9+7PMnhBqyWM8bDu+XytZO2/OprxN1yepnUmymeu33wUR6/NtwP6XbL6b62HeTazWyga5121Rv XXKfFaI3ivAucseFwaRw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sb4TA-0000000HE2j-1Rqg; Mon, 05 Aug 2024 20:38:16 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sb4Sc-0000000HDse-22kq; Mon, 05 Aug 2024 20:37:43 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id AD1AD60DD2; Mon, 5 Aug 2024 20:37:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 087EBC4AF0E; Mon, 5 Aug 2024 20:37:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722890261; bh=qdRuOti9XNlLltkR78ltAp8iub7ZiaEGkve5ZQKgRXs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bF0xgt419GbxyCGFRj0fNjByi1OtMInAxUy0fO7kuEExoo6r6jeZMXGjN5ikPGLYH /M1nzHizackmgautp/VnDSLRxQXCurMyrYVEwg5Yf+PdgGkwhSt7ZiA1a6tEsPe3+w oJPfE55fHB91q50vVv1vV9hAXYemhAyhr6OpNgWOOvXUx9/9Vw4S7evidbf87YcNj+ pEPIiDW05PYUn8lRlujrJ1DKbY3WIHytjXuNelSTWpy7nXBiYR1lO2v9ZQh4g3aHrR PgFXkbijAdUJ0BywpuS1YJGB4AvPiLFgG1t0OrXdtLJEh5IFQJb88z75ZKH8cfv8oU ALk7ATW/rOneA== Date: Mon, 5 Aug 2024 23:35:22 +0300 From: Mike Rapoport To: Dan Williams Cc: linux-kernel@vger.kernel.org, Alexander Gordeev , Andreas Larsson , Andrew Morton , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christophe Leroy , Dave Hansen , David Hildenbrand , "David S. Miller" , Davidlohr Bueso , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Jonathan Cameron , Jonathan Corbet , Michael Ellerman , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Samuel Holland , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , Zi Yan , devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-cxl@vger.kernel.org, linux-doc@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, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, nvdimm@lists.linux.dev, sparclinux@vger.kernel.org, x86@kernel.org Subject: Re: [PATCH v3 11/26] x86/numa: use get_pfn_range_for_nid to verify that node spans memory Message-ID: References: <20240801060826.559858-1-rppt@kernel.org> <20240801060826.559858-12-rppt@kernel.org> <66b1302ce5fd3_c1448294d3@dwillia2-xfh.jf.intel.com.notmuch> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <66b1302ce5fd3_c1448294d3@dwillia2-xfh.jf.intel.com.notmuch> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240805_133742_679900_3EEB7207 X-CRM114-Status: GOOD ( 24.02 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On Mon, Aug 05, 2024 at 01:03:56PM -0700, Dan Williams wrote: > Mike Rapoport wrote: > > From: "Mike Rapoport (Microsoft)" > > > > Instead of looping over numa_meminfo array to detect node's start and > > end addresses use get_pfn_range_for_init(). > > > > This is shorter and make it easier to lift numa_memblks to generic code. > > > > Signed-off-by: Mike Rapoport (Microsoft) > > Tested-by: Zi Yan # for x86_64 and arm64 > > --- > > arch/x86/mm/numa.c | 13 +++---------- > > 1 file changed, 3 insertions(+), 10 deletions(-) > > > > diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c > > index edfc38803779..cfe7e5477cf8 100644 > > --- a/arch/x86/mm/numa.c > > +++ b/arch/x86/mm/numa.c > > @@ -521,17 +521,10 @@ static int __init numa_register_memblks(struct numa_meminfo *mi) > > > > /* Finally register nodes. */ > > for_each_node_mask(nid, node_possible_map) { > > - u64 start = PFN_PHYS(max_pfn); > > - u64 end = 0; > > + unsigned long start_pfn, end_pfn; > > > > - for (i = 0; i < mi->nr_blks; i++) { > > - if (nid != mi->blk[i].nid) > > - continue; > > - start = min(mi->blk[i].start, start); > > - end = max(mi->blk[i].end, end); > > - } > > - > > - if (start >= end) > > + get_pfn_range_for_nid(nid, &start_pfn, &end_pfn); > > + if (start_pfn >= end_pfn) > > Assuming I understand why this works, would it be worth a comment like: > > "Note, get_pfn_range_for_nid() depends on memblock_set_node() having > already happened" Will add a comment, sure. > ...at least that context was not part of the diff so took me second to > figure out how this works. > -- Sincerely yours, Mike. _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv 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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 423D3C3DA4A for ; Mon, 5 Aug 2024 20:38:26 +0000 (UTC) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=bF0xgt41; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Wd7Yr6Nvmz3cfB for ; Tue, 6 Aug 2024 06:38:24 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=bF0xgt41; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=139.178.84.217; helo=dfw.source.kernel.org; envelope-from=rppt@kernel.org; receiver=lists.ozlabs.org) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Wd7Y44kbqz3cRF for ; Tue, 6 Aug 2024 06:37:44 +1000 (AEST) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id AD1AD60DD2; Mon, 5 Aug 2024 20:37:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 087EBC4AF0E; Mon, 5 Aug 2024 20:37:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722890261; bh=qdRuOti9XNlLltkR78ltAp8iub7ZiaEGkve5ZQKgRXs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bF0xgt419GbxyCGFRj0fNjByi1OtMInAxUy0fO7kuEExoo6r6jeZMXGjN5ikPGLYH /M1nzHizackmgautp/VnDSLRxQXCurMyrYVEwg5Yf+PdgGkwhSt7ZiA1a6tEsPe3+w oJPfE55fHB91q50vVv1vV9hAXYemhAyhr6OpNgWOOvXUx9/9Vw4S7evidbf87YcNj+ pEPIiDW05PYUn8lRlujrJ1DKbY3WIHytjXuNelSTWpy7nXBiYR1lO2v9ZQh4g3aHrR PgFXkbijAdUJ0BywpuS1YJGB4AvPiLFgG1t0OrXdtLJEh5IFQJb88z75ZKH8cfv8oU ALk7ATW/rOneA== Date: Mon, 5 Aug 2024 23:35:22 +0300 From: Mike Rapoport To: Dan Williams Subject: Re: [PATCH v3 11/26] x86/numa: use get_pfn_range_for_nid to verify that node spans memory Message-ID: References: <20240801060826.559858-1-rppt@kernel.org> <20240801060826.559858-12-rppt@kernel.org> <66b1302ce5fd3_c1448294d3@dwillia2-xfh.jf.intel.com.notmuch> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <66b1302ce5fd3_c1448294d3@dwillia2-xfh.jf.intel.com.notmuch> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nvdimm@lists.linux.dev, x86@kernel.org, Andreas Larsson , Catalin Marinas , Dave Hansen , David Hildenbrand , Jiaxun Yang , linux-mips@vger.kernel.org, linux-mm@kvack.org, sparclinux@vger.kernel.org, Alexander Gordeev , Will Deacon , linux-riscv@lists.infradead.org, linux-arch@vger.kernel.org, Rob Herring , Davidlohr Bueso , Vasily Gorbik , Jonathan Corbet , linux-sh@vger.kernel.org, Huacai Chen , Christophe Leroy , linux-acpi@vger.kernel.org, Ingo Molnar , Zi Yan , devicetree@vger.kernel.org, Arnd Bergmann , linux-s390@vger.kernel.org, Heiko Carstens , Borislav Petkov , linux-cxl@vger.kernel.org, loongarch@lists.linux.dev, John Paul Adrian Glaubitz , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, Thomas Bogendoerfer , Greg Kroah-Hartman , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Samuel Holland , Palmer Dabbelt , Jonathan Cameron , "Rafael J. Wysocki" , Andrew Morton , linuxppc-dev@lists.ozlabs.org, "David S. Miller" Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Mon, Aug 05, 2024 at 01:03:56PM -0700, Dan Williams wrote: > Mike Rapoport wrote: > > From: "Mike Rapoport (Microsoft)" > > > > Instead of looping over numa_meminfo array to detect node's start and > > end addresses use get_pfn_range_for_init(). > > > > This is shorter and make it easier to lift numa_memblks to generic code. > > > > Signed-off-by: Mike Rapoport (Microsoft) > > Tested-by: Zi Yan # for x86_64 and arm64 > > --- > > arch/x86/mm/numa.c | 13 +++---------- > > 1 file changed, 3 insertions(+), 10 deletions(-) > > > > diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c > > index edfc38803779..cfe7e5477cf8 100644 > > --- a/arch/x86/mm/numa.c > > +++ b/arch/x86/mm/numa.c > > @@ -521,17 +521,10 @@ static int __init numa_register_memblks(struct numa_meminfo *mi) > > > > /* Finally register nodes. */ > > for_each_node_mask(nid, node_possible_map) { > > - u64 start = PFN_PHYS(max_pfn); > > - u64 end = 0; > > + unsigned long start_pfn, end_pfn; > > > > - for (i = 0; i < mi->nr_blks; i++) { > > - if (nid != mi->blk[i].nid) > > - continue; > > - start = min(mi->blk[i].start, start); > > - end = max(mi->blk[i].end, end); > > - } > > - > > - if (start >= end) > > + get_pfn_range_for_nid(nid, &start_pfn, &end_pfn); > > + if (start_pfn >= end_pfn) > > Assuming I understand why this works, would it be worth a comment like: > > "Note, get_pfn_range_for_nid() depends on memblock_set_node() having > already happened" Will add a comment, sure. > ...at least that context was not part of the diff so took me second to > figure out how this works. > -- Sincerely yours, Mike.