perf/x86 subsystem fixes:

- Move the smp_processor_id() invocation back into the non-preemtible
        region, so that the result is valid to use.
 
      - Add the missing package C2 residency counters for Sierra Forest CPUs
        to make the newly added support actually useful
 -----BEGIN PGP SIGNATURE-----
 
 iQJHBAABCgAxFiEEQp8+kY+LLUocC4bMphj1TA10mKEFAmavcrATHHRnbHhAbGlu
 dXRyb25peC5kZQAKCRCmGPVMDXSYoYKrD/wKtioQzAPuZHu7XH4IiaTLAbGEuU7L
 9B+RYhMJcYmvYgZFdCJIMhsnKeNH6U6tVYx5ajYb4ThjXOpjGnJO5x8kYFoIFRuY
 CibYnGZSfjfVQtHgOXtwNt/SG0DkiTP7nS4HrX++zakXeBREVZG/gd4tAq8jWnaq
 sxJS3e3WhSz0MqYqfxbkgqIPlREAVLon3pgtBsNQwu1J6y6MV9yYJYwHW4NPCMGq
 fTpEEKUdWKOwayaljw+r+GfAiyub+t0IlZ9Cue7FaqNlbLKTnMKSnJgo/wWLdei8
 SUs5EOh76w2gFamPz+qRv9LlndvY2mhVvb+aPb/py2EtOUIISAqa/bCNI28EldEr
 pzlrybyXxU+sb8igGp7oBpa154DzSAOqIGx81pBDUeqdN9oThjAU6+qC3VgDHqLh
 XNKEL+i2MIsyHKwwsjIJDcW10g5p0ngbi+4QmucqXeSCv0Ms9+64m2/xWmFGgnJM
 KGu8Iv7e9k15E4wuUUdzsUcOo2UxzQb+HkYfXK0x39FZbRVR1nbjNUJsBrEe9gFA
 OJ3CJHJfkVMml0uLlO0vxecDkaBkDuXN33tn7SlABtf5jlWNaeoIZC1ltp/BG8oB
 vC3VTDHDpS5H3vN1wQs9UrdxXWQXbpQedv50jwotKgBcP2ibrMV5kSvxjE6LC9V0
 jEaxVFfRYVkIVg==
 =q4oe
 -----END PGP SIGNATURE-----

Merge tag 'perf-urgent-2024-08-04' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 perf fixes from Thomas Gleixner:

 - Move the smp_processor_id() invocation back into the non-preemtible
   region, so that the result is valid to use

 - Add the missing package C2 residency counters for Sierra Forest CPUs
   to make the newly added support actually useful

* tag 'perf-urgent-2024-08-04' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  perf/x86: Fix smp_processor_id()-in-preemptible warnings
  perf/x86/intel/cstate: Add pkg C2 residency counter for Sierra Forest
This commit is contained in:
Linus Torvalds 2024-08-04 08:42:18 -07:00
commit 1ddeb0ef3c
2 changed files with 15 additions and 12 deletions

View File

@ -1520,20 +1520,23 @@ static void x86_pmu_start(struct perf_event *event, int flags)
void perf_event_print_debug(void) void perf_event_print_debug(void)
{ {
u64 ctrl, status, overflow, pmc_ctrl, pmc_count, prev_left, fixed; u64 ctrl, status, overflow, pmc_ctrl, pmc_count, prev_left, fixed;
unsigned long *cntr_mask, *fixed_cntr_mask;
struct event_constraint *pebs_constraints;
struct cpu_hw_events *cpuc;
u64 pebs, debugctl; u64 pebs, debugctl;
int cpu = smp_processor_id(); int cpu, idx;
struct cpu_hw_events *cpuc = &per_cpu(cpu_hw_events, cpu);
unsigned long *cntr_mask = hybrid(cpuc->pmu, cntr_mask); guard(irqsave)();
unsigned long *fixed_cntr_mask = hybrid(cpuc->pmu, fixed_cntr_mask);
struct event_constraint *pebs_constraints = hybrid(cpuc->pmu, pebs_constraints); cpu = smp_processor_id();
unsigned long flags; cpuc = &per_cpu(cpu_hw_events, cpu);
int idx; cntr_mask = hybrid(cpuc->pmu, cntr_mask);
fixed_cntr_mask = hybrid(cpuc->pmu, fixed_cntr_mask);
pebs_constraints = hybrid(cpuc->pmu, pebs_constraints);
if (!*(u64 *)cntr_mask) if (!*(u64 *)cntr_mask)
return; return;
local_irq_save(flags);
if (x86_pmu.version >= 2) { if (x86_pmu.version >= 2) {
rdmsrl(MSR_CORE_PERF_GLOBAL_CTRL, ctrl); rdmsrl(MSR_CORE_PERF_GLOBAL_CTRL, ctrl);
rdmsrl(MSR_CORE_PERF_GLOBAL_STATUS, status); rdmsrl(MSR_CORE_PERF_GLOBAL_STATUS, status);
@ -1577,7 +1580,6 @@ void perf_event_print_debug(void)
pr_info("CPU#%d: fixed-PMC%d count: %016llx\n", pr_info("CPU#%d: fixed-PMC%d count: %016llx\n",
cpu, idx, pmc_count); cpu, idx, pmc_count);
} }
local_irq_restore(flags);
} }
void x86_pmu_stop(struct perf_event *event, int flags) void x86_pmu_stop(struct perf_event *event, int flags)

View File

@ -64,7 +64,7 @@
* perf code: 0x00 * perf code: 0x00
* Available model: SNB,IVB,HSW,BDW,SKL,KNL,GLM,CNL, * Available model: SNB,IVB,HSW,BDW,SKL,KNL,GLM,CNL,
* KBL,CML,ICL,ICX,TGL,TNT,RKL,ADL, * KBL,CML,ICL,ICX,TGL,TNT,RKL,ADL,
* RPL,SPR,MTL,ARL,LNL * RPL,SPR,MTL,ARL,LNL,SRF
* Scope: Package (physical package) * Scope: Package (physical package)
* MSR_PKG_C3_RESIDENCY: Package C3 Residency Counter. * MSR_PKG_C3_RESIDENCY: Package C3 Residency Counter.
* perf code: 0x01 * perf code: 0x01
@ -693,7 +693,8 @@ static const struct cstate_model srf_cstates __initconst = {
.core_events = BIT(PERF_CSTATE_CORE_C1_RES) | .core_events = BIT(PERF_CSTATE_CORE_C1_RES) |
BIT(PERF_CSTATE_CORE_C6_RES), BIT(PERF_CSTATE_CORE_C6_RES),
.pkg_events = BIT(PERF_CSTATE_PKG_C6_RES), .pkg_events = BIT(PERF_CSTATE_PKG_C2_RES) |
BIT(PERF_CSTATE_PKG_C6_RES),
.module_events = BIT(PERF_CSTATE_MODULE_C6_RES), .module_events = BIT(PERF_CSTATE_MODULE_C6_RES),
}; };