fix topology initialization
PATCH 1/1 fix topology initialization
Now that NUMA kernels are working we can properly initialze the topology information so that /sys/devices/system/node* & friends aren't empty.
In doing this I found some circular dependencies, so I removed nodedata.h and did some forward declarations because I figured cleaning them up properly is something that can wait until after 2.6.
Jesse
arch/ia64/mm/numa.c +47 -0
@@ -11,12 +11,20 @@*/ #include <linux/config.h> +#include <linux/cpu.h> #include <linux/kernel.h> #include <linux/mm.h> +#include <linux/memblk.h> +#include <linux/node.h> #include <linux/init.h> #include <linux/bootmem.h> +#include <linux/topology.h> #include <asm/numa.h> +struct memblk *sysfs_memblks;; +struct node *sysfs_nodes; +struct cpu *sysfs_cpus; +/* * The following structures are usually initialized by ACPI or * similar mechanisms and describe the NUMA characteristics of the machine.
@@ -43,3 +51,42 @@return (i < num_memblks) ? node_memblk[i].nid : (num_memblks ?-1 :0 ); } + +int __init topology_init (void ) +{ +int i, err =0 ; + + sysfs_nodes =kmalloc (sizeof (struct node ) * numnodes,GFP_KERNEL ); +if (!sysfs_nodes) +return -ENOMEM ; + + sysfs_memblks =kmalloc (sizeof (struct memblk ) * num_memblks, +GFP_KERNEL ); +if (!sysfs_memblks) { +kfree (sysfs_nodes); +return -ENOMEM ; + } + + sysfs_cpus =kmalloc (sizeof (struct cpu ) *NR_CPUS ,GFP_KERNEL ); +if (!sysfs_cpus) { +kfree (sysfs_memblks); +kfree (sysfs_nodes); +return -ENOMEM ; + } + +for (i =0 ; i < numnodes; i++) + err =register_node (&sysfs_nodes[i], i,0 ); + +for (i =0 ; i < num_memblks; i++) + err =register_memblk (&sysfs_memblks[i], i, + &sysfs_nodes[memblk_to_node (i)]); + +for (i =0 ; i <NR_CPUS ; i++) +if (cpu_online (i)) + err =register_cpu (&sysfs_cpus[i], i, + &sysfs_nodes[cpu_to_node (i)]); + +return err; +} + +__initcall (topology_init);
arch/ia64/sn/kernel/bte.c +1 -1
@@ -39,7 +39,7 @@#include <asm/sn/sn_cpuid.h> #include <asm/sn/pda.h> #include <asm/sn/sn2/shubio.h> -#include <asm/nodedata.h> +#include <asm/mmzone.h> #include <linux/bootmem.h> #include <linux/string.h>
include/asm-ia64/mmzone.h +11 -1
@@ -12,8 +12,9 @@#define _ASM_IA64_MMZONE_H#include <linux/config.h> -#include <asm/page.h> #include <asm/meminit.h> +#include <asm/page.h> +#include <asm/percpu.h> #ifdef CONFIG_DISCONTIGMEM
@@ -32,6 +33,15 @@#define pfn_valid (pfn) (((pfn) < max_low_pfn) && ia64_pfn_valid(pfn))#define page_to_pfn (page) ((unsigned long) (page - vmem_map))#define pfn_to_page (pfn) (vmem_map + (pfn)) + +struct ia64_node_data { +short active_cpu_count; +short node; +struct pglist_data *pg_data_ptrs[NR_NODES ]; +}; + +#define local_node_data (local_cpu_data->node_data) +#define NODE_DATA (nid) (local_node_data->pg_data_ptrs[nid])#endif /* CONFIG_DISCONTIGMEM */ #endif /* _ASM_IA64_MMZONE_H */
include/asm-ia64/nodedata.h deleted +0 -52
52 lines not on this page · raw message
include/asm-ia64/processor.h +0 -3
@@ -95,9 +95,6 @@#include <asm/rse.h> #include <asm/unwind.h> #include <asm/atomic.h> -#ifdef CONFIG_NUMA -#include <asm/nodedata.h> -#endif /* like above but expressed as bitfields for more efficient access: */ struct ia64_psr {
include/asm-ia64/sn/sn_cpuid.h +0 -1
@@ -17,7 +17,6 @@#include <linux/mmzone.h> #include <asm/sn/types.h> #include <asm/current.h> -#include <asm/nodedata.h> #include <asm/sn/pda.h>
include/asm-ia64/topology.h +8 -0
@@ -13,6 +13,7 @@#ifndef _ASM_IA64_TOPOLOGY_H#define _ASM_IA64_TOPOLOGY_H +#include <linux/config.h> #include <asm/acpi.h> #include <asm/numa.h> #include <asm/smp.h>
@@ -63,5 +64,12 @@#endif /* CONFIG_NUMA */ #include <asm-generic/topology.h> + +struct memblk ; +struct node ; +struct cpu ; +extern struct memblk *sysfs_memblks; +extern struct node *sysfs_nodes; +extern struct cpu *sysfs_cpus;#endif /* _ASM_IA64_TOPOLOGY_H */
Please ignore this bogus patch. I'll resend in a minute w/o all the unnecessary crap.
Thanks,
Jesse
Quoted 223 lines · jbarnes
Now that NUMA kernels are working we can properly initialze the topology information so that
/sys/devices/system/node*& friends aren't empty.In doing this I found some circular dependencies, so I removed
nodedata.hand did some forward declarations because I figured cleaning them up properly is something that can wait until after 2.6.Jesse
diff -Nru
a/arch/ia64/mm/numa.cb/arch/ia64/mm/numa.carch/ia64/mm/numa.c +47
-0@@ -11,12 +11,20 @@*/ #include <linux/config.h> +#include <linux/cpu.h> #include <linux/kernel.h> #include <linux/mm.h> +#include <linux/memblk.h> +#include <linux/node.h> #include <linux/init.h> #include <linux/bootmem.h> +#include <linux/topology.h> #include <asm/numa.h> +struct memblk *sysfs_memblks;; +struct node *sysfs_nodes; +struct cpu *sysfs_cpus; +/* * The following structures are usually initialized by ACPI or * similar mechanisms and describe the NUMA characteristics of the machine. @@ -43,3 +51,42 @@return (i < num_memblks) ? node_memblk[i].nid : (num_memblks ?-1 :0 ); } + +int __init topology_init (void ) +{ +int i, err =0 ; + + sysfs_nodes =kmalloc (sizeof (struct node ) * numnodes,GFP_KERNEL ); +if (!sysfs_nodes) +return -ENOMEM ; + + sysfs_memblks =kmalloc (sizeof (struct memblk ) * num_memblks, +GFP_KERNEL ); +if (!sysfs_memblks) { +kfree (sysfs_nodes); +return -ENOMEM ; + } + + sysfs_cpus =kmalloc (sizeof (struct cpu ) *NR_CPUS ,GFP_KERNEL ); +if (!sysfs_cpus) { +kfree (sysfs_memblks); +kfree (sysfs_nodes); +return -ENOMEM ; + } + +for (i =0 ; i < numnodes; i++) + err =register_node (&sysfs_nodes[i], i,0 ); + +for (i =0 ; i < num_memblks; i++) + err =register_memblk (&sysfs_memblks[i], i, + &sysfs_nodes[memblk_to_node (i)]); + +for (i =0 ; i <NR_CPUS ; i++) +if (cpu_online (i)) + err =register_cpu (&sysfs_cpus[i], i, + &sysfs_nodes[cpu_to_node (i)]); + +return err; +} + +__initcall (topology_init);diff -Nru
a/arch/ia64/sn/kernel/bte.cb/arch/ia64/sn/kernel/bte.carch/ia64/sn/kernel/bte.c +1
-1@@ -39,7 +39,7 @@#include <asm/sn/sn_cpuid.h> #include <asm/sn/pda.h> #include <asm/sn/sn2/shubio.h> -#include <asm/nodedata.h> +#include <asm/mmzone.h> #include <linux/bootmem.h> #include <linux/string.h> diff -Nru
a/include/asm-ia64/mmzone.hb/include/asm-ia64/mmzone.hinclude/asm-ia64/mmzone.h +11
-1@@ -12,8 +12,9 @@#define _ASM_IA64_MMZONE_H#include <linux/config.h> -#include <asm/page.h> #include <asm/meminit.h> +#include <asm/page.h> +#include <asm/percpu.h> #ifdef CONFIG_DISCONTIGMEM @@ -32,6 +33,15 @@#define pfn_valid (pfn) (((pfn) < max_low_pfn) && ia64_pfn_valid(pfn))#define page_to_pfn (page) ((unsigned long) (page - vmem_map))#define pfn_to_page (pfn) (vmem_map + (pfn)) + +struct ia64_node_data { +short active_cpu_count; +short node; +struct pglist_data *pg_data_ptrs[NR_NODES ]; +}; + +#define local_node_data (local_cpu_data->node_data) +#define NODE_DATA (nid) (local_node_data->pg_data_ptrs[nid])#endif /* CONFIG_DISCONTIGMEM */ #endif /* _ASM_IA64_MMZONE_H */ diff -Nru
a/include/asm-ia64/nodedata.hb/include/asm-ia64/nodedata.hinclude/asm-ia64/nodedata.h deleted +0
-52@@ -1,52 +0,0 @@ -/* -* This file is subject to the terms and conditions of the GNU General Public -* License. See the file "COPYING" in the main directory of this archive -* for more details. -* -* Copyright (c) 2000 Silicon Graphics, Inc. All rights reserved. -* Copyright (c) 2002 NEC Corp. -* Copyright (c) 2002 Erich Focht <[email protected]> -* Copyright (c) 2002 Kimio Suganuma <[email protected]> -*/ -#ifndef _ASM_IA64_NODEDATA_H -#define _ASM_IA64_NODEDATA_H - -#include <linux/config.h> -#include <linux/numa.h> - -#include <asm/percpu.h> -#include <asm/mmzone.h> - -#ifdef CONFIG_DISCONTIGMEM - -/* -* Node Data. One of these structures is located on each node of a NUMA system. -*/ - -struct pglist_data ; -struct ia64_node_data { -short active_cpu_count; -short node; -struct pglist_data *pg_data_ptrs[NR_NODES ]; -}; - - -/* -* Return a pointer to the node_data structure for the executing cpu. -*/ -#define local_node_data (local_cpu_data->node_data) - -/* -* Given a node id, return a pointer to the pg_data_t for the node. -* -* NODE_DATA - should be used in all code not related to system -* initialization. It uses pernode data structures to minimize -* offnode memory references. However, these structure are not -* present during boot. This macro can be used once cpu_init -* completes. -*/ -#define NODE_DATA (nid) (local_node_data->pg_data_ptrs[nid]) - -#endif /* CONFIG_DISCONTIGMEM */ - -#endif /* _ASM_IA64_NODEDATA_H */ diff -Nru
a/include/asm-ia64/processor.hb/include/asm-ia64/processor.hinclude/asm-ia64/processor.h +0
-3@@ -95,9 +95,6 @@#include <asm/rse.h> #include <asm/unwind.h> #include <asm/atomic.h> -#ifdef CONFIG_NUMA -#include <asm/nodedata.h> -#endif /* like above but expressed as bitfields for more efficient access: */ struct ia64_psr {diff -Nru
a/include/asm-ia64/sn/sn_cpuid.hb/include/asm-ia64/sn/sn_cpuid.hinclude/asm-ia64/sn/sn_cpuid.h +0
-1@@ -17,7 +17,6 @@#include <linux/mmzone.h> #include <asm/sn/types.h> #include <asm/current.h> -#include <asm/nodedata.h> #include <asm/sn/pda.h> diff -Nru
a/include/asm-ia64/topology.hb/include/asm-ia64/topology.hinclude/asm-ia64/topology.h +8
-0@@ -13,6 +13,7 @@#ifndef _ASM_IA64_TOPOLOGY_H#define _ASM_IA64_TOPOLOGY_H +#include <linux/config.h> #include <asm/acpi.h> #include <asm/numa.h> #include <asm/smp.h> @@ -63,5 +64,12 @@#endif /* CONFIG_NUMA */ #include <asm-generic/topology.h> + +struct memblk ; +struct node ; +struct cpu ; +extern struct memblk *sysfs_memblks; +extern struct node *sysfs_nodes; +extern struct cpu *sysfs_cpus;#endif /* _ASM_IA64_TOPOLOGY_H */
Quoted 2 lines · Jesse Barnes
Now that NUMA kernels are working we can properly initialze the topology information so that
/sys/devices/system/node*& friends aren't empty.
So with a proper topology API we can start to kill off the topology-related hwgfs mess?
Quoted 6 lines · Christoph Hellwig
Quoted 2 lines · Jesse Barnes
Now that NUMA kernels are working we can properly initialze the topology information so that
/sys/devices/system/node*& friends aren't empty.So with a proper topology API we can start to kill off the topology-related hwgfs mess?
I think this will provide some of the info that hwgfs provides, but not all. We still need a way to map PCI busses to nodes (or cpumasks, whatever makes sense) and a way to map nodes & busses to physical, rack mounted bricks.
Jesse
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Christoph" = Christoph Hellwig <[email protected]> writes:
Quoted 3 lines · Jesse Barnes
Quoted 3 lines
Now that NUMA kernels are working we can properly initialze the topology information so that
/sys/devices/system/node*& friends aren't empty.
Christoph> So with a proper topology API we can start to kill off the Christoph> topology-related hwgfs mess?
We're working on it...
Signature · 2 lines
Martin K. Petersen Silicon Graphics, Inc. [email protected] http://www.sgi.com/
Quoted 11 lines · Jesse Barnes
Quoted 6 lines · Christoph Hellwig
Quoted 2 lines · Jesse Barnes
Now that NUMA kernels are working we can properly initialze the topology information so that
/sys/devices/system/node*& friends aren't empty.So with a proper topology API we can start to kill off the topology-related hwgfs mess?
I think this will provide some of the info that hwgfs provides, but not all. We still need a way to map PCI busses to nodes (or cpumasks, whatever makes sense)
We should have this in the topology API already in a generic fashion. Do you need it in userland aswell?
Quoted 1 line
and a way to map nodes & busses to physical, rack mounted bricks.
Well, that's a SN-specific thing. But it could be implemented similar to the current toplogy API. What do you actually need this for?
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Christoph" = Christoph Hellwig <[email protected]> writes:
I think this will provide some of the info that hwgfs provides, but not all. We still need a way to map PCI busses to nodes (or cpumasks, whatever makes sense)
Matthew Dobson has worked on PCI affinity. I'm on the road this week and have not had a chance to test his latest patch on Altix yet.
Christoph> We should have this in the topology API already in a Christoph> generic fashion. Do you need it in userland aswell?
The tentative plan is to use libnuma to export the information to application developers.
Quoted 1 line
Quoted 1 line
and a way to map nodes & busses to physical, rack mounted bricks.
Christoph> Well, that's a SN-specific thing. But it could be Christoph> implemented similar to the current toplogy API. What do Christoph> you actually need this for?
System administrator diagnostics. We'll need to do this with a set of SN2-specific utilities.
Signature · 2 lines
Martin K. Petersen Silicon Graphics, Inc. [email protected] http://www.sgi.com/
Is there any libnuma code available somewhere (library, kernel patch, etc)?
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Martin K. Petersen
Sent: Friday, October 17, 2003 11:51 AM
To: Christoph Hellwig
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] fix topology initialization
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Christoph" = Christoph Hellwig <[email protected]> writes:
I think this will provide some of the info that hwgfs provides, but not all. We still need a way to map PCI busses to nodes (or cpumasks, whatever makes sense)
Matthew Dobson has worked on PCI affinity. I'm on the road this week and have not had a chance to test his latest patch on Altix yet.
Christoph> We should have this in the topology API already in a Christoph> generic fashion. Do you need it in userland aswell?
The tentative plan is to use libnuma to export the information to application developers.
Quoted 1 line
Quoted 1 line
and a way to map nodes & busses to physical, rack mounted bricks.
Christoph> Well, that's a SN-specific thing. But it could be Christoph> implemented similar to the current toplogy API. What do Christoph> you actually need this for?
System administrator diagnostics. We'll need to do this with a set of SN2-specific utilities.
Signature · 2 lines
Martin K. Petersen Silicon Graphics, Inc. [email protected] http://www.sgi.com/
Quoted 6 lines · Christoph Hellwig
Quoted 3 lines
I think this will provide some of the info that hwgfs provides, but not all. We still need a way to map PCI busses to nodes (or cpumasks, whatever makes sense)
We should have this in the topology API already in a generic fashion. Do you need it in userland aswell?
Yeah, it might be useful for a userland irq balancer for example.
Quoted 4 lines
Quoted 1 line
and a way to map nodes & busses to physical, rack mounted bricks.
Well, that's a SN-specific thing. But it could be implemented similar to the current toplogy API. What do you actually need this for?
Well, I'm not sure that it should be in the kernel at all. Maybe it could just be a SAL call or something with a thin driver wrapper for a userspace program to use. It's mainly useful for physically locating things, e.g. 'the PCI slot on this brick on this rack is dead'.
Jesse
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Kenneth" = Chen, Kenneth W <[email protected]> writes:
Kenneth> Is there any libnuma code available somewhere (library, Kenneth> kernel patch, etc)?
The closest pointer I can find off hand is this one:
http://lwn.net/Articles/32848/
Cheers,
Jes
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
"Jes" = Jes Sorensen <[email protected]> writes:
"Kenneth" = Chen, Kenneth W <[email protected]> writes:
Kenneth> Is there any libnuma code available somewhere (library, Kenneth> kernel patch, etc)?
Jes> The closest pointer I can find off hand is this one:
Jes> http://lwn.net/Articles/32848/
Yeah, that's what I was thinking of. There was some talk about extending and embracing libnuma at the kernel summit.
Andi, where's the code hiding?
Signature · 2 lines
Martin K. Petersen Wild Open Source, Inc. [email protected] http://www.wildopensource.com/