perf/x86/intel/uncore: remove hard code for Node ID mapping location
Subsystems (2)
PATCH v2 1/3 perf/x86/intel/uncore: remove hard code for Node ID mapping location
From: Kan Liang <[email protected]>
The method to build PCI bus to socket mapping is similar among platforms. However, the PCI location which store Node ID mapping could vary for different platforms. For example, the Node ID mapping address on Skylake server is different from the previous platform. Also, to build the mapping for the PCI bus without UBOX, it has to start from bus 0 on Skylake server.
This patch removes the hard code in current implementation, and adds three parameters for snbep_pci2phy_map_init. So the Node ID mapping address and bus searching direction could be configured according to different platforms.
---
Changes since V1:
- Refine the changelog according to Nilay's suggestion
arch/x86/events/intel/uncore_snbep.c | 37 ++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-)
arch/x86/events/intel/uncore_snbep.c +25 -12
@@ -1,6 +1,10 @@/* SandyBridge-EP/IvyTown uncore support */ #include "uncore.h" +/* SNB-EP pci bus to socket mapping */ +#define SNBEP_CPUNODEID 0x40 +#define SNBEP_GIDNIDMAP 0x54 +/* SNB-EP Box level control */ #define SNBEP_PMON_BOX_CTL_RST_CTRL (1 << 0)#define SNBEP_PMON_BOX_CTL_RST_CTRS (1 << 1)
@@ -1153,7 +1157,7 @@ static struct pci_driver snbep_uncore_pci_driver = {/* * build pci bus to socket mapping */ -static int snbep_pci2phy_map_init (int devid) +static int snbep_pci2phy_map_init (int devid,int nodeid_loc,int idmap_loc,bool reverse) {struct pci_dev *ubox_dev =NULL ;int i, bus, nodeid, segment;
@@ -1168,12 +1172,12 @@ static int snbep_pci2phy_map_init(int devid)break ; bus = ubox_dev->bus->number;/* get the Node ID of the local register */ - err =pci_read_config_dword (ubox_dev,0x40 , &config); + err =pci_read_config_dword (ubox_dev, nodeid_loc, &config);if (err)break ; nodeid = config;/* get the Node ID mapping */ - err =pci_read_config_dword (ubox_dev,0x54 , &config); + err =pci_read_config_dword (ubox_dev, idmap_loc, &config);if (err)break ;
@@ -1207,11 +1211,20 @@ static int snbep_pci2phy_map_init(int devid)raw_spin_lock (&pci2phy_map_lock);list_for_each_entry (map, &pci2phy_map_head, list) { i =-1 ; -for (bus =255 ; bus >=0 ; bus--) { -if (map->pbus_to_physid[bus] >=0 ) - i = map->pbus_to_physid[bus]; -else - map->pbus_to_physid[bus] = i; +if (reverse) { +for (bus =255 ; bus >=0 ; bus--) { +if (map->pbus_to_physid[bus] >=0 ) + i = map->pbus_to_physid[bus]; +else + map->pbus_to_physid[bus] = i; + } + }else { +for (bus =0 ; bus <=255 ; bus++) { +if (map->pbus_to_physid[bus] >=0 ) + i = map->pbus_to_physid[bus]; +else + map->pbus_to_physid[bus] = i; + } } }raw_spin_unlock (&pci2phy_map_lock);
@@ -1224,7 +1237,7 @@ static int snbep_pci2phy_map_init(int devid)int snbep_uncore_pci_init (void ) { -int ret =snbep_pci2phy_map_init (0x3ce0 ); +int ret =snbep_pci2phy_map_init (0x3ce0 ,SNBEP_CPUNODEID ,SNBEP_GIDNIDMAP , true);if (ret)return ret; uncore_pci_uncores = snbep_pci_uncores;
@@ -1788,7 +1801,7 @@ static struct pci_driver ivbep_uncore_pci_driver = {int ivbep_uncore_pci_init (void ) { -int ret =snbep_pci2phy_map_init (0x0e1e ); +int ret =snbep_pci2phy_map_init (0x0e1e ,SNBEP_CPUNODEID ,SNBEP_GIDNIDMAP , true);if (ret)return ret; uncore_pci_uncores = ivbep_pci_uncores;
@@ -2897,7 +2910,7 @@ static struct pci_driver hswep_uncore_pci_driver = {int hswep_uncore_pci_init (void ) { -int ret =snbep_pci2phy_map_init (0x2f1e ); +int ret =snbep_pci2phy_map_init (0x2f1e ,SNBEP_CPUNODEID ,SNBEP_GIDNIDMAP , true);if (ret)return ret; uncore_pci_uncores = hswep_pci_uncores;
@@ -3186,7 +3199,7 @@ static struct pci_driver bdx_uncore_pci_driver = {int bdx_uncore_pci_init (void ) { -int ret =snbep_pci2phy_map_init (0x6f1e ); +int ret =snbep_pci2phy_map_init (0x6f1e ,SNBEP_CPUNODEID ,SNBEP_GIDNIDMAP , true);if (ret)return ret;
Signature · 1 line
2.5.5
PATCH v2 2/3 perf/x86/intel/uncore: handle non-standard counter offset
From: Stephane Eranian <[email protected]>
The offset of the counters for UPI and M2M boxes on Skylake server is non-standard (8 bytes apart).
This patch introduces a custom flag UNCORE_BOX_FLAG_CTL_OFFS8 to specially handle it.
---
No Change since V1
arch/x86/events/intel/uncore.h | 4 ++++ 1 file changed, 4 insertions(+)
arch/x86/events/intel/uncore.h +4 -0
@@ -120,6 +120,7 @@ struct intel_uncore_box { };#define UNCORE_BOX_FLAG_INITIATED 0 +#define UNCORE_BOX_FLAG_CTL_OFFS8 1/* event config registers are 8-byte apart */ struct uncore_event_desc {struct kobj_attribute attr;
@@ -172,6 +173,9 @@ static inline unsigned uncore_pci_fixed_ctr(struct intel_uncore_box *box)static inline unsigned uncore_pci_event_ctl (struct intel_uncore_box *box,int idx) { +if (test_bit (UNCORE_BOX_FLAG_CTL_OFFS8 , &box->flags)) +return idx *8 + box->pmu->type->event_ctl; +return idx *4 + box->pmu->type->event_ctl; }
Signature · 1 line
2.5.5
tip-bot for Stephane Eranian
merge bot[tip:perf/core] perf/x86/intel/uncore: Handle non-standard counter offset
perf/x86/intel/uncore: Handle non-standard counter offset
Commit-ID: 24cf84672e0a1e0d13f3894b60cd820a0140342a Gitweb: http://git.kernel.org/tip/24cf84672e0a1e0d13f3894b60cd820a0140342a Author: Stephane Eranian <[email protected]> AuthorDate: Tue, 16 Aug 2016 16:09:49 -0400 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 5 Sep 2016 13:15:08 +0200
perf/x86/intel/uncore: Handle non-standard counter offset
The offset of the counters for UPI and M2M boxes on Skylake server is non-standard (8 bytes apart).
This patch introduces a custom flag UNCORE_BOX_FLAG_CTL_OFFS8 to specially handle it.
--- arch/x86/events/intel/uncore.h | 4 ++++ 1 file changed, 4 insertions(+)
arch/x86/events/intel/uncore.h +4 -0
@@ -120,6 +120,7 @@ struct intel_uncore_box { };#define UNCORE_BOX_FLAG_INITIATED 0 +#define UNCORE_BOX_FLAG_CTL_OFFS8 1/* event config registers are 8-byte apart */ struct uncore_event_desc {struct kobj_attribute attr;
@@ -172,6 +173,9 @@ static inline unsigned uncore_pci_fixed_ctr(struct intel_uncore_box *box)static inline unsigned uncore_pci_event_ctl (struct intel_uncore_box *box,int idx) { +if (test_bit (UNCORE_BOX_FLAG_CTL_OFFS8 , &box->flags)) +return idx *8 + box->pmu->type->event_ctl; +return idx *4 + box->pmu->type->event_ctl; }
PATCH v2 3/3 perf/x86/intel/uncore: Add Skylake server uncore support
In reply to Kan LiangFrom: Kan Liang <[email protected]>
This patch implements the uncore monitoring driver for Skylake server. The uncore subsystem in Skylake server is similar to previous server. There are some differences in config register encoding and pci device IDs. Besides, Skylake introduces many new boxes to reflect the MESH architecture changes.
The control registers for IIO and UPI have been extended to 64 bit. This patch also introduces event_mask_ext to handle the high 32 bit mask.
The CHA box number could vary for different machines. This patch gets the CHA box number by counting the CHA register space during initialization at runtime.
---
No Change since V1
arch/x86/events/intel/uncore.c | 9 +- arch/x86/events/intel/uncore.h | 3 + arch/x86/events/intel/uncore_snbep.c | 589 +++++++++++++++++++++++++++++++++++ 3 files changed, 600 insertions(+), 1 deletion(-)
arch/x86/events/intel/uncore.c +8 -1
@@ -683,7 +683,8 @@ static int uncore_pmu_event_init(struct perf_event *event)/* fixed counters have event field hardcoded to zero */ hwc->config =0ULL ; }else { - hwc->config = event->attr.config & pmu->type->event_mask; + hwc->config = event->attr.config & + (pmu->type->event_mask | ((u64 )pmu->type->event_mask_ext <<32 ));if (pmu->type->ops->hw_config) { ret = pmu->type->ops->hw_config (box, event);if (ret)
@@ -1321,6 +1322,11 @@ static const struct intel_uncore_init_fun skl_uncore_init __initconst = { .pci_init = skl_uncore_pci_init, }; +static const struct intel_uncore_init_fun skx_uncore_init__initconst = { + .cpu_init = skx_uncore_cpu_init, + .pci_init = skx_uncore_pci_init, +}; +static const struct x86_cpu_id intel_uncore_match[]__initconst = {X86_UNCORE_MODEL_MATCH (INTEL_FAM6_NEHALEM_EP , nhm_uncore_init),X86_UNCORE_MODEL_MATCH (INTEL_FAM6_NEHALEM , nhm_uncore_init),
@@ -1343,6 +1349,7 @@ static const struct x86_cpu_id intel_uncore_match[] __initconst = {X86_UNCORE_MODEL_MATCH (INTEL_FAM6_XEON_PHI_KNL , knl_uncore_init),X86_UNCORE_MODEL_MATCH (INTEL_FAM6_SKYLAKE_DESKTOP ,skl_uncore_init),X86_UNCORE_MODEL_MATCH (INTEL_FAM6_SKYLAKE_MOBILE , skl_uncore_init), + X86_UNCORE_MODEL_MATCH(INTEL_FAM6_SKYLAKE_X, skx_uncore_init), {}, };
arch/x86/events/intel/uncore.h +3 -0
@@ -44,6 +44,7 @@ struct intel_uncore_type {unsigned perf_ctr;unsigned event_ctl;unsigned event_mask; +unsigned event_mask_ext;unsigned fixed_ctr;unsigned fixed_ctl;unsigned box_ctl;
@@ -381,6 +382,8 @@ int bdx_uncore_pci_init(void);void bdx_uncore_cpu_init (void );int knl_uncore_pci_init (void );void knl_uncore_cpu_init (void ); +int skx_uncore_pci_init (void ); +void skx_uncore_cpu_init (void );/* perf_event_intel_uncore_nhmex.c */ void nhmex_uncore_cpu_init (void );
arch/x86/events/intel/uncore_snbep.c +589 -0
631 lines not on this page · raw message
Signature · 1 line
2.5.5
tip-bot for Kan Liang
merge bot[tip:perf/core] perf/x86/intel/uncore: Add Skylake server uncore support
perf/x86/intel/uncore: Add Skylake server uncore support
Commit-ID: cd34cd97b7b4336aa2c623c37daffab264c7c6ce Gitweb: http://git.kernel.org/tip/cd34cd97b7b4336aa2c623c37daffab264c7c6ce Author: Kan Liang <[email protected]> AuthorDate: Tue, 16 Aug 2016 16:09:50 -0400 Committer: Ingo Molnar <[email protected]> CommitDate: Sat, 10 Sep 2016 11:18:52 +0200
perf/x86/intel/uncore: Add Skylake server uncore support
This patch implements the uncore monitoring driver for Skylake server. The uncore subsystem in Skylake server is similar to previous server. There are some differences in config register encoding and pci device IDs. Besides, Skylake introduces many new boxes to reflect the MESH architecture changes.
The control registers for IIO and UPI have been extended to 64 bit. This patch also introduces event_mask_ext to handle the high 32 bit mask.
The CHA box number could vary for different machines. This patch gets the CHA box number by counting the CHA register space during initialization at runtime.
--- arch/x86/events/intel/uncore.c | 9 +- arch/x86/events/intel/uncore.h | 3 + arch/x86/events/intel/uncore_snbep.c | 589 +++++++++++++++++++++++++++++++++++ 3 files changed, 600 insertions(+), 1 deletion(-)
arch/x86/events/intel/uncore.c +8 -1
@@ -685,7 +685,8 @@ static int uncore_pmu_event_init(struct perf_event *event)/* fixed counters have event field hardcoded to zero */ hwc->config =0ULL ; }else { - hwc->config = event->attr.config & pmu->type->event_mask; + hwc->config = event->attr.config & + (pmu->type->event_mask | ((u64 )pmu->type->event_mask_ext <<32 ));if (pmu->type->ops->hw_config) { ret = pmu->type->ops->hw_config (box, event);if (ret)
@@ -1323,6 +1324,11 @@ static const struct intel_uncore_init_fun skl_uncore_init __initconst = { .pci_init = skl_uncore_pci_init, }; +static const struct intel_uncore_init_fun skx_uncore_init__initconst = { + .cpu_init = skx_uncore_cpu_init, + .pci_init = skx_uncore_pci_init, +}; +static const struct x86_cpu_id intel_uncore_match[]__initconst = {X86_UNCORE_MODEL_MATCH (INTEL_FAM6_NEHALEM_EP , nhm_uncore_init),X86_UNCORE_MODEL_MATCH (INTEL_FAM6_NEHALEM , nhm_uncore_init),
@@ -1345,6 +1351,7 @@ static const struct x86_cpu_id intel_uncore_match[] __initconst = {X86_UNCORE_MODEL_MATCH (INTEL_FAM6_XEON_PHI_KNL , knl_uncore_init),X86_UNCORE_MODEL_MATCH (INTEL_FAM6_SKYLAKE_DESKTOP ,skl_uncore_init),X86_UNCORE_MODEL_MATCH (INTEL_FAM6_SKYLAKE_MOBILE , skl_uncore_init), + X86_UNCORE_MODEL_MATCH(INTEL_FAM6_SKYLAKE_X, skx_uncore_init), {}, };
arch/x86/events/intel/uncore.h +3 -0
@@ -44,6 +44,7 @@ struct intel_uncore_type {unsigned perf_ctr;unsigned event_ctl;unsigned event_mask; +unsigned event_mask_ext;unsigned fixed_ctr;unsigned fixed_ctl;unsigned box_ctl;
@@ -381,6 +382,8 @@ int bdx_uncore_pci_init(void);void bdx_uncore_cpu_init (void );int knl_uncore_pci_init (void );void knl_uncore_cpu_init (void ); +int skx_uncore_pci_init (void ); +void skx_uncore_cpu_init (void );/* perf_event_intel_uncore_nhmex.c */ void nhmex_uncore_cpu_init (void );
arch/x86/events/intel/uncore_snbep.c +589 -0
631 lines not on this page · raw message
tip-bot for Kan Liang
merge bot[tip:perf/core] perf/x86/intel/uncore: Remove hard-coded implementation for Node ID mapping location
In reply to Kan Liangperf/x86/intel/uncore: Remove hard-coded implementation for Node ID mapping location
Commit-ID: 68ce4a0dea168e99d422aed8f93eca5528fd0e50 Gitweb: http://git.kernel.org/tip/68ce4a0dea168e99d422aed8f93eca5528fd0e50 Author: Kan Liang <[email protected]> AuthorDate: Tue, 16 Aug 2016 16:09:48 -0400 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 5 Sep 2016 13:15:07 +0200
perf/x86/intel/uncore: Remove hard-coded implementation for Node ID mapping location
The method to build PCI bus to socket mapping is similar among platforms. However, the PCI location which stores Node ID mapping could vary between different platforms. For example, the Node ID mapping address on Skylake server is different from the previous platform. Also, to build the mapping for the PCI bus without UBOX, it has to start from bus 0 on Skylake server.
This patch removes the current hardcoded implementation and adds three parameters for snbep_pci2phy_map_init(). This way the Node ID mapping address and bus searching direction can be configured according to different platforms.
--- arch/x86/events/intel/uncore_snbep.c | 37 ++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-)
arch/x86/events/intel/uncore_snbep.c +25 -12
@@ -1,6 +1,10 @@/* SandyBridge-EP/IvyTown uncore support */ #include "uncore.h" +/* SNB-EP pci bus to socket mapping */ +#define SNBEP_CPUNODEID 0x40 +#define SNBEP_GIDNIDMAP 0x54 +/* SNB-EP Box level control */ #define SNBEP_PMON_BOX_CTL_RST_CTRL (1 << 0)#define SNBEP_PMON_BOX_CTL_RST_CTRS (1 << 1)
@@ -1153,7 +1157,7 @@ static struct pci_driver snbep_uncore_pci_driver = {/* * build pci bus to socket mapping */ -static int snbep_pci2phy_map_init (int devid) +static int snbep_pci2phy_map_init (int devid,int nodeid_loc,int idmap_loc,bool reverse) {struct pci_dev *ubox_dev =NULL ;int i, bus, nodeid, segment;
@@ -1168,12 +1172,12 @@ static int snbep_pci2phy_map_init(int devid)break ; bus = ubox_dev->bus->number;/* get the Node ID of the local register */ - err =pci_read_config_dword (ubox_dev,0x40 , &config); + err =pci_read_config_dword (ubox_dev, nodeid_loc, &config);if (err)break ; nodeid = config;/* get the Node ID mapping */ - err =pci_read_config_dword (ubox_dev,0x54 , &config); + err =pci_read_config_dword (ubox_dev, idmap_loc, &config);if (err)break ;
@@ -1207,11 +1211,20 @@ static int snbep_pci2phy_map_init(int devid)raw_spin_lock (&pci2phy_map_lock);list_for_each_entry (map, &pci2phy_map_head, list) { i =-1 ; -for (bus =255 ; bus >=0 ; bus--) { -if (map->pbus_to_physid[bus] >=0 ) - i = map->pbus_to_physid[bus]; -else - map->pbus_to_physid[bus] = i; +if (reverse) { +for (bus =255 ; bus >=0 ; bus--) { +if (map->pbus_to_physid[bus] >=0 ) + i = map->pbus_to_physid[bus]; +else + map->pbus_to_physid[bus] = i; + } + }else { +for (bus =0 ; bus <=255 ; bus++) { +if (map->pbus_to_physid[bus] >=0 ) + i = map->pbus_to_physid[bus]; +else + map->pbus_to_physid[bus] = i; + } } }raw_spin_unlock (&pci2phy_map_lock);
@@ -1224,7 +1237,7 @@ static int snbep_pci2phy_map_init(int devid)int snbep_uncore_pci_init (void ) { -int ret =snbep_pci2phy_map_init (0x3ce0 ); +int ret =snbep_pci2phy_map_init (0x3ce0 ,SNBEP_CPUNODEID ,SNBEP_GIDNIDMAP , true);if (ret)return ret; uncore_pci_uncores = snbep_pci_uncores;
@@ -1788,7 +1801,7 @@ static struct pci_driver ivbep_uncore_pci_driver = {int ivbep_uncore_pci_init (void ) { -int ret =snbep_pci2phy_map_init (0x0e1e ); +int ret =snbep_pci2phy_map_init (0x0e1e ,SNBEP_CPUNODEID ,SNBEP_GIDNIDMAP , true);if (ret)return ret; uncore_pci_uncores = ivbep_pci_uncores;
@@ -2897,7 +2910,7 @@ static struct pci_driver hswep_uncore_pci_driver = {int hswep_uncore_pci_init (void ) { -int ret =snbep_pci2phy_map_init (0x2f1e ); +int ret =snbep_pci2phy_map_init (0x2f1e ,SNBEP_CPUNODEID ,SNBEP_GIDNIDMAP , true);if (ret)return ret; uncore_pci_uncores = hswep_pci_uncores;
@@ -3186,7 +3199,7 @@ static struct pci_driver bdx_uncore_pci_driver = {int bdx_uncore_pci_init (void ) { -int ret =snbep_pci2phy_map_init (0x6f1e ); +int ret =snbep_pci2phy_map_init (0x6f1e ,SNBEP_CPUNODEID ,SNBEP_GIDNIDMAP , true);if (ret)return ret;