Skip to content

Commit 222a21d

Browse files
committed
Merge branch 'x86-topology-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 topology updates from Ingo Molnar: "Implement multi-die topology support on Intel CPUs and expose the die topology to user-space tooling, by Len Brown, Kan Liang and Zhang Rui. These changes should have no effect on the kernel's existing understanding of topologies, i.e. there should be no behavioral impact on cache, NUMA, scheduler, perf and other topologies and overall system performance" * 'x86-topology-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: perf/x86/intel/rapl: Cosmetic rename internal variables in response to multi-die/pkg support perf/x86/intel/uncore: Cosmetic renames in response to multi-die/pkg support hwmon/coretemp: Cosmetic: Rename internal variables to zones from packages thermal/x86_pkg_temp_thermal: Cosmetic: Rename internal variables to zones from packages perf/x86/intel/cstate: Support multi-die/package perf/x86/intel/rapl: Support multi-die/package perf/x86/intel/uncore: Support multi-die/package topology: Create core_cpus and die_cpus sysfs attributes topology: Create package_cpus sysfs attribute hwmon/coretemp: Support multi-die/package powercap/intel_rapl: Update RAPL domain name and debug messages thermal/x86_pkg_temp_thermal: Support multi-die/package powercap/intel_rapl: Support multi-die/package powercap/intel_rapl: Simplify rapl_find_package() x86/topology: Define topology_logical_die_id() x86/topology: Define topology_die_id() cpu/topology: Export die_id x86/topology: Create topology_max_die_per_package() x86/topology: Add CPUID.1F multi-die/package support
2 parents 8faef71 + eb876fb commit 222a21d

File tree

19 files changed

+422
-214
lines changed

19 files changed

+422
-214
lines changed

Documentation/cputopology.txt

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ physical_package_id:
1212
socket number, but the actual value is architecture and platform
1313
dependent.
1414

15+
die_id:
16+
17+
the CPU die ID of cpuX. Typically it is the hardware platform's
18+
identifier (rather than the kernel's). The actual value is
19+
architecture and platform dependent.
20+
1521
core_id:
1622

1723
the CPU core ID of cpuX. Typically it is the hardware platform's
@@ -30,25 +36,33 @@ drawer_id:
3036
identifier (rather than the kernel's). The actual value is
3137
architecture and platform dependent.
3238

33-
thread_siblings:
39+
core_cpus:
3440

35-
internal kernel map of cpuX's hardware threads within the same
36-
core as cpuX.
41+
internal kernel map of CPUs within the same core.
42+
(deprecated name: "thread_siblings")
3743

38-
thread_siblings_list:
44+
core_cpus_list:
3945

40-
human-readable list of cpuX's hardware threads within the same
41-
core as cpuX.
46+
human-readable list of CPUs within the same core.
47+
(deprecated name: "thread_siblings_list");
4248

43-
core_siblings:
49+
package_cpus:
4450

45-
internal kernel map of cpuX's hardware threads within the same
46-
physical_package_id.
51+
internal kernel map of the CPUs sharing the same physical_package_id.
52+
(deprecated name: "core_siblings")
4753

48-
core_siblings_list:
54+
package_cpus_list:
4955

50-
human-readable list of cpuX's hardware threads within the same
51-
physical_package_id.
56+
human-readable list of CPUs sharing the same physical_package_id.
57+
(deprecated name: "core_siblings_list")
58+
59+
die_cpus:
60+
61+
internal kernel map of CPUs within the same die.
62+
63+
die_cpus_list:
64+
65+
human-readable list of CPUs within the same die.
5266

5367
book_siblings:
5468

@@ -81,11 +95,13 @@ For an architecture to support this feature, it must define some of
8195
these macros in include/asm-XXX/topology.h::
8296

8397
#define topology_physical_package_id(cpu)
98+
#define topology_die_id(cpu)
8499
#define topology_core_id(cpu)
85100
#define topology_book_id(cpu)
86101
#define topology_drawer_id(cpu)
87102
#define topology_sibling_cpumask(cpu)
88103
#define topology_core_cpumask(cpu)
104+
#define topology_die_cpumask(cpu)
89105
#define topology_book_cpumask(cpu)
90106
#define topology_drawer_cpumask(cpu)
91107

@@ -99,9 +115,11 @@ provides default definitions for any of the above macros that are
99115
not defined by include/asm-XXX/topology.h:
100116

101117
1) topology_physical_package_id: -1
102-
2) topology_core_id: 0
103-
3) topology_sibling_cpumask: just the given CPU
104-
4) topology_core_cpumask: just the given CPU
118+
2) topology_die_id: -1
119+
3) topology_core_id: 0
120+
4) topology_sibling_cpumask: just the given CPU
121+
5) topology_core_cpumask: just the given CPU
122+
6) topology_die_cpumask: just the given CPU
105123

106124
For architectures that don't support books (CONFIG_SCHED_BOOK) there are no
107125
default definitions for topology_book_id() and topology_book_cpumask().

Documentation/x86/topology.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ Package-related topology information in the kernel:
4949

5050
The number of cores in a package. This information is retrieved via CPUID.
5151

52+
- cpuinfo_x86.x86_max_dies:
53+
54+
The number of dies in a package. This information is retrieved via CPUID.
55+
5256
- cpuinfo_x86.phys_proc_id:
5357

5458
The physical ID of the package. This information is retrieved via CPUID

