Skip to content

Commit a4c421b

Browse files
AlisonSchofieldgregkh
authored andcommitted
x86, sched: Treat Intel SNC topology as default, COD as exception
commit 2c88d45 upstream. Commit 1340ccf ("x86,sched: Allow topologies where NUMA nodes share an LLC") added a vendor and model specific check to never call topology_sane() for Intel Skylake Server systems where NUMA nodes share an LLC. Intel Ice Lake and Sapphire Rapids CPUs also enumerate an LLC that is shared by multiple NUMA nodes. The LLC on these CPUs is shared for off-package data access but private to the NUMA node for on-package access. Rather than managing a list of allowable SNC topologies, make this SNC topology the default, and treat Intel's Cluster-On-Die (COD) topology as the exception. In SNC mode, Sky Lake, Ice Lake, and Sapphire Rapids servers do not emit this warning: sched: CPU raspberrypi#3's llc-sibling CPU #0 is not on the same node! [node: 1 != 0]. Ignoring dependency. Suggested-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Alison Schofield <alison.schofield@intel.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Dave Hansen <dave.hansen@linux.intel.com> Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/20210310190233.31752-1-alison.schofield@intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 4c0ddc8 commit a4c421b

1 file changed

Lines changed: 46 additions & 44 deletions

File tree

‎arch/x86/kernel/smpboot.c‎

Lines changed: 46 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -452,29 +452,52 @@ static bool match_smt(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o)
452452
return false;
453453
}
454454

455+
static bool match_die(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o)
456+
{
457+
if (c->phys_proc_id == o->phys_proc_id &&
458+
c->cpu_die_id == o->cpu_die_id)
459+
return true;
460+
return false;
461+
}
462+
455463
/*
456-
* Define snc_cpu[] for SNC (Sub-NUMA Cluster) CPUs.
464+
* Unlike the other levels, we do not enforce keeping a
465+
* multicore group inside a NUMA node. If this happens, we will
466+
* discard the MC level of the topology later.
467+
*/
468+
static bool match_pkg(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o)
469+
{
470+
if (c->phys_proc_id == o->phys_proc_id)
471+
return true;
472+
return false;
473+
}
474+
475+
/*
476+
* Define intel_cod_cpu[] for Intel COD (Cluster-on-Die) CPUs.
457477
*
458-
* These are Intel CPUs that enumerate an LLC that is shared by
459-
* multiple NUMA nodes. The LLC on these systems is shared for
460-
* off-package data access but private to the NUMA node (half
461-
* of the package) for on-package access.
478+
* Any Intel CPU that has multiple nodes per package and does not
479+
* match intel_cod_cpu[] has the SNC (Sub-NUMA Cluster) topology.
462480
*
463-
* CPUID (the source of the information about the LLC) can only
464-
* enumerate the cache as being shared *or* unshared, but not
465-
* this particular configuration. The CPU in this case enumerates
466-
* the cache to be shared across the entire package (spanning both
467-
* NUMA nodes).
481+
* When in SNC mode, these CPUs enumerate an LLC that is shared
482+
* by multiple NUMA nodes. The LLC is shared for off-package data
483+
* access but private to the NUMA node (half of the package) for
484+
* on-package access. CPUID (the source of the information about
485+
* the LLC) can only enumerate the cache as shared or unshared,
486+
* but not this particular configuration.
468487
*/
469488

