aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>2016-04-17 18:03:00 -0400
committerIngo Molnar <mingo@kernel.org>2016-04-23 08:13:36 -0400
commitdcee75b3b7f025cc6765e6c92ba0a4e59a4d25f4 (patch)
tree037bad7127511a9caf1fcf4682c0186c1ddb7c03
parent9ecda41acb971ebd07c8fb35faf24005c0baea12 (diff)
perf/x86/intel/rapl: Support Skylake RAPL domains
Add Skylake client support for RAPL domains. In addition to RAPL domains in Broadwell clients, it has support for platform domain (aka PSys). The PSys domain controls the entire SoC instead of just a CPU package. Unlike package domain, PSys support requires more than just processor level implementation. The other parts in the system need additional HW level signaling, which OEMs need to support. When not supported, the energy counter register in PSys domain returns 0. Also corrected error in comment for GPU counter, which previously was DRAM counter. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com [ Cnverted to model_match stuff. ] Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Vince Weaver <vincent.weaver@maine.edu> Cc: bp@alien8.de Cc: hpa@zytor.com Cc: jacob.jun.pan@linux.intel.com Cc: rjw@rjwysocki.net Link: http://lkml.kernel.org/r/1460930581-29748-2-git-send-email-srinivas.pandruvada@linux.intel.com Signed-off-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--arch/x86/events/intel/rapl.c54
-rw-r--r--arch/x86/include/asm/msr-index.h2
2 files changed, 54 insertions, 2 deletions
diff --git a/arch/x86/events/intel/rapl.c b/arch/x86/events/intel/rapl.c
index c9b7489ae8ee..26c7d7d8a657 100644
--- a/arch/x86/events/intel/rapl.c
+++ b/arch/x86/events/intel/rapl.c
@@ -27,10 +27,14 @@
27 * event: rapl_energy_dram 27 * event: rapl_energy_dram
28 * perf code: 0x3 28 * perf code: 0x3
29 * 29 *
30 * dram counter: consumption of the builtin-gpu domain (client only) 30 * gpu counter: consumption of the builtin-gpu domain (client only)
31 * event: rapl_energy_gpu 31 * event: rapl_energy_gpu
32 * perf code: 0x4 32 * perf code: 0x4
33 * 33 *
34 * psys counter: consumption of the builtin-psys domain (client only)
35 * event: rapl_energy_psys
36 * perf code: 0x5
37 *
34 * We manage those counters as free running (read-only). They may be 38 * We manage those counters as free running (read-only). They may be
35 * use simultaneously by other tools, such as turbostat. 39 * use simultaneously by other tools, such as turbostat.
36 * 40 *
@@ -66,13 +70,16 @@ MODULE_LICENSE("GPL");
66#define INTEL_RAPL_RAM 0x3 /* pseudo-encoding */ 70#define INTEL_RAPL_RAM 0x3 /* pseudo-encoding */
67#define RAPL_IDX_PP1_NRG_STAT 3 /* gpu */ 71#define RAPL_IDX_PP1_NRG_STAT 3 /* gpu */
68#define INTEL_RAPL_PP1 0x4 /* pseudo-encoding */ 72#define INTEL_RAPL_PP1 0x4 /* pseudo-encoding */
73#define RAPL_IDX_PSYS_NRG_STAT 4 /* psys */
74#define INTEL_RAPL_PSYS 0x5 /* pseudo-encoding */
69 75
70#define NR_RAPL_DOMAINS 0x4 76#define NR_RAPL_DOMAINS 0x5
71static const char *const rapl_domain_names[NR_RAPL_DOMAINS] __initconst = { 77static const char *const rapl_domain_names[NR_RAPL_DOMAINS] __initconst = {
72 "pp0-core", 78 "pp0-core",
73 "package", 79 "package",
74 "dram", 80 "dram",
75 "pp1-gpu", 81 "pp1-gpu",
82 "psys",
76}; 83};
77 84
78/* Clients have PP0, PKG */ 85/* Clients have PP0, PKG */
@@ -91,6 +98,13 @@ static const char *const rapl_domain_names[NR_RAPL_DOMAINS] __initconst = {
91 1<<RAPL_IDX_RAM_NRG_STAT|\ 98 1<<RAPL_IDX_RAM_NRG_STAT|\
92 1<<RAPL_IDX_PP1_NRG_STAT) 99 1<<RAPL_IDX_PP1_NRG_STAT)
93 100
101/* SKL clients have PP0, PKG, RAM, PP1, PSYS */
102#define RAPL_IDX_SKL_CLN (1<<RAPL_IDX_PP0_NRG_STAT|\
103 1<<RAPL_IDX_PKG_NRG_STAT|\
104 1<<RAPL_IDX_RAM_NRG_STAT|\
105 1<<RAPL_IDX_PP1_NRG_STAT|\
106 1<<RAPL_IDX_PSYS_NRG_STAT)
107
94/* Knights Landing has PKG, RAM */ 108/* Knights Landing has PKG, RAM */
95#define RAPL_IDX_KNL (1<<RAPL_IDX_PKG_NRG_STAT|\ 109#define RAPL_IDX_KNL (1<<RAPL_IDX_PKG_NRG_STAT|\
96 1<<RAPL_IDX_RAM_NRG_STAT) 110 1<<RAPL_IDX_RAM_NRG_STAT)
@@ -362,6 +376,10 @@ static int rapl_pmu_event_init(struct perf_event *event)
362 bit = RAPL_IDX_PP1_NRG_STAT; 376 bit = RAPL_IDX_PP1_NRG_STAT;
363 msr = MSR_PP1_ENERGY_STATUS; 377 msr = MSR_PP1_ENERGY_STATUS;
364 break; 378 break;
379 case INTEL_RAPL_PSYS:
380 bit = RAPL_IDX_PSYS_NRG_STAT;
381 msr = MSR_PLATFORM_ENERGY_STATUS;
382 break;
365 default: 383 default:
366 return -EINVAL; 384 return -EINVAL;
367 } 385 }
@@ -416,11 +434,13 @@ RAPL_EVENT_ATTR_STR(energy-cores, rapl_cores, "event=0x01");
416RAPL_EVENT_ATTR_STR(energy-pkg , rapl_pkg, "event=0x02"); 434RAPL_EVENT_ATTR_STR(energy-pkg , rapl_pkg, "event=0x02");
417RAPL_EVENT_ATTR_STR(energy-ram , rapl_ram, "event=0x03"); 435RAPL_EVENT_ATTR_STR(energy-ram , rapl_ram, "event=0x03");
418RAPL_EVENT_ATTR_STR(energy-gpu , rapl_gpu, "event=0x04"); 436RAPL_EVENT_ATTR_STR(energy-gpu , rapl_gpu, "event=0x04");
437RAPL_EVENT_ATTR_STR(energy-psys, rapl_psys, "event=0x05");
419 438
420RAPL_EVENT_ATTR_STR(energy-cores.unit, rapl_cores_unit, "Joules"); 439RAPL_EVENT_ATTR_STR(energy-cores.unit, rapl_cores_unit, "Joules");
421RAPL_EVENT_ATTR_STR(energy-pkg.unit , rapl_pkg_unit, "Joules"); 440RAPL_EVENT_ATTR_STR(energy-pkg.unit , rapl_pkg_unit, "Joules");
422RAPL_EVENT_ATTR_STR(energy-ram.unit , rapl_ram_unit, "Joules"); 441RAPL_EVENT_ATTR_STR(energy-ram.unit , rapl_ram_unit, "Joules");
423RAPL_EVENT_ATTR_STR(energy-gpu.unit , rapl_gpu_unit, "Joules"); 442RAPL_EVENT_ATTR_STR(energy-gpu.unit , rapl_gpu_unit, "Joules");
443RAPL_EVENT_ATTR_STR(energy-psys.unit, rapl_psys_unit, "Joules");
424 444
425/* 445/*
426 * we compute in 0.23 nJ increments regardless of MSR 446 * we compute in 0.23 nJ increments regardless of MSR
@@ -429,6 +449,7 @@ RAPL_EVENT_ATTR_STR(energy-cores.scale, rapl_cores_scale, "2.3283064365386962890
429RAPL_EVENT_ATTR_STR(energy-pkg.scale, rapl_pkg_scale, "2.3283064365386962890625e-10"); 449RAPL_EVENT_ATTR_STR(energy-pkg.scale, rapl_pkg_scale, "2.3283064365386962890625e-10");
430RAPL_EVENT_ATTR_STR(energy-ram.scale, rapl_ram_scale, "2.3283064365386962890625e-10"); 450RAPL_EVENT_ATTR_STR(energy-ram.scale, rapl_ram_scale, "2.3283064365386962890625e-10");
431RAPL_EVENT_ATTR_STR(energy-gpu.scale, rapl_gpu_scale, "2.3283064365386962890625e-10"); 451RAPL_EVENT_ATTR_STR(energy-gpu.scale, rapl_gpu_scale, "2.3283064365386962890625e-10");
452RAPL_EVENT_ATTR_STR(energy-psys.scale, rapl_psys_scale, "2.3283064365386962890625e-10");
432 453
433static struct attribute *rapl_events_srv_attr[] = { 454static struct attribute *rapl_events_srv_attr[] = {
434 EVENT_PTR(rapl_cores), 455 EVENT_PTR(rapl_cores),
@@ -478,6 +499,27 @@ static struct attribute *rapl_events_hsw_attr[] = {
478 NULL, 499 NULL,
479}; 500};
480 501
502static struct attribute *rapl_events_skl_attr[] = {
503 EVENT_PTR(rapl_cores),
504 EVENT_PTR(rapl_pkg),
505 EVENT_PTR(rapl_gpu),
506 EVENT_PTR(rapl_ram),
507 EVENT_PTR(rapl_psys),
508
509 EVENT_PTR(rapl_cores_unit),
510 EVENT_PTR(rapl_pkg_unit),
511 EVENT_PTR(rapl_gpu_unit),
512 EVENT_PTR(rapl_ram_unit),
513 EVENT_PTR(rapl_psys_unit),
514
515 EVENT_PTR(rapl_cores_scale),
516 EVENT_PTR(rapl_pkg_scale),
517 EVENT_PTR(rapl_gpu_scale),
518 EVENT_PTR(rapl_ram_scale),
519 EVENT_PTR(rapl_psys_scale),
520 NULL,
521};
522
481static struct attribute *rapl_events_knl_attr[] = { 523static struct attribute *rapl_events_knl_attr[] = {
482 EVENT_PTR(rapl_pkg), 524 EVENT_PTR(rapl_pkg),
483 EVENT_PTR(rapl_ram), 525 EVENT_PTR(rapl_ram),
@@ -737,6 +779,12 @@ static const struct intel_rapl_init_fun knl_rapl_init __initconst = {
737 .attrs = rapl_events_knl_attr, 779 .attrs = rapl_events_knl_attr,
738}; 780};
739 781
782static const struct intel_rapl_init_fun skl_rapl_init __initconst = {
783 .apply_quirk = false,
784 .cntr_mask = RAPL_IDX_SKL_CLN,
785 .attrs = rapl_events_skl_attr,
786};
787
740static const struct x86_cpu_id rapl_cpu_match[] __initconst = { 788static const struct x86_cpu_id rapl_cpu_match[] __initconst = {
741 X86_RAPL_MODEL_MATCH(42, snb_rapl_init), /* Sandy Bridge */ 789 X86_RAPL_MODEL_MATCH(42, snb_rapl_init), /* Sandy Bridge */
742 X86_RAPL_MODEL_MATCH(58, snb_rapl_init), /* Ivy Bridge */ 790 X86_RAPL_MODEL_MATCH(58, snb_rapl_init), /* Ivy Bridge */
@@ -750,6 +798,8 @@ static const struct x86_cpu_id rapl_cpu_match[] __initconst = {
750 X86_RAPL_MODEL_MATCH(45, snbep_rapl_init), /* Sandy Bridge-EP */ 798 X86_RAPL_MODEL_MATCH(45, snbep_rapl_init), /* Sandy Bridge-EP */
751 X86_RAPL_MODEL_MATCH(62, snbep_rapl_init), /* IvyTown */ 799 X86_RAPL_MODEL_MATCH(62, snbep_rapl_init), /* IvyTown */
752 X86_RAPL_MODEL_MATCH(87, knl_rapl_init), /* Knights Landing */ 800 X86_RAPL_MODEL_MATCH(87, knl_rapl_init), /* Knights Landing */
801 X86_RAPL_MODEL_MATCH(78, skl_rapl_init), /* Skylake */
802 X86_RAPL_MODEL_MATCH(94, skl_rapl_init), /* Skylake H/S */
753 {}, 803 {},
754}; 804};
755 805
diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
index f882cbf9e3da..94555b4d85cf 100644
--- a/arch/x86/include/asm/msr-index.h
+++ b/arch/x86/include/asm/msr-index.h
@@ -205,6 +205,8 @@
205#define MSR_CONFIG_TDP_CONTROL 0x0000064B 205#define MSR_CONFIG_TDP_CONTROL 0x0000064B
206#define MSR_TURBO_ACTIVATION_RATIO 0x0000064C 206#define MSR_TURBO_ACTIVATION_RATIO 0x0000064C
207 207
208#define MSR_PLATFORM_ENERGY_STATUS 0x0000064D
209
208#define MSR_PKG_WEIGHTED_CORE_C0_RES 0x00000658 210#define MSR_PKG_WEIGHTED_CORE_C0_RES 0x00000658
209#define MSR_PKG_ANY_CORE_C0_RES 0x00000659 211#define MSR_PKG_ANY_CORE_C0_RES 0x00000659
210#define MSR_PKG_ANY_GFXE_C0_RES 0x0000065A 212#define MSR_PKG_ANY_GFXE_C0_RES 0x0000065A