arch/x86/events/intel/cstate.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ static int cstate_pmu_event_init(struct perf_event *event)
302302
return -EINVAL;
303303
event->hw.event_base = pkg_msr[cfg].msr;
304304
cpu = cpumask_any_and(&cstate_pkg_cpu_mask,
305-
topology_core_cpumask(event->cpu));
305+
topology_die_cpumask(event->cpu));
306306
} else {
307307
return -ENOENT;
308308
}
@@ -385,7 +385,7 @@ static int cstate_cpu_exit(unsigned int cpu)
385385
if (has_cstate_pkg &&
386386
cpumask_test_and_clear_cpu(cpu, &cstate_pkg_cpu_mask)) {
387387

388-
target = cpumask_any_but(topology_core_cpumask(cpu), cpu);
388+
target = cpumask_any_but(topology_die_cpumask(cpu), cpu);
389389
/* Migrate events if there is a valid target */
390390
if (target < nr_cpu_ids) {
391391
cpumask_set_cpu(target, &cstate_pkg_cpu_mask);
@@ -414,7 +414,7 @@ static int cstate_cpu_init(unsigned int cpu)
414414
* in the package cpu mask as the designated reader.
415415
*/
416416
target = cpumask_any_and(&cstate_pkg_cpu_mask,
417-
topology_core_cpumask(cpu));
417+
topology_die_cpumask(cpu));
418418
if (has_cstate_pkg && target >= nr_cpu_ids)
419419
cpumask_set_cpu(cpu, &cstate_pkg_cpu_mask);
420420

@@ -663,7 +663,13 @@ static int __init cstate_init(void)
663663
}
664664

665665
if (has_cstate_pkg) {
666-
err = perf_pmu_register(&cstate_pkg_pmu, cstate_pkg_pmu.name, -1);
666+
if (topology_max_die_per_package() > 1) {
667+
err = perf_pmu_register(&cstate_pkg_pmu,
668+
"cstate_die", -1);
669+
} else {
670+
err = perf_pmu_register(&cstate_pkg_pmu,
671+
cstate_pkg_pmu.name, -1);
672+
}
667673
if (err) {
668674
has_cstate_pkg = false;
669675
pr_info("Failed to register cstate pkg pmu\n");

arch/x86/events/intel/rapl.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ struct rapl_pmu {
149149

150150
struct rapl_pmus {
151151
struct pmu pmu;
152-
unsigned int maxpkg;
152+
unsigned int maxdie;
153153
struct rapl_pmu *pmus[];
154154
};
155155

@@ -162,13 +162,13 @@ static u64 rapl_timer_ms;
162162

163163
static inline struct rapl_pmu *cpu_to_rapl_pmu(unsigned int cpu)
164164
{
165-
unsigned int pkgid = topology_logical_package_id(cpu);
165+
unsigned int dieid = topology_logical_die_id(cpu);
166166

167167
/*
168168
* The unsigned check also catches the '-1' return value for non
169169
* existent mappings in the topology map.
170170
*/
171-
return pkgid < rapl_pmus->maxpkg ? rapl_pmus->pmus[pkgid] : NULL;
171+
return dieid < rapl_pmus->maxdie ? rapl_pmus->pmus[dieid] : NULL;
172172
}
173173

174174
static inline u64 rapl_read_counter(struct perf_event *event)
@@ -572,7 +572,7 @@ static int rapl_cpu_offline(unsigned int cpu)
572572

573573
pmu->cpu = -1;
574574
/* Find a new cpu to collect rapl events */
575-
target = cpumask_any_but(topology_core_cpumask(cpu), cpu);
575+
target = cpumask_any_but(topology_die_cpumask(cpu), cpu);
576576

577577
/* Migrate rapl events to the new target */
578578
if (target < nr_cpu_ids) {
@@ -599,14 +599,14 @@ static int rapl_cpu_online(unsigned int cpu)
599599
pmu->timer_interval = ms_to_ktime(rapl_timer_ms);
600600
rapl_hrtimer_init(pmu);
601601

602-
rapl_pmus->pmus[topology_logical_package_id(cpu)] = pmu;
602+
rapl_pmus->pmus[topology_logical_die_id(cpu)] = pmu;
603603
}
604604

605605
/*
606606
* Check if there is an online cpu in the package which collects rapl
607607
* events already.
608608
*/
609-
target = cpumask_any_and(&rapl_cpu_mask, topology_core_cpumask(cpu));
609+
target = cpumask_any_and(&rapl_cpu_mask, topology_die_cpumask(cpu));
610610
if (target < nr_cpu_ids)
611611
return 0;
612612

@@ -669,22 +669,22 @@ static void cleanup_rapl_pmus(void)
669669
{
670670
int i;
671671

672-
for (i = 0; i < rapl_pmus->maxpkg; i++)
672+
for (i = 0; i < rapl_pmus->maxdie; i++)
673673
kfree(rapl_pmus->pmus[i]);
674674
kfree(rapl_pmus);
675675
}
676676

677677
static int __init init_rapl_pmus(void)
678678
{
679-
int maxpkg = topology_max_packages();
679+
int maxdie = topology_max_packages() * topology_max_die_per_package();
680680
size_t size;
681681

682-
size = sizeof(*rapl_pmus) + maxpkg * sizeof(struct rapl_pmu *);
682+
size = sizeof(*rapl_pmus) + maxdie * sizeof(struct rapl_pmu *);
683683
rapl_pmus = kzalloc(size, GFP_KERNEL);
684684
if (!rapl_pmus)
685685
return -ENOMEM;
686686

687-
rapl_pmus->maxpkg = maxpkg;
687+
rapl_pmus->maxdie = maxdie;
688688
rapl_pmus->pmu.attr_groups = rapl_attr_groups;
689689
rapl_pmus->pmu.task_ctx_nr = perf_invalid_context;
690690
rapl_pmus->pmu.event_init = rapl_pmu_event_init;

0 commit comments

Comments
 (0)