470-
static const struct x86_cpu_id snc_cpu[] = {
471-
X86_MATCH_INTEL_FAM6_MODEL(SKYLAKE_X, NULL),
489+
static const struct x86_cpu_id intel_cod_cpu[] = {
490+
X86_MATCH_INTEL_FAM6_MODEL(HASWELL_X, 0), /* COD */
491+
X86_MATCH_INTEL_FAM6_MODEL(BROADWELL_X, 0), /* COD */
492+
X86_MATCH_INTEL_FAM6_MODEL(ANY, 1), /* SNC */
472493
{}
473494
};
474495

475496
static bool match_llc(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o)
476497
{
498+
const struct x86_cpu_id *id = x86_match_cpu(intel_cod_cpu);
477499
int cpu1 = c->cpu_index, cpu2 = o->cpu_index;
500+
bool intel_snc = id && id->driver_data;
478501

479502
/* Do not match if we do not have a valid APICID for cpu: */
480503
if (per_cpu(cpu_llc_id, cpu1) == BAD_APICID)
@@ -489,32 +512,12 @@ static bool match_llc(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o)
489512
* means 'c' does not share the LLC of 'o'. This will be
490513
* reflected to userspace.
491514
*/
492-
if (!topology_same_node(c, o) && x86_match_cpu(snc_cpu))
515+
if (match_pkg(c, o) && !topology_same_node(c, o) && intel_snc)
493516
return false;
494517

495518
return topology_sane(c, o, "llc");
496519
}
497520

498-
/*
499-
* Unlike the other levels, we do not enforce keeping a
500-
* multicore group inside a NUMA node. If this happens, we will
501-
* discard the MC level of the topology later.
502-
*/
503-
static bool match_pkg(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o)
504-
{
505-
if (c->phys_proc_id == o->phys_proc_id)
506-
return true;
507-
return false;
508-
}
509-
510-
static bool match_die(struct cpuinfo_x86 *c, struct cpuinfo_x86 *o)
511-
{
512-
if ((c->phys_proc_id == o->phys_proc_id) &&
513-
(c->cpu_die_id == o->cpu_die_id))
514-
return true;
515-
return false;
516-
}
517-
518521

519522
#if defined(CONFIG_SCHED_SMT) || defined(CONFIG_SCHED_MC)
520523
static inline int x86_sched_itmt_flags(void)
@@ -586,14 +589,23 @@ void set_cpu_sibling_map(int cpu)
586589
for_each_cpu(i, cpu_sibling_setup_mask) {
587590
o = &cpu_data(i);
588591

592+
if (match_pkg(c, o) && !topology_same_node(c, o))
593+
x86_has_numa_in_package = true;
594+
589595
if ((i == cpu) || (has_smt && match_smt(c, o)))
590596
link_mask(topology_sibling_cpumask, cpu, i);
591597

592598
if ((i == cpu) || (has_mp && match_llc(c, o)))
593599
link_mask(cpu_llc_shared_mask, cpu, i);
594600

601+
if ((i == cpu) || (has_mp && match_die(c, o)))
602+
link_mask(topology_die_cpumask, cpu, i);
595603
}
596604

605+
threads = cpumask_weight(topology_sibling_cpumask(cpu));
606+
if (threads > __max_smt_threads)
607+
__max_smt_threads = threads;
608+
597609
/*
598610
* This needs a separate iteration over the cpus because we rely on all
599611
* topology_sibling_cpumask links to be set-up.
@@ -607,8 +619,7 @@ void set_cpu_sibling_map(int cpu)
607619
/*
608620
* Does this new cpu bringup a new core?
609621
*/
610-
if (cpumask_weight(
611-
topology_sibling_cpumask(cpu)) == 1) {
622+
if (threads == 1) {
612623
/*
613624
* for each core in package, increment
614625
* the booted_cores for this new cpu
@@ -625,16 +636,7 @@ void set_cpu_sibling_map(int cpu)
625636
} else if (i != cpu && !c->booted_cores)
626637
c->booted_cores = cpu_data(i).booted_cores;
627638
}
628-
if (match_pkg(c, o) && !topology_same_node(c, o))
629-
x86_has_numa_in_package = true;
630-
631-
if ((i == cpu) || (has_mp && match_die(c, o)))
632-
link_mask(topology_die_cpumask, cpu, i);
633639
}
634-
635-
threads = cpumask_weight(topology_sibling_cpumask(cpu));
636-
if (threads > __max_smt_threads)
637-
__max_smt_threads = threads;
638640
}
639641

640642
/* maps the cpu to the sched domain representing multi-core */

0 commit comments

Comments
 (0)