History

intel_rapl: support two power limits for every RAPL domain

RAPL MSR interface supports 2 power limits for package domain, and 1 power limit for other domains, while RAPL MMIO interface supports 2 power limits for both package and dram domains. And when 2 power limits are supported, the FW_LOCK bit is in bit 63 of the register, instead of bit 31. Remove the assumption that only pakcage domain supports 2 power limits. And allow the RAPL interface driver to specify the number of power limits supported, for every single RAPL domain it owns..

Zhang Rui committed 7 years ago

Commit 0c2dded1 parent d978e753 files · +28 −47Browse files

Unified · Split

3 files
  1. drivers/powercap/intel_rapl_common.c +25 −47
  2. drivers/powercap/intel_rapl_msr.c +1 −0
  3. include/linux/intel_rapl.h +2 −0
drivers/powercap/intel_rapl_common.c+25−47
@@ -38,8 +38,8 @@ · 37 unmodified lines
3838 #define POWER_LIMIT2_MASK (0x7FFFULL<<32)
3939 #define POWER_LIMIT2_ENABLE BIT_ULL(47)
4040 #define POWER_LIMIT2_CLAMP BIT_ULL(48)
41−#define POWER_PACKAGE_LOCK BIT_ULL(63)
42−#define POWER_PP_LOCK BIT(31)
41+#define POWER_HIGH_LOCK BIT_ULL(63)
42+#define POWER_LOW_LOCK BIT(31)
4343
4444 #define TIME_WINDOW1_MASK (0x7FULL<<17)
4545 #define TIME_WINDOW2_MASK (0x7FULL<<49)
@@ -513,60 +513,38 @@ static const struct powercap_zone_constraint_ops constraint_ops = { · 467 unmodified lines
513513 /* called after domain detection and package level data are set */
514514 static void rapl_init_domains(struct rapl_package *rp)
515515 {
516− int i;
516+ enum rapl_domain_type i;
517+ enum rapl_domain_reg_id j;
517518 struct rapl_domain *rd = rp->domains;
518519
519520 for (i = 0; i < RAPL_DOMAIN_MAX; i++) {
520521 unsigned int mask = rp->domain_map & (1 << i);
521522
522− rd->regs[RAPL_DOMAIN_REG_LIMIT] =
523− rp->priv->regs[i][RAPL_DOMAIN_REG_LIMIT];
524− rd->regs[RAPL_DOMAIN_REG_STATUS] =
525− rp->priv->regs[i][RAPL_DOMAIN_REG_STATUS];
526− rd->regs[RAPL_DOMAIN_REG_PERF] =
527− rp->priv->regs[i][RAPL_DOMAIN_REG_PERF];
528− rd->regs[RAPL_DOMAIN_REG_POLICY] =
529− rp->priv->regs[i][RAPL_DOMAIN_REG_POLICY];
530− rd->regs[RAPL_DOMAIN_REG_INFO] =
531− rp->priv->regs[i][RAPL_DOMAIN_REG_INFO];
532−
533− switch (mask) {
534− case BIT(RAPL_DOMAIN_PACKAGE):
535− rd->name = rapl_domain_names[RAPL_DOMAIN_PACKAGE];
536− rd->id = RAPL_DOMAIN_PACKAGE;
537− rd->rpl[0].prim_id = PL1_ENABLE;
538− rd->rpl[0].name = pl1_name;
523+ if (!mask)
524+ continue;
525+
526+ rd->rp = rp;
527+ rd->name = rapl_domain_names[i];
528+ rd->id = i;
529+ rd->rpl[0].prim_id = PL1_ENABLE;
530+ rd->rpl[0].name = pl1_name;
531+ /* some domain may support two power limits */
532+ if (rp->priv->limits[i] == 2) {
539533 rd->rpl[1].prim_id = PL2_ENABLE;
540534 rd->rpl[1].name = pl2_name;
541− break;
542− case BIT(RAPL_DOMAIN_PP0):
543− rd->name = rapl_domain_names[RAPL_DOMAIN_PP0];
544− rd->id = RAPL_DOMAIN_PP0;
545− rd->rpl[0].prim_id = PL1_ENABLE;
546− rd->rpl[0].name = pl1_name;
547− break;
548− case BIT(RAPL_DOMAIN_PP1):
549− rd->name = rapl_domain_names[RAPL_DOMAIN_PP1];
550− rd->id = RAPL_DOMAIN_PP1;
551− rd->rpl[0].prim_id = PL1_ENABLE;
552− rd->rpl[0].name = pl1_name;
553− break;
554− case BIT(RAPL_DOMAIN_DRAM):
555− rd->name = rapl_domain_names[RAPL_DOMAIN_DRAM];
556− rd->id = RAPL_DOMAIN_DRAM;
557− rd->rpl[0].prim_id = PL1_ENABLE;
558− rd->rpl[0].name = pl1_name;
535+ }
536+
537+ for (j = 0; j < RAPL_DOMAIN_REG_MAX; j++)
538+ rd->regs[j] = rp->priv->regs[i][j];
539+
540+ if (i == RAPL_DOMAIN_DRAM) {
559541 rd->domain_energy_unit =
560542 rapl_defaults->dram_domain_energy_unit;
561543 if (rd->domain_energy_unit)
562544 pr_info("DRAM domain energy unit %dpj\n",
563545 rd->domain_energy_unit);
564− break;
565− }
566− if (mask) {
567− rd->rp = rp;
568− rd++;
569546 }
547+ rd++;
570548 }
571549 }
572550
@@ -613,7 +591,7 @@ static struct rapl_primitive_info rpi[] = { · 40 unmodified lines
613591 RAPL_DOMAIN_REG_LIMIT, POWER_UNIT, 0),
614592 PRIMITIVE_INFO_INIT(POWER_LIMIT2, POWER_LIMIT2_MASK, 32,
615593 RAPL_DOMAIN_REG_LIMIT, POWER_UNIT, 0),
616− PRIMITIVE_INFO_INIT(FW_LOCK, POWER_PP_LOCK, 31,
594+ PRIMITIVE_INFO_INIT(FW_LOCK, POWER_LOW_LOCK, 31,
617595 RAPL_DOMAIN_REG_LIMIT, ARBITRARY_UNIT, 0),
618596 PRIMITIVE_INFO_INIT(PL1_ENABLE, POWER_LIMIT1_ENABLE, 15,
619597 RAPL_DOMAIN_REG_LIMIT, ARBITRARY_UNIT, 0),
@@ -675,9 +653,9 @@ static int rapl_read_data_raw(struct rapl_domain *rd, · 55 unmodified lines
675653
676654 cpu = rd->rp->lead_cpu;
677655
678− /* special-case package domain, which uses a different bit */
679− if (prim == FW_LOCK && rd->id == RAPL_DOMAIN_PACKAGE) {
680− rp->mask = POWER_PACKAGE_LOCK;
656+ /* domain with 2 limits has different bit */
657+ if (prim == FW_LOCK && rd->rp->priv->limits[rd->id] == 2) {
658+ rp->mask = POWER_HIGH_LOCK;
681659 rp->shift = 63;
682660 }
683661 /* non-hardware data are collected by the polling thread */
drivers/powercap/intel_rapl_msr.c+1−0
@@ -41,6 +41,7 @@ static struct rapl_if_priv rapl_msr_priv = { · 40 unmodified lines
4141 MSR_DRAM_POWER_LIMIT, MSR_DRAM_ENERGY_STATUS, MSR_DRAM_PERF_STATUS, 0, MSR_DRAM_POWER_INFO },
4242 .regs[RAPL_DOMAIN_PLATFORM] = {
4343 MSR_PLATFORM_POWER_LIMIT, MSR_PLATFORM_ENERGY_STATUS, 0, 0, 0},
44+ .limits[RAPL_DOMAIN_PACKAGE] = 2,
4445 };
4546
4647 /* Handles CPU hotplug on multi-socket systems.
include/linux/intel_rapl.h+2−0
@@ -104,6 +104,7 @@ struct reg_action { · 103 unmodified lines
104104 * @pcap_rapl_online: CPU hotplug state for each RAPL interface.
105105 * @reg_unit: Register for getting energy/power/time unit.
106106 * @regs: Register sets for different RAPL Domains.
107+ * @limits: Number of power limits supported by each domain.
107108 * @read_raw: Callback for reading RAPL interface specific
108109 * registers.
109110 * @write_raw: Callback for writing RAPL interface specific
@@ -115,6 +116,7 @@ struct rapl_if_priv { · 5 unmodified lines
115116 enum cpuhp_state pcap_rapl_online;
116117 u64 reg_unit;
117118 u64 regs[RAPL_DOMAIN_MAX][RAPL_DOMAIN_REG_MAX];
119+ int limits[RAPL_DOMAIN_MAX];
118120 int (*read_raw)(int cpu, struct reg_action *ra);
119121 int (*write_raw)(int cpu, struct reg_action *ra);
120122 };

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t