2005-04-16 15:20:36 -07:00
# ifndef _ASM_X86_64_TOPOLOGY_H
# define _ASM_X86_64_TOPOLOGY_H
# include <linux/config.h>
2005-06-23 00:08:06 -07:00
# ifdef CONFIG_NUMA
2005-04-16 15:20:36 -07:00
# include <asm/mpspec.h>
# include <asm/bitops.h>
/* Map the K8 CPU local memory controllers to a simple 1:1 CPU:NODE topology */
extern cpumask_t cpu_online_map ;
extern unsigned char cpu_to_node [ ] ;
extern cpumask_t node_to_cpumask [ ] ;
# ifdef CONFIG_ACPI_NUMA
extern int __node_distance ( int , int ) ;
# define node_distance(a,b) __node_distance(a,b)
/* #else fallback version */
# endif
# define cpu_to_node(cpu) (cpu_to_node[cpu])
# define parent_node(node) (node)
2005-12-22 14:21:34 -08:00
# define node_to_first_cpu(node) (first_cpu(node_to_cpumask[node]))
2005-04-16 15:20:36 -07:00
# define node_to_cpumask(node) (node_to_cpumask[node])
2005-09-12 18:49:24 +02:00
# define pcibus_to_node(bus) ((long)(bus->sysdata))
2005-06-23 00:08:18 -07:00
# define pcibus_to_cpumask(bus) node_to_cpumask(pcibus_to_node(bus));
2005-04-16 15:20:36 -07:00
2005-11-05 17:25:53 +01:00
# define numa_node_id() read_pda(nodenumber)
2005-04-16 15:20:36 -07:00
/* sched_domains SD_NODE_INIT for x86_64 machines */
# define SD_NODE_INIT (struct sched_domain) { \
. span = CPU_MASK_NONE , \
. parent = NULL , \
. groups = NULL , \
. min_interval = 8 , \
. max_interval = 32 , \
. busy_factor = 32 , \
. imbalance_pct = 125 , \
2005-06-25 14:57:13 -07:00
. cache_nice_tries = 2 , \
. busy_idx = 3 , \
. idle_idx = 2 , \
2005-06-25 14:57:21 -07:00
. newidle_idx = 0 , \
2005-06-25 14:57:13 -07:00
. wake_idx = 1 , \
2005-06-25 14:57:19 -07:00
. forkexec_idx = 1 , \
2005-04-16 15:20:36 -07:00
. per_cpu_gain = 100 , \
. flags = SD_LOAD_BALANCE \
2005-06-25 14:57:19 -07:00
| SD_BALANCE_FORK \
2005-04-16 15:20:36 -07:00
| SD_BALANCE_EXEC \
| SD_WAKE_BALANCE , \
. last_balance = jiffies , \
. balance_interval = 1 , \
. nr_balance_failed = 0 , \
}
# endif
[PATCH] Export cpu topology in sysfs
The patch implements cpu topology exportation by sysfs.
Items (attributes) are similar to /proc/cpuinfo.
1) /sys/devices/system/cpu/cpuX/topology/physical_package_id:
represent the physical package id of cpu X;
2) /sys/devices/system/cpu/cpuX/topology/core_id:
represent the cpu core id to cpu X;
3) /sys/devices/system/cpu/cpuX/topology/thread_siblings:
represent the thread siblings to cpu X in the same core;
4) /sys/devices/system/cpu/cpuX/topology/core_siblings:
represent the thread siblings to cpu X in the same physical package;
To implement it in an architecture-neutral way, a new source file,
driver/base/topology.c, is to export the 5 attributes.
If one architecture wants to support this feature, it just needs to
implement 4 defines, typically in file include/asm-XXX/topology.h.
The 4 defines are:
#define topology_physical_package_id(cpu)
#define topology_core_id(cpu)
#define topology_thread_siblings(cpu)
#define topology_core_siblings(cpu)
The type of **_id is int.
The type of siblings is cpumask_t.
To be consistent on all architectures, the 4 attributes should have
deafult values if their values are unavailable. Below is the rule.
1) physical_package_id: If cpu has no physical package id, -1 is the
default value.
2) core_id: If cpu doesn't support multi-core, its core id is 0.
3) thread_siblings: Just include itself, if the cpu doesn't support
HT/multi-thread.
4) core_siblings: Just include itself, if the cpu doesn't support
multi-core and HT/Multi-thread.
So be careful when declaring the 4 defines in include/asm-XXX/topology.h.
If an attribute isn't defined on an architecture, it won't be exported.
Thank Nathan, Greg, Andi, Paul and Venki.
The patch provides defines for i386/x86_64/ia64.
Signed-off-by: Zhang, Yanmin <yanmin.zhang@intel.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-02-03 03:04:36 -08:00
# ifdef CONFIG_SMP
# define topology_physical_package_id(cpu) \
( phys_proc_id [ cpu ] = = BAD_APICID ? - 1 : phys_proc_id [ cpu ] )
# define topology_core_id(cpu) \
( cpu_core_id [ cpu ] = = BAD_APICID ? 0 : cpu_core_id [ cpu ] )
# define topology_core_siblings(cpu) (cpu_core_map[cpu])
# define topology_thread_siblings(cpu) (cpu_sibling_map[cpu])
# endif
2005-04-16 15:20:36 -07:00
# include <asm-generic/topology.h>
2006-03-27 01:15:22 -08:00
extern cpumask_t cpu_coregroup_map ( int cpu ) ;
2005-04-16 15:20:36 -07:00
# endif