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 082FFC3DA5D for ; Mon, 22 Jul 2024 07:38:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=u8pyhZF8JePcVWlxZmDuXf307f3nQV2zunDHCr7yCXI=; b=40TZuEz1seOC9fF5QnKL4kaamp 1/4m6IpE6O/LL7BzOUcLrXrZsGHwC0FoPKPjp1+NTt5vnk/YVUfidzaDhHfdy8BAsV2GEX6PuHnrF ZBMFUpt6SRK3rsUFhWIuBIRkiijtKwjoMWKM0/LYiKC2XiHKW2IdwiVtmTkW2PYI4uT7llOHzZfef TznZHHDNMpqqnhBNxgM3PHABfEy+S6EiI/XtxjhPwKaI7X0+FbNsFOihQclSq1HoG5yEKAQZ9oJj/ aN4Yenj3EkRAefANrw7vaVBeXfOFsV3FpQLgo+DI9eOMwhSP5vq1MafEuO0YpRF9LoVbVOTCH9qUl Gmv83EBg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sVnc8-00000008jP1-2Gju; Mon, 22 Jul 2024 07:37:44 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sVnbj-00000008jEw-3h1a; Mon, 22 Jul 2024 07:37:21 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 7105ECE0B0A; Mon, 22 Jul 2024 07:37:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2C14EC116B1; Mon, 22 Jul 2024 07:37:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721633837; bh=Dxslf8J1nw2EoO1825aVEeJAxLrpHgQU1wjgg+XF/0U=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=V5rEoxjJyp8Si4Ol1tKmDHfxujD1M6arK5yB3md41TgtMqzL7133QUbpMAiRqALI8 zHqP2jnhANmIGx1K6HRYtObkAQqmVJ2vQFti7pCzHaOzz0dds7xFt2urt534cJHiXw CurmUQ1pi3n/TpSSCUqTSIn7TV/EpAfGuHiiiLk6U01osyb6JXJ0yznQ72y9r7YmE5 p6fsNYiqRdEsZWZ4qQtfi/2IxHr6rbbdo6JlW+fM0tWjobtA9os1Uj3kz7eGY4SLEa ISuNDqsn9MvH468ghs8RFDYohLKYRIm2o5BjdJ/Ni63NJJU1x+XnEdyepZgDkMsXF7 by+28UouvqBSA== Date: Mon, 22 Jul 2024 10:34:06 +0300 From: Mike Rapoport To: Jonathan Cameron Cc: David Hildenbrand , linux-kernel@vger.kernel.org, Alexander Gordeev , Andreas Larsson , Andrew Morton , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christophe Leroy , Dan Williams , Dave Hansen , "David S. Miller" , Greg Kroah-Hartman , Heiko Carstens , Huacai Chen , Ingo Molnar , Jiaxun Yang , John Paul Adrian Glaubitz , Michael Ellerman , Palmer Dabbelt , "Rafael J. Wysocki" , Rob Herring , Thomas Bogendoerfer , Thomas Gleixner , Vasily Gorbik , Will Deacon , linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-acpi@vger.kernel.org, linux-cxl@vger.kernel.org, nvdimm@lists.linux.dev, devicetree@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org Subject: Re: [PATCH 02/17] MIPS: sgi-ip27: make NODE_DATA() the same as on all other architectures Message-ID: References: <20240716111346.3676969-1-rppt@kernel.org> <20240716111346.3676969-3-rppt@kernel.org> <20240719153852.00003f44@Huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240719153852.00003f44@Huawei.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240722_003720_305736_F39F9FD9 X-CRM114-Status: GOOD ( 33.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Jul 19, 2024 at 03:38:52PM +0100, Jonathan Cameron wrote: > On Wed, 17 Jul 2024 16:32:59 +0200 > David Hildenbrand wrote: > > > On 16.07.24 13:13, Mike Rapoport wrote: > > > From: "Mike Rapoport (Microsoft)" > > > > > > sgi-ip27 is the only system that defines NODE_DATA() differently than > > > the rest of NUMA machines. > > > > > > Add node_data array of struct pglist pointers that will point to > > > __node_data[node]->pglist and redefine NODE_DATA() to use node_data > > > array. > > > > > > This will allow pulling declaration of node_data to the generic mm code > > > in the next commit. > > > > > > Signed-off-by: Mike Rapoport (Microsoft) > > > --- > > > arch/mips/include/asm/mach-ip27/mmzone.h | 5 ++++- > > > arch/mips/sgi-ip27/ip27-memory.c | 5 ++++- > > > 2 files changed, 8 insertions(+), 2 deletions(-) > > > > > > diff --git a/arch/mips/include/asm/mach-ip27/mmzone.h b/arch/mips/include/asm/mach-ip27/mmzone.h > > > index 08c36e50a860..629c3f290203 100644 > > > --- a/arch/mips/include/asm/mach-ip27/mmzone.h > > > +++ b/arch/mips/include/asm/mach-ip27/mmzone.h > > > @@ -22,7 +22,10 @@ struct node_data { > > > > > > extern struct node_data *__node_data[]; > > > > > > -#define NODE_DATA(n) (&__node_data[(n)]->pglist) > > > #define hub_data(n) (&__node_data[(n)]->hub) > > > > > > +extern struct pglist_data *node_data[]; > > > + > > > +#define NODE_DATA(nid) (node_data[nid]) > > > + > > > #endif /* _ASM_MACH_MMZONE_H */ > > > diff --git a/arch/mips/sgi-ip27/ip27-memory.c b/arch/mips/sgi-ip27/ip27-memory.c > > > index b8ca94cfb4fe..c30ef6958b97 100644 > > > --- a/arch/mips/sgi-ip27/ip27-memory.c > > > +++ b/arch/mips/sgi-ip27/ip27-memory.c > > > @@ -34,8 +34,10 @@ > > > #define SLOT_PFNSHIFT (SLOT_SHIFT - PAGE_SHIFT) > > > #define PFN_NASIDSHFT (NASID_SHFT - PAGE_SHIFT) > > > > > > -struct node_data *__node_data[MAX_NUMNODES]; > > > +struct pglist_data *node_data[MAX_NUMNODES]; > > > +EXPORT_SYMBOL(node_data); > > > > > > +struct node_data *__node_data[MAX_NUMNODES]; > > > EXPORT_SYMBOL(__node_data); > > > > > > static u64 gen_region_mask(void) > > > @@ -361,6 +363,7 @@ static void __init node_mem_init(nasid_t node) > > > */ > > > __node_data[node] = __va(slot_freepfn << PAGE_SHIFT); > > > memset(__node_data[node], 0, PAGE_SIZE); > > > + node_data[node] = &__node_data[node]->pglist; > > > > > > NODE_DATA(node)->node_start_pfn = start_pfn; > > > NODE_DATA(node)->node_spanned_pages = end_pfn - start_pfn; > > > > I was assuming we could get rid of __node_data->pglist. > > > > But now I am confused where that is actually set. > > It looks nasty... Nasty indeed :) > Cast in arch_refresh_nodedata() takes incoming pg_data_t * and casts it > to the local version of struct node_data * which I think is this one > > struct node_data { > struct pglist_data pglist; (which is pg_data_t pglist) > struct hub_data hub; > }; > > https://elixir.bootlin.com/linux/v6.10/source/arch/mips/sgi-ip27/ip27-memory.c#L432 > > Now that pg_data_t is allocated by > arch_alloc_nodedata() which might be fine (though types could be handled in a more > readable fashion via some container_of() magic. > https://elixir.bootlin.com/linux/v6.10/source/arch/mips/sgi-ip27/ip27-memory.c#L427 > > However that call is: > pg_data_t * __init arch_alloc_nodedata(int nid) > { > return memblock_alloc(sizeof(pg_data_t), SMP_CACHE_BYTES); > } > > So doesn't seem to allocate enough space to me as should be sizeof(struct node_data) Well, it's there to silence a compiler error (commit f8f9f21c7848 ("MIPS: Fix build error for loongson64 and sgi-ip27")), but this is not a proper fix :( Luckily nothing calls cpumask_of_node() for offline nodes... > Worth cleaning up whilst here? Proper handling of types would definitely > help. Worth cleanup indeed, but I'd rather drop arch_alloc_nodedata() on MIPS altogether. > Jonathan -- Sincerely yours, Mike.