Skip to content

Commit df86f91

Browse files
committed
Merge tag 'x86-urgent-2025-09-14' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 fixes from Ingo Molnar: "Fix a CPU topology parsing bug on AMD guests, and address a lockdep warning in the resctrl filesystem" * tag 'x86-urgent-2025-09-14' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: fs/resctrl: Eliminate false positive lockdep warning when reading SNC counters x86/cpu/topology: Always try cpu_parse_topology_ext() on AMD/Hygon
2 parents 8378c89 + d2e1b84 commit df86f91

File tree

4 files changed

+19
-18
lines changed

4 files changed

+19
-18
lines changed

arch/x86/kernel/cpu/topology_amd.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -175,27 +175,30 @@ static void topoext_fixup(struct topo_scan *tscan)
175175

176176
static void parse_topology_amd(struct topo_scan *tscan)
177177
{
178-
bool has_topoext = false;
179-
180178
/*
181-
* If the extended topology leaf 0x8000_001e is available
182-
* try to get SMT, CORE, TILE, and DIE shifts from extended
179+
* Try to get SMT, CORE, TILE, and DIE shifts from extended
183180
* CPUID leaf 0x8000_0026 on supported processors first. If
184181
* extended CPUID leaf 0x8000_0026 is not supported, try to
185-
* get SMT and CORE shift from leaf 0xb first, then try to
186-
* get the CORE shift from leaf 0x8000_0008.
182+
* get SMT and CORE shift from leaf 0xb. If either leaf is
183+
* available, cpu_parse_topology_ext() will return true.
187184
*/
188-
if (cpu_feature_enabled(X86_FEATURE_TOPOEXT))
189-
has_topoext = cpu_parse_topology_ext(tscan);
185+
bool has_xtopology = cpu_parse_topology_ext(tscan);
190186

191187
if (cpu_feature_enabled(X86_FEATURE_AMD_HTR_CORES))
192188
tscan->c->topo.cpu_type = cpuid_ebx(0x80000026);
193189

194-
if (!has_topoext && !parse_8000_0008(tscan))
190+
/*
191+
* If XTOPOLOGY leaves (0x26/0xb) are not available, try to
192+
* get the CORE shift from leaf 0x8000_0008 first.
193+
*/
194+
if (!has_xtopology && !parse_8000_0008(tscan))
195195
return;
196196

197-
/* Prefer leaf 0x8000001e if available */
198-
if (parse_8000_001e(tscan, has_topoext))
197+
/*
198+
* Prefer leaf 0x8000001e if available to get the SMT shift and
199+
* the initial APIC ID if XTOPOLOGY leaves are not available.
200+
*/
201+
if (parse_8000_001e(tscan, has_xtopology))
199202
return;
200203

201204
/* Try the NODEID MSR */

fs/resctrl/ctrlmondata.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,11 +625,11 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg)
625625
*/
626626
list_for_each_entry(d, &r->mon_domains, hdr.list) {
627627
if (d->ci_id == domid) {
628-
rr.ci_id = d->ci_id;
629628
cpu = cpumask_any(&d->hdr.cpu_mask);
630629
ci = get_cpu_cacheinfo_level(cpu, RESCTRL_L3_CACHE);
631630
if (!ci)
632631
continue;
632+
rr.ci = ci;
633633
mon_event_read(&rr, r, NULL, rdtgrp,
634634
&ci->shared_cpu_map, evtid, false);
635635
goto checkresult;

fs/resctrl/internal.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ struct mon_data {
9898
* domains in @r sharing L3 @ci.id
9999
* @evtid: Which monitor event to read.
100100
* @first: Initialize MBM counter when true.
101-
* @ci_id: Cacheinfo id for L3. Only set when @d is NULL. Used when summing domains.
101+
* @ci: Cacheinfo for L3. Only set when @d is NULL. Used when summing domains.
102102
* @err: Error encountered when reading counter.
103103
* @val: Returned value of event counter. If @rgrp is a parent resource group,
104104
* @val includes the sum of event counts from its child resource groups.
@@ -112,7 +112,7 @@ struct rmid_read {
112112
struct rdt_mon_domain *d;
113113
enum resctrl_event_id evtid;
114114
bool first;
115-
unsigned int ci_id;
115+
struct cacheinfo *ci;
116116
int err;
117117
u64 val;
118118
void *arch_mon_ctx;

fs/resctrl/monitor.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,6 @@ static int __mon_event_count(u32 closid, u32 rmid, struct rmid_read *rr)
361361
{
362362
int cpu = smp_processor_id();
363363
struct rdt_mon_domain *d;
364-
struct cacheinfo *ci;
365364
struct mbm_state *m;
366365
int err, ret;
367366
u64 tval = 0;
@@ -389,8 +388,7 @@ static int __mon_event_count(u32 closid, u32 rmid, struct rmid_read *rr)
389388
}
390389

391390
/* Summing domains that share a cache, must be on a CPU for that cache. */
392-
ci = get_cpu_cacheinfo_level(cpu, RESCTRL_L3_CACHE);
393-
if (!ci || ci->id != rr->ci_id)
391+
if (!cpumask_test_cpu(cpu, &rr->ci->shared_cpu_map))
394392
return -EINVAL;
395393

396394
/*
@@ -402,7 +400,7 @@ static int __mon_event_count(u32 closid, u32 rmid, struct rmid_read *rr)
402400
*/
403401
ret = -EINVAL;
404402
list_for_each_entry(d, &rr->r->mon_domains, hdr.list) {
405-
if (d->ci_id != rr->ci_id)
403+
if (d->ci_id != rr->ci->id)
406404
continue;
407405
err = resctrl_arch_rmid_read(rr->r, d, closid, rmid,
408406
rr->evtid, &tval, rr->arch_mon_ctx);

0 commit comments

Comments
 (0)