x86, amd: family 0x15 L3 cache features
cover x86, amd: family 0x15 L3 cache features
This patch set enables L3 cache index disable and adds support for L3 cache partitioning on AMD family 0x15 CPUs.
This stuff applies against tip/master 3ff6dcac735704824c1dff64dc6863c390d364cc.
Andreas Herrmann (1):
x86, amd: Normalize compute unit IDs on multi-node processors
Hans Rosenfeld (3):
x86, amd: Enable L3 cache index disable on family 0x15 x86, amd: Extend AMD northbridge caching code to support "Link
Control" devices
x86, amd: Support L3 Cache Partitioning on AMD family 0x15 CPUs
arch/x86/include/asm/amd_nb.h | 4 ++ arch/x86/kernel/amd_nb.c | 69 ++++++++++++++++++++++++++++++- arch/x86/kernel/cpu/amd.c | 8 +++- arch/x86/kernel/cpu/intel_cacheinfo.c | 73 +++++++++++++++++++++++++++----- arch/x86/kernel/smpboot.c | 1 + include/linux/pci_ids.h | 1 + 6 files changed, 140 insertions(+), 16 deletions(-)
PATCH 1/4 x86, amd: Normalize compute unit IDs on multi-node processors
From: Andreas Herrmann <[email protected]>
On multi-node CPUs we don't need the socket wide compute unit ID but the node-wide compute unit ID. Thus we need to normalize the value. This is similar to what we do with cpu_core_id.
A compute unit is then identified by physical_package_id, node_id, and compute_unit_id.
--- arch/x86/kernel/cpu/amd.c | 8 ++++++-- arch/x86/kernel/smpboot.c | 1 + 2 files changed, 7 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/amd.c +6 -2
@@ -261,7 +261,7 @@ static int __cpuinit nearby_node(int apicid)#ifdef CONFIG_X86_HT static void __cpuinit amd_get_topology (struct cpuinfo_x86 *c) { -u32 nodes; +u32 nodes, cores_per_cu;u8 node_id;int cpu =smp_processor_id ();
@@ -276,6 +276,7 @@ static void __cpuinit amd_get_topology(struct cpuinfo_x86 *c)/* get compute unit information */ smp_num_siblings = ((ebx >>8 ) &3 ) +1 ; c->compute_unit_id = ebx &0xff ; + cores_per_cu = ((ebx >>8 ) &3 ) +1 ; }else if (cpu_has (c,X86_FEATURE_NODEID_MSR )) {u64 value;
@@ -288,15 +289,18 @@ static void __cpuinit amd_get_topology(struct cpuinfo_x86 *c)/* fixup multi-node processor information */ if (nodes >1 ) {u32 cores_per_node; +u32 cus_per_node;set_cpu_cap (c,X86_FEATURE_AMD_DCM ); cores_per_node = c->x86_max_cores / nodes; + cus_per_node = cores_per_node / cores_per_cu;/* store NodeID, use llc_shared_map to store sibling info */ per_cpu (cpu_llc_id, cpu) = node_id;/* core id to be in range from 0 to (cores_per_node - 1) */ - c->cpu_core_id = c->cpu_core_id % cores_per_node; + c->cpu_core_id %= cores_per_node; + c->compute_unit_id %= cus_per_node; } }#endif
arch/x86/kernel/smpboot.c +1 -0
@@ -414,6 +414,7 @@ void __cpuinit set_cpu_sibling_map(int cpu)if (cpu_has (c,X86_FEATURE_TOPOEXT )) {if (c->phys_proc_id == o->phys_proc_id && +per_cpu (cpu_llc_id, cpu) ==per_cpu (cpu_llc_id, i) && c->compute_unit_id == o->compute_unit_id)link_thread_siblings (cpu, i); } else if (c->phys_proc_id == o->phys_proc_id &&
Signature · 1 line
1.5.6.5
[tip:x86/amd-nb] x86, amd: Normalize compute unit IDs on multi-node processors
Commit-ID: d518573de63fb119e5e9a3137386544671387681 Gitweb: http://git.kernel.org/tip/d518573de63fb119e5e9a3137386544671387681 Author: Andreas Herrmann <[email protected]> AuthorDate: Mon, 24 Jan 2011 16:05:40 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 26 Jan 2011 08:28:22 +0100
x86, amd: Normalize compute unit IDs on multi-node processors
On multi-node CPUs we don't need the socket wide compute unit ID but the node-wide compute unit ID. Thus we need to normalize the value. This is similar to what we do with cpu_core_id.
A compute unit is then identified by physical_package_id, node_id, and compute_unit_id.
LKML-Reference: <[email protected]>
--- arch/x86/kernel/cpu/amd.c | 8 ++++++-- arch/x86/kernel/smpboot.c | 1 + 2 files changed, 7 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/amd.c +6 -2
@@ -261,7 +261,7 @@ static int __cpuinit nearby_node(int apicid)#ifdef CONFIG_X86_HT static void __cpuinit amd_get_topology (struct cpuinfo_x86 *c) { -u32 nodes; +u32 nodes, cores_per_cu;u8 node_id;int cpu =smp_processor_id ();
@@ -276,6 +276,7 @@ static void __cpuinit amd_get_topology(struct cpuinfo_x86 *c)/* get compute unit information */ smp_num_siblings = ((ebx >>8 ) &3 ) +1 ; c->compute_unit_id = ebx &0xff ; + cores_per_cu = ((ebx >>8 ) &3 ) +1 ; }else if (cpu_has (c,X86_FEATURE_NODEID_MSR )) {u64 value;
@@ -288,15 +289,18 @@ static void __cpuinit amd_get_topology(struct cpuinfo_x86 *c)/* fixup multi-node processor information */ if (nodes >1 ) {u32 cores_per_node; +u32 cus_per_node;set_cpu_cap (c,X86_FEATURE_AMD_DCM ); cores_per_node = c->x86_max_cores / nodes; + cus_per_node = cores_per_node / cores_per_cu;/* store NodeID, use llc_shared_map to store sibling info */ per_cpu (cpu_llc_id, cpu) = node_id;/* core id to be in range from 0 to (cores_per_node - 1) */ - c->cpu_core_id = c->cpu_core_id % cores_per_node; + c->cpu_core_id %= cores_per_node; + c->compute_unit_id %= cus_per_node; } }#endif
arch/x86/kernel/smpboot.c +1 -0
@@ -414,6 +414,7 @@ void __cpuinit set_cpu_sibling_map(int cpu)if (cpu_has (c,X86_FEATURE_TOPOEXT )) {if (c->phys_proc_id == o->phys_proc_id && +per_cpu (cpu_llc_id, cpu) ==per_cpu (cpu_llc_id, i) && c->compute_unit_id == o->compute_unit_id)link_thread_siblings (cpu, i); } else if (c->phys_proc_id == o->phys_proc_id &&
Re: [tip:x86/amd-nb] x86, amd: Normalize compute unit IDs on multi-node processors
Quoted 4 lines · tip-bot for Andreas Herrmann
Commit-ID: d518573de63fb119e5e9a3137386544671387681 Gitweb: http://git.kernel.org/tip/d518573de63fb119e5e9a3137386544671387681 Author: Andreas Herrmann <[email protected]> AuthorDate: Mon, 24 Jan 2011 16:05:40 +0100
Andreas,
the build is now producing this warning:
arch/x86/kernel/cpu/amd.c: In function 'amd_detect_cmp':
arch/x86/kernel/cpu/amd.c:268: warning: 'cores_per_cu' may be used uninitialized in this function arch/x86/kernel/cpu/amd.c:268: note: 'cores_per_cu' was declared here
Thanks,
Ingo
PATCH 1/1 x86, amd: Fix uninitialized variable warning
Quoted 8 lines · Ingo Molnar
Quoted 4 lines · tip-bot for Andreas Herrmann
Commit-ID: d518573de63fb119e5e9a3137386544671387681 Gitweb: http://git.kernel.org/tip/d518573de63fb119e5e9a3137386544671387681 Author: Andreas Herrmann <[email protected]> AuthorDate: Mon, 24 Jan 2011 16:05:40 +0100
Quoted 7 lines
Andreas,
the build is now producing this warning:
arch/x86/kernel/cpu/amd.c: In function 'amd_detect_cmp':
arch/x86/kernel/cpu/amd.c:268: warning: 'cores_per_cu' may be used uninitialized in this functionarch/x86/kernel/cpu/amd.c:268: note: 'cores_per_cu' was declared here
Here's a quick fix against tip/amd-nb:
--
From: Borislav Petkov <[email protected]>
Date: Mon, 14 Feb 2011 16:25:47 +0100
Subject: [PATCH] x86, amd: Fix uninitialized variable warning
d518573de63fb119e5e9a3137386544671387681 introduced compute unit normalization but causes a valid compiler warning:
arch/x86/kernel/cpu/amd.c: In function 'amd_detect_cmp':arch/x86/kernel/cpu/amd.c:268: warning: 'cores_per_cu' may be used uninitialized in this function arch/x86/kernel/cpu/amd.c:268: note: 'cores_per_cu' was declared here
Initialize it with a proper value. Also, fixup comment while at it.
--- arch/x86/kernel/cpu/amd.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/cpu/amd.c +3 -3
@@ -261,7 +261,7 @@ static int __cpuinit nearby_node(int apicid)#ifdef CONFIG_X86_HT static void __cpuinit amd_get_topology (struct cpuinfo_x86 *c) { -u32 nodes, cores_per_cu; +u32 nodes, cores_per_cu =1 ;u8 node_id;int cpu =smp_processor_id ();
@@ -276,7 +276,7 @@ static void __cpuinit amd_get_topology(struct cpuinfo_x86 *c)/* get compute unit information */ smp_num_siblings = ((ebx >>8 ) &3 ) +1 ; c->compute_unit_id = ebx &0xff ; - cores_per_cu = ((ebx >>8 ) &3 ) +1 ; + cores_per_cu += ((ebx >>8 ) &3 ); }else if (cpu_has (c,X86_FEATURE_NODEID_MSR )) {u64 value;
@@ -298,7 +298,7 @@ static void __cpuinit amd_get_topology(struct cpuinfo_x86 *c)/* store NodeID, use llc_shared_map to store sibling info */ per_cpu (cpu_llc_id, cpu) = node_id; -/* core id to be in range from 0 to (cores_per_node - 1) */ +/* core id has to be in the [0 .. cores_per_node - 1] range */ c->cpu_core_id %= cores_per_node; c->compute_unit_id %= cus_per_node; }
Signature · 12 lines
1.7.4.rc2 -- Regards/Gruss, Boris. Advanced Micro Devices GmbH Einsteinring 24, 85609 Dornach General Managers: Alberto Bozzo, Andrew Bowd Registration: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632
[tip:x86/amd-nb] x86, amd: Initialize variable properly
Commit-ID: 9e81509efc4fefcdd75cc6a4121672fa71ae8745 Gitweb: http://git.kernel.org/tip/9e81509efc4fefcdd75cc6a4121672fa71ae8745 Author: Borislav Petkov <[email protected]> AuthorDate: Mon, 14 Feb 2011 18:14:51 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 15 Feb 2011 03:03:19 +0100
x86, amd: Initialize variable properly
Commit d518573de63f ("x86, amd: Normalize compute unit IDs on multi-node processors") introduced compute unit normalization but causes a compiler warning:
arch/x86/kernel/cpu/amd.c: In function 'amd_detect_cmp':
arch/x86/kernel/cpu/amd.c:268: warning: 'cores_per_cu' may be used uninitialized in this function arch/x86/kernel/cpu/amd.c:268: note: 'cores_per_cu' was declared here
The compiler is right - initialize it with a proper value.
Also, fix up a comment while at it.
LKML-Reference: <[email protected]>
--- arch/x86/kernel/cpu/amd.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/kernel/cpu/amd.c +3 -3
@@ -261,7 +261,7 @@ static int __cpuinit nearby_node(int apicid)#ifdef CONFIG_X86_HT static void __cpuinit amd_get_topology (struct cpuinfo_x86 *c) { -u32 nodes, cores_per_cu; +u32 nodes, cores_per_cu =1 ;u8 node_id;int cpu =smp_processor_id ();
@@ -276,7 +276,7 @@ static void __cpuinit amd_get_topology(struct cpuinfo_x86 *c)/* get compute unit information */ smp_num_siblings = ((ebx >>8 ) &3 ) +1 ; c->compute_unit_id = ebx &0xff ; - cores_per_cu = ((ebx >>8 ) &3 ) +1 ; + cores_per_cu += ((ebx >>8 ) &3 ); }else if (cpu_has (c,X86_FEATURE_NODEID_MSR )) {u64 value;
@@ -298,7 +298,7 @@ static void __cpuinit amd_get_topology(struct cpuinfo_x86 *c)/* store NodeID, use llc_shared_map to store sibling info */ per_cpu (cpu_llc_id, cpu) = node_id; -/* core id to be in range from 0 to (cores_per_node - 1) */ +/* core id has to be in the [0 .. cores_per_node - 1] range */ c->cpu_core_id %= cores_per_node; c->compute_unit_id %= cus_per_node; }
Re: [PATCH 1/4] x86, amd: Normalize compute unit IDs on multi-node processors
In reply to Hans RosenfeldQuoted 40 lines · On Mon, 24 Jan 2011 16:05:40 +0100 Hans Rosenfeld <[email protected]>…
From: Andreas Herrmann <[email protected]>
On multi-node CPUs we don't need the socket wide compute unit ID but the node-wide compute unit ID. Thus we need to normalize the value. This is similar to what we do with
cpu_core_id.A compute unit is then identified by
physical_package_id,node_id, andcompute_unit_id....
arch/x86/kernel/cpu/amd.c +4
-1@@ -261,7 +261,7 @@ static int __cpuinit nearby_node(int apicid)#ifdef CONFIG_X86_HT static void __cpuinit amd_get_topology (struct cpuinfo_x86 *c) { -u32 nodes; +u32 nodes, cores_per_cu;u8 node_id;int cpu =smp_processor_id ();@@ -276,6 +276,7 @@ static void __cpuinit amd_get_topology(struct cpuinfo_x86 *c)/* get compute unit information */ smp_num_siblings = ((ebx >>8 ) &3 ) +1 ; c->compute_unit_id = ebx &0xff ; + cores_per_cu = ((ebx >>8 ) &3 ) +1 ; }else if (cpu_has (c,X86_FEATURE_NODEID_MSR )) {u64 value;@@ -288,15 +289,18 @@ static void __cpuinit amd_get_topology(struct cpuinfo_x86 *c)/* fixup multi-node processor information */ if (nodes >1 ) {u32 cores_per_node; +u32 cus_per_node;set_cpu_cap (c,X86_FEATURE_AMD_DCM ); cores_per_node = c->x86_max_cores / nodes; + cus_per_node = cores_per_node / cores_per_cu;
arch/x86/kernel/cpu/amd.c static void __cpuinit amd_get_topology(struct cpuinfo_x86 *c) · line 306
Quoted 10 lines
arch/x86/kernel/cpu/amd.c +2
-1/* store NodeID, use llc_shared_map to store sibling info */ per_cpu (cpu_llc_id, cpu) = node_id;/* core id to be in range from 0 to (cores_per_node - 1) */ - c->cpu_core_id = c->cpu_core_id % cores_per_node; + c->cpu_core_id %= cores_per_node; + c->compute_unit_id %= cus_per_node; } }#endif
arch/x86/kernel/cpu/amd.c: In function 'init_amd':arch/x86/kernel/cpu/amd.c:268: warning: 'cores_per_cu' may be used uninitialized in this function
The code looks buggy to me.
PATCH 2/4 x86, amd: Enable L3 cache index disable on family 0x15
In reply to Hans RosenfeldAMD family 0x15 CPUs support L3 cache index disable, so enable it on them.
--- arch/x86/kernel/amd_nb.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
arch/x86/kernel/amd_nb.c +3 -0
@@ -85,6 +85,9 @@ int amd_cache_northbridges(void) boot_cpu_data.x86_mask >= 0x1)) amd_northbridges.flags |=AMD_NB_L3_INDEX_DISABLE ; +if (boot_cpu_data.x86 ==0x15 ) + amd_northbridges.flags |=AMD_NB_L3_INDEX_DISABLE ; +return 0 ; }EXPORT_SYMBOL_GPL (amd_cache_northbridges);
Signature · 1 line
1.5.6.5
[tip:x86/amd-nb] x86, amd: Enable L3 cache index disable on family 0x15
Commit-ID: b453de02b786c63b8928ec822401468131db0a9b Gitweb: http://git.kernel.org/tip/b453de02b786c63b8928ec822401468131db0a9b Author: Hans Rosenfeld <[email protected]> AuthorDate: Mon, 24 Jan 2011 16:05:41 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 26 Jan 2011 08:28:23 +0100
x86, amd: Enable L3 cache index disable on family 0x15
AMD family 0x15 CPUs support L3 cache index disable, so enable it on them.
LKML-Reference: <[email protected]>
--- arch/x86/kernel/amd_nb.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
arch/x86/kernel/amd_nb.c +3 -0
@@ -85,6 +85,9 @@ int amd_cache_northbridges(void) boot_cpu_data.x86_mask >= 0x1)) amd_northbridges.flags |=AMD_NB_L3_INDEX_DISABLE ; +if (boot_cpu_data.x86 ==0x15 ) + amd_northbridges.flags |=AMD_NB_L3_INDEX_DISABLE ; +return 0 ; }EXPORT_SYMBOL_GPL (amd_cache_northbridges);
PATCH 3/4 x86, amd: Extend AMD northbridge caching code to support "Link Control" devices
In reply to Hans Rosenfeld"Link Control" devices (NB function 4) will be used by L3 cache partitioning on family 0x15.
--- arch/x86/include/asm/amd_nb.h | 1 + arch/x86/kernel/amd_nb.c | 11 +++++++++-- include/linux/pci_ids.h | 1 + 3 files changed, 11 insertions(+), 2 deletions(-)
arch/x86/include/asm/amd_nb.h +1 -0
@@ -26,6 +26,7 @@ extern void amd_get_nodes(struct bootnode *nodes);struct amd_northbridge {struct pci_dev *misc; +struct pci_dev *link; };struct amd_northbridge_info {
arch/x86/kernel/amd_nb.c +9 -2
@@ -20,6 +20,11 @@ struct pci_device_id amd_nb_misc_ids[] = { };EXPORT_SYMBOL (amd_nb_misc_ids); +static struct pci_device_id amd_nb_link_ids[] = { + {PCI_DEVICE (PCI_VENDOR_ID_AMD ,PCI_DEVICE_ID_AMD_15H_NB_LINK ) }, + {} +}; +const struct amd_nb_bus_dev_range amd_nb_bus_dev_ranges[]__initconst = { {0x00 ,0x18 ,0x20 }, {0xff ,0x00 ,0x20 },
@@ -45,7 +50,7 @@ int amd_cache_northbridges(void) {int i =0 ;struct amd_northbridge *nb; -struct pci_dev *misc; +struct pci_dev *misc, *link;if (amd_nb_num ())return 0 ;
@@ -64,10 +69,12 @@ int amd_cache_northbridges(void) amd_northbridges.nb = nb; amd_northbridges.num = i; - misc =NULL ; + link = misc =NULL ;for (i =0 ; i !=amd_nb_num (); i++) {node_to_amd_nb (i)->misc = misc =next_northbridge (misc, amd_nb_misc_ids); +node_to_amd_nb (i)->link = link = +next_northbridge (link, amd_nb_link_ids); }/* some CPU families (e.g. family 0x11) do not support GART */
include/linux/pci_ids.h +1 -0
@@ -518,6 +518,7 @@#define PCI_DEVICE_ID_AMD_11H_NB_MISC 0x1303#define PCI_DEVICE_ID_AMD_11H_NB_LINK 0x1304#define PCI_DEVICE_ID_AMD_15H_NB_MISC 0x1603 +#define PCI_DEVICE_ID_AMD_15H_NB_LINK 0x1604#define PCI_DEVICE_ID_AMD_CNB17H_F3 0x1703#define PCI_DEVICE_ID_AMD_LANCE 0x2000#define PCI_DEVICE_ID_AMD_LANCE_HOME 0x2001
Signature · 1 line
1.5.6.5
[tip:x86/amd-nb] x86, amd: Extend AMD northbridge caching code to support "Link Control" devices
Commit-ID: 41b2610c3443e6c4760e61fc10eef73f96f9f6a5 Gitweb: http://git.kernel.org/tip/41b2610c3443e6c4760e61fc10eef73f96f9f6a5 Author: Hans Rosenfeld <[email protected]> AuthorDate: Mon, 24 Jan 2011 16:05:42 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Wed, 26 Jan 2011 08:28:23 +0100
x86, amd: Extend AMD northbridge caching code to support "Link Control" devices
"Link Control" devices (NB function 4) will be used by L3 cache partitioning on family 0x15.
LKML-Reference: <[email protected]>
--- arch/x86/include/asm/amd_nb.h | 1 + arch/x86/kernel/amd_nb.c | 11 +++++++++-- include/linux/pci_ids.h | 1 + 3 files changed, 11 insertions(+), 2 deletions(-)
arch/x86/include/asm/amd_nb.h +1 -0
@@ -26,6 +26,7 @@ extern void amd_get_nodes(struct bootnode *nodes);struct amd_northbridge {struct pci_dev *misc; +struct pci_dev *link; };struct amd_northbridge_info {
arch/x86/kernel/amd_nb.c +9 -2
@@ -20,6 +20,11 @@ struct pci_device_id amd_nb_misc_ids[] = { };EXPORT_SYMBOL (amd_nb_misc_ids); +static struct pci_device_id amd_nb_link_ids[] = { + {PCI_DEVICE (PCI_VENDOR_ID_AMD ,PCI_DEVICE_ID_AMD_15H_NB_LINK ) }, + {} +}; +const struct amd_nb_bus_dev_range amd_nb_bus_dev_ranges[]__initconst = { {0x00 ,0x18 ,0x20 }, {0xff ,0x00 ,0x20 },
@@ -45,7 +50,7 @@ int amd_cache_northbridges(void) {int i =0 ;struct amd_northbridge *nb; -struct pci_dev *misc; +struct pci_dev *misc, *link;if (amd_nb_num ())return 0 ;
@@ -64,10 +69,12 @@ int amd_cache_northbridges(void) amd_northbridges.nb = nb; amd_northbridges.num = i; - misc =NULL ; + link = misc =NULL ;for (i =0 ; i !=amd_nb_num (); i++) {node_to_amd_nb (i)->misc = misc =next_northbridge (misc, amd_nb_misc_ids); +node_to_amd_nb (i)->link = link = +next_northbridge (link, amd_nb_link_ids); }/* some CPU families (e.g. family 0x11) do not support GART */
include/linux/pci_ids.h +1 -0
@@ -518,6 +518,7 @@#define PCI_DEVICE_ID_AMD_11H_NB_MISC 0x1303#define PCI_DEVICE_ID_AMD_11H_NB_LINK 0x1304#define PCI_DEVICE_ID_AMD_15H_NB_MISC 0x1603 +#define PCI_DEVICE_ID_AMD_15H_NB_LINK 0x1604#define PCI_DEVICE_ID_AMD_CNB17H_F3 0x1703#define PCI_DEVICE_ID_AMD_LANCE 0x2000#define PCI_DEVICE_ID_AMD_LANCE_HOME 0x2001
PATCH 4/4 x86, amd: Support L3 Cache Partitioning on AMD family 0x15 CPUs
In reply to Hans RosenfeldL3 Cache Partitioning allows selecting which of the 4 L3 subcaches can be used for evictions by the L2 cache of each compute unit. By writing a 4-bit hexadecimal mask into the the sysfs file /sys/devices/system/cpu/\
cpuX/cache/index3/subcaches, the user can set the enabled subcaches for a CPU. The settings are directly read from and written to the hardware, so there is no way to have contradicting settings for two CPUs belonging to the same compute unit. Writing will always overwrite any previous setting for a compute unit.
--- arch/x86/include/asm/amd_nb.h | 3 + arch/x86/kernel/amd_nb.c | 55 +++++++++++++++++++++++++ arch/x86/kernel/cpu/intel_cacheinfo.c | 73 +++++++++++++++++++++++++++----- 3 files changed, 119 insertions(+), 12 deletions(-)
arch/x86/include/asm/amd_nb.h +3 -0
@@ -18,6 +18,8 @@ extern int amd_cache_northbridges(void);extern void amd_flush_garts (void );extern int amd_numa_init (unsigned long start_pfn,unsigned long end_pfn);extern int amd_scan_nodes (void ); +extern int amd_get_subcaches (int ); +extern int amd_set_subcaches (int ,int );#ifdef CONFIG_NUMA_EMU extern void amd_fake_nodes (const struct bootnode *nodes,int nr_nodes);
@@ -38,6 +40,7 @@ extern struct amd_northbridge_info amd_northbridges;#define AMD_NB_GART 0x1#define AMD_NB_L3_INDEX_DISABLE 0x2 +#define AMD_NB_L3_PARTITIONING 0x4#ifdef CONFIG_AMD_NB
arch/x86/kernel/amd_nb.c +55 -0
67 lines not on this page · raw message
arch/x86/kernel/cpu/intel_cacheinfo.c +61 -12
147 lines not on this page · raw message
Signature · 1 line
1.5.6.5
Re: [PATCH 4/4] x86, amd: Support L3 Cache Partitioning on AMD family 0x15 CPUs
Quoted 9 lines · Hans Rosenfeld
L3 Cache Partitioning allows selecting which of the 4 L3 subcaches can be used for evictions by the L2 cache of each compute unit. By writing a 4-bit hexadecimal mask into the the sysfs file /sys/devices/system/cpu/\
cpuX/cache/index3/subcaches, the user can set the enabled subcaches for a CPU. The settings are directly read from and written to the hardware, so there is no way to have contradicting settings for two CPUs belonging to the same compute unit. Writing will always overwrite any previous setting for a compute unit.
Quoted 6 lines
Signed-off-by Hans Rosenfeld <[email protected]>--- arch/x86/include/asm/amd_nb.h | 3 + arch/x86/kernel/amd_nb.c | 55 +++++++++++++++++++++++++ arch/x86/kernel/cpu/intel_cacheinfo.c | 73 +++++++++++++++++++++++++++----- 3 files changed, 119 insertions(+), 12 deletions(-)
I have picked up the other 3 patches, but this one causes this build failure:
arch/x86/kernel/amd_nb.c: In function ‘amd_get_subcaches’:
arch/x86/kernel/amd_nb.c:129:36: error: ‘struct cpuinfo_x86’ has no member named ‘compute_unit_id’ arch/x86/kernel/amd_nb.c: In function ‘amd_set_subcaches’:
arch/x86/kernel/amd_nb.c:154:28: error: ‘struct cpuinfo_x86’ has no member named ‘compute_unit_id’ arch/x86/kernel/amd_nb.c:155:36: error: ‘struct cpuinfo_x86’ has no member named ‘compute_unit_id’ arch/x86/kernel/amd_nb.c: In function ‘amd_get_subcaches’:
arch/x86/kernel/amd_nb.c:130:1: warning: control reaches end of non-void function
Thanks,
Ingo
Re: [PATCH 4/4] x86, amd: Support L3 Cache Partitioning on AMD family 0x15 CPUs
Quoted 21 lines · Ingo Molnar
Quoted 9 lines · Hans Rosenfeld
L3 Cache Partitioning allows selecting which of the 4 L3 subcaches can be used for evictions by the L2 cache of each compute unit. By writing a 4-bit hexadecimal mask into the the sysfs file /sys/devices/system/cpu/\
cpuX/cache/index3/subcaches, the user can set the enabled subcaches for a CPU. The settings are directly read from and written to the hardware, so there is no way to have contradicting settings for two CPUs belonging to the same compute unit. Writing will always overwrite any previous setting for a compute unit.Quoted 6 lines
Signed-off-by Hans Rosenfeld <[email protected]>--- arch/x86/include/asm/amd_nb.h | 3 + arch/x86/kernel/amd_nb.c | 55 +++++++++++++++++++++++++ arch/x86/kernel/cpu/intel_cacheinfo.c | 73 +++++++++++++++++++++++++++----- 3 files changed, 119 insertions(+), 12 deletions(-)I have picked up the other 3 patches, but this one causes this build failure:
Quoted 7 lines
arch/x86/kernel/amd_nb.c: In function ?amd_get_subcaches?:
arch/x86/kernel/amd_nb.c:129:36: error: ?structcpuinfo_x86? has no member named ?compute_unit_id?arch/x86/kernel/amd_nb.c: In function ?amd_set_subcaches?:
arch/x86/kernel/amd_nb.c:154:28: error: ?structcpuinfo_x86? has no member named ?compute_unit_id?arch/x86/kernel/amd_nb.c:155:36: error: ?structcpuinfo_x86? has no member named ?compute_unit_id?arch/x86/kernel/amd_nb.c: In function ?amd_get_subcaches?:
arch/x86/kernel/amd_nb.c:130:1: warning: control reaches end of non-void function
Hrmpf. CONFIG_SMP.
Sorry for the noise, fixed patch will follow shortly.
Hans
Signature · 1 line
%SYSTEM-F-ANARCHISM, The operating system has been overthrown
PATCH 4/4 x86, amd: Support L3 Cache Partitioning on AMD family 0x15 CPUs
In reply to Ingo MolnarL3 Cache Partitioning allows selecting which of the 4 L3 subcaches can be used for evictions by the L2 cache of each compute unit. By writing a 4-bit hexadecimal mask into the the sysfs file /sys/devices/system/cpu/\
cpuX/cache/index3/subcaches, the user can set the enabled subcaches for a CPU. The settings are directly read from and written to the hardware, so there is no way to have contradicting settings for two CPUs belonging to the same compute unit. Writing will always overwrite any previous setting for a compute unit.
--- arch/x86/include/asm/amd_nb.h | 3 + arch/x86/kernel/amd_nb.c | 57 ++++++++++++++++++++++++ arch/x86/kernel/cpu/intel_cacheinfo.c | 77 +++++++++++++++++++++++++++----- 3 files changed, 125 insertions(+), 12 deletions(-)
arch/x86/include/asm/amd_nb.h +3 -0
@@ -18,6 +18,8 @@ extern int amd_cache_northbridges(void);extern void amd_flush_garts (void );extern int amd_numa_init (unsigned long start_pfn,unsigned long end_pfn);extern int amd_scan_nodes (void ); +extern int amd_get_subcaches (int ); +extern int amd_set_subcaches (int ,int );#ifdef CONFIG_NUMA_EMU extern void amd_fake_nodes (const struct bootnode *nodes,int nr_nodes);
@@ -38,6 +40,7 @@ extern struct amd_northbridge_info amd_northbridges;#define AMD_NB_GART 0x1#define AMD_NB_L3_INDEX_DISABLE 0x2 +#define AMD_NB_L3_PARTITIONING 0x4#ifdef CONFIG_AMD_NB
arch/x86/kernel/amd_nb.c +57 -0
69 lines not on this page · raw message
arch/x86/kernel/cpu/intel_cacheinfo.c +65 -12
151 lines not on this page · raw message
Signature · 1 line
1.5.6.5
Re: [PATCH 4/4] x86, amd: Support L3 Cache Partitioning on AMD family 0x15 CPUs
Quoted 53 lines · Hans Rosenfeld
L3 Cache Partitioning allows selecting which of the 4 L3 subcaches can be used for evictions by the L2 cache of each compute unit. By writing a 4-bit hexadecimal mask into the the sysfs file /sys/devices/system/cpu/\
cpuX/cache/index3/subcaches, the user can set the enabled subcaches for a CPU. The settings are directly read from and written to the hardware, so there is no way to have contradicting settings for two CPUs belonging to the same compute unit. Writing will always overwrite any previous setting for a compute unit.Signed-off-by Hans Rosenfeld <[email protected]>--- arch/x86/include/asm/amd_nb.h | 3 + arch/x86/kernel/amd_nb.c | 57 ++++++++++++++++++++++++ arch/x86/kernel/cpu/intel_cacheinfo.c | 77 +++++++++++++++++++++++++++----- 3 files changed, 125 insertions(+), 12 deletions(-)arch/x86/include/asm/amd_nb.h +3
-0@@ -18,6 +18,8 @@ extern int amd_cache_northbridges(void);extern void amd_flush_garts (void );extern int amd_numa_init (unsigned long start_pfn,unsigned long end_pfn);extern int amd_scan_nodes (void ); +extern int amd_get_subcaches (int ); +extern int amd_set_subcaches (int ,int );#ifdef CONFIG_NUMA_EMU extern void amd_fake_nodes (const struct bootnode *nodes,int nr_nodes);@@ -38,6 +40,7 @@ extern struct amd_northbridge_info amd_northbridges;#define AMD_NB_GART 0x1#define AMD_NB_L3_INDEX_DISABLE 0x2 +#define AMD_NB_L3_PARTITIONING 0x4#ifdef CONFIG_AMD_NB arch/x86/kernel/amd_nb.c +4
-0@@ -95,6 +95,10 @@ int amd_cache_northbridges(void)if (boot_cpu_data.x86 ==0x15 ) amd_northbridges.flags |=AMD_NB_L3_INDEX_DISABLE ; +/* L3 cache partitioning is supported on family 0x15 */ +if (boot_cpu_data.x86 ==0x15 ) + amd_northbridges.flags |=AMD_NB_L3_PARTITIONING ; +return 0 ; }EXPORT_SYMBOL_GPL (amd_cache_northbridges);
arch/x86/kernel/amd_nb.c int __init early_is_amd_nb(u32 device) · line 120
Quoted 5 lines
arch/x86/kernel/amd_nb.c +2
-0@@ -112,6 +116,59 @@ int __init early_is_amd_nb(u32 device)return 0 ; } +#ifdef CONFIG_SMP +int amd_get_subcaches (int cpu)
Well, sprinkling it with CONFIG_SMP is pretty ugly. Also, there's no fundamental reason why this shouldnt work with UP. Yes, it makes most sense on SMP but such code should be SMP-invariant.
Thanks,
Ingo
Re: [PATCH 4/4] x86, amd: Support L3 Cache Partitioning on AMD family 0x15 CPUs
Quoted 7 lines · Ingo Molnar
arch/x86/kernel/amd_nb.c int __init early_is_amd_nb(u32 device) · line 120
Quoted 2 lines · Hans Rosenfeld
arch/x86/kernel/amd_nb.c +2
-0+#ifdef CONFIG_SMP +int amd_get_subcaches (int cpu)Well, sprinkling it with
CONFIG_SMPis pretty ugly. Also, there's no fundamental reason why this shouldnt work with UP. Yes, it makes most sense on SMP but such code should be SMP-invariant.
True, it is pretty ugly. And while the feature is pretty useless for UP, it would still work for compute_unit_id 0 in that case.
The problem is that cpuinfo_x86.compute_unit_id etc. don't exist unless CONFIG_SMP is enabled. I don't think there is any reason why this should be that way, but changing this just for this particular L3 feature seems too intrusive. Do you really want me to do that?
Hans
Signature · 1 line
%SYSTEM-F-ANARCHISM, The operating system has been overthrown
Re: [PATCH 4/4] x86, amd: Support L3 Cache Partitioning on AMD family 0x15 CPUs
Quoted 9 lines · Hans Rosenfeld
Quoted 7 lines · Ingo Molnar
arch/x86/kernel/amd_nb.c int __init early_is_amd_nb(u32 device) · line 120
Quoted 2 lines · Hans Rosenfeld
arch/x86/kernel/amd_nb.c +2
-0+#ifdef CONFIG_SMP +int amd_get_subcaches (int cpu)Well, sprinkling it with
CONFIG_SMPis pretty ugly. Also, there's no fundamental reason why this shouldnt work with UP. Yes, it makes most sense on SMP but such code should be SMP-invariant.
Quoted 7 lines
True, it is pretty ugly. And while the feature is pretty useless for UP, it would still work for
compute_unit_id0 in that case.The problem is that cpuinfo_x86.compute_unit_id etc. don't exist unless
CONFIG_SMPis enabled. I don't think there is any reason why this should be that way, but changing this just for this particular L3 feature seems too intrusive. Do you really want me to do that?
All the CONFIG_X86_HT #ifdefs in arch/x86/kernel/cpu/amd.c look pretty ugly too - and it's not really a properly modularized solution.
We generally want to unify the SMP and UP kernels as much as possible. 'CONFIG_SMP' is not really a property of the hardware, it's a property of the software.
If some topology information should be excluded then it can already be done by turning off CONFIG_CPU_SUP_AMD under CONFIG_EXPERT.
Thanks,
Ingo
Re: [PATCH 4/4] x86, amd: Support L3 Cache Partitioning on AMD family 0x15 CPUs
Quoted 5 lines · Ingo Molnar
Quoted 4 lines
The problem is that cpuinfo_x86.compute_unit_id etc. don't exist unless
CONFIG_SMPis enabled. I don't think there is any reason why this should be that way, but changing this just for this particular L3 feature seems too intrusive. Do you really want me to do that?
Quoted 8 lines
All the
CONFIG_X86_HT#ifdefs inarch/x86/kernel/cpu/amd.clook pretty ugly too - and it's not really a properly modularized solution.We generally want to unify the SMP and UP kernels as much as possible. '
CONFIG_SMP' is not really a property of the hardware, it's a property of the software.If some topology information should be excluded then it can already be done by turning off
CONFIG_CPU_SUP_AMDunderCONFIG_EXPERT.
I see several solutions to resolve this issue:
1. Remove #ifdef CONFIG_SMP around compute_unit_id in struct cpuinfo_x86 and then use my original patch. This would work without introducing new #ifdef ugliness with the L3 cache partitioning, but it would increase #ifdef ugliness in struct cpuinfo_x86. Also, compute_unit_id would just so happen to be initialized to 0, there would be no other code using it for CONFIG_SMP. L3 cache partitioning would be the first SMP-specific feature to be available in non-SMP kernels.
2. Same as #1, but remove CONFIG_SMP completely from struct cpuinfo_x86. This would mean less #ifdef ugliness there, but then we would have a bunch of unused fields in there in non-SMP kernels, which would also just be initialized to 0. I don't think that would be correct for booted_cores, but as it is unused I don't see an immediate problem with that. Of course, this is also neither correct nor less ugly.
3. Same as #2, but also rework all code using those fields to be usable on non-SMP kernels. This would be essentially a rework of all that CONFIG_SMP stuff, and I think thats too much to ask for just for a little extra L3 feature.
Maybe I'm missing something here, but I don't see how this could be done cleanly in any other way at this time.
Of course, you could just take the modified patch I sent you. That would be ugly, but not more so than the existing code. If this is not acceptable, please tell me which of the other two ugly solutions you would prefer.
Hans
Signature · 1 line
%SYSTEM-F-ANARCHISM, The operating system has been overthrown
PATCH 4/4 x86, amd: Support L3 Cache Partitioning on AMD family 0x15 CPUs
In reply to Ingo MolnarL3 Cache Partitioning allows selecting which of the 4 L3 subcaches can be used for evictions by the L2 cache of each compute unit. By writing a 4-bit hexadecimal mask into the the sysfs file /sys/devices/system/cpu/\
cpuX/cache/index3/subcaches, the user can set the enabled subcaches for a CPU. The settings are directly read from and written to the hardware, so there is no way to have contradicting settings for two CPUs belonging to the same compute unit. Writing will always overwrite any previous setting for a compute unit.
--- arch/x86/include/asm/amd_nb.h | 3 + arch/x86/kernel/amd_nb.c | 63 ++++++++++++++++++++++++++++ arch/x86/kernel/cpu/intel_cacheinfo.c | 73 +++++++++++++++++++++++++++----- 3 files changed, 127 insertions(+), 12 deletions(-)
arch/x86/include/asm/amd_nb.h +3 -0
@@ -18,6 +18,8 @@ extern int amd_cache_northbridges(void);extern void amd_flush_garts (void );extern int amd_numa_init (unsigned long start_pfn,unsigned long end_pfn);extern int amd_scan_nodes (void ); +extern int amd_get_subcaches (int ); +extern int amd_set_subcaches (int ,int );#ifdef CONFIG_NUMA_EMU extern void amd_fake_nodes (const struct bootnode *nodes,int nr_nodes);
@@ -38,6 +40,7 @@ extern struct amd_northbridge_info amd_northbridges;#define AMD_NB_GART 0x1#define AMD_NB_L3_INDEX_DISABLE 0x2 +#define AMD_NB_L3_PARTITIONING 0x4#ifdef CONFIG_AMD_NB
arch/x86/kernel/amd_nb.c +63 -0
75 lines not on this page · raw message
arch/x86/kernel/cpu/intel_cacheinfo.c +61 -12
147 lines not on this page · raw message
Signature · 1 line
1.5.6.5
[tip:x86/amd-nb] x86, amd: Support L3 Cache Partitioning on AMD family 0x15 CPUs
Commit-ID: cabb5bd7ff4d6963ec9e67f958fc30e7815425e6 Gitweb: http://git.kernel.org/tip/cabb5bd7ff4d6963ec9e67f958fc30e7815425e6 Author: Hans Rosenfeld <[email protected]> AuthorDate: Mon, 7 Feb 2011 18:10:39 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 7 Feb 2011 19:16:22 +0100
x86, amd: Support L3 Cache Partitioning on AMD family 0x15 CPUs
L3 Cache Partitioning allows selecting which of the 4 L3 subcaches can be used for evictions by the L2 cache of each compute unit. By writing a 4-bit hexadecimal mask into the the sysfs file /sys/devices/system/cpu/cpuX/cache/index3/subcaches, the user can set the enabled subcaches for a CPU.
The settings are directly read from and written to the hardware, so there is no way to have contradicting settings for two CPUs belonging to the same compute unit. Writing will always overwrite any previous setting for a compute unit.
LKML-Reference: <[email protected]>
--- arch/x86/include/asm/amd_nb.h | 3 + arch/x86/kernel/amd_nb.c | 63 +++++++++++++++++++++++++++ arch/x86/kernel/cpu/intel_cacheinfo.c | 76 ++++++++++++++++++++++++++------ 3 files changed, 127 insertions(+), 15 deletions(-)
arch/x86/include/asm/amd_nb.h +3 -0
@@ -18,6 +18,8 @@ extern int amd_cache_northbridges(void);extern void amd_flush_garts (void );extern int amd_numa_init (unsigned long start_pfn,unsigned long end_pfn);extern int amd_scan_nodes (void ); +extern int amd_get_subcaches (int ); +extern int amd_set_subcaches (int ,int );#ifdef CONFIG_NUMA_EMU extern void amd_fake_nodes (const struct bootnode *nodes,int nr_nodes);
@@ -38,6 +40,7 @@ extern struct amd_northbridge_info amd_northbridges;#define AMD_NB_GART 0x1#define AMD_NB_L3_INDEX_DISABLE 0x2 +#define AMD_NB_L3_PARTITIONING 0x4#ifdef CONFIG_AMD_NB
arch/x86/kernel/amd_nb.c +63 -0
75 lines not on this page · raw message
arch/x86/kernel/cpu/intel_cacheinfo.c +61 -15
156 lines not on this page · raw message