Skip to contentSkip to conversation

x86: remove cpu_**_mask() functions

PATCH RESEND Superseded Bartosz Golaszewski 3 participants 13 messages May 19, 2015 – May 26, 2015

Subsystems (19)
lore
Share & tools
lore
#0 lore raw

v2 cover x86: remove cpu_**_mask() functions

Two functions defined in asm/smp.h: cpu_sibling_mask() and cpu_core_mask(), have the same functionality as macros defined in linux/topology.h:
topology_thread_cpumask() and topology_core_cpumask() respectively.

They are not documented and are architecture specific. Also: different naming for the same functionality (in case of cpu_sibling_mask() and topology_thread_cpumask()) is a bit misleading.

This series makes all the callers switch to using the topology.h macros and removes their smp.h counterparts. While we're at it: rename topology_thread_cpumask() to topology_sibling_cpumask() to be consistent with the term used in the scheduler.

The same duplication exists on powerpc.

NOTE: patch 2/9 had been already submitted separately but didn't receive any attention, so I'm attaching it to this series.

v2:
- renamed topology_thread_cpumask() to topology_sibling_cpumask()
- updated Documentation/cputopology.txt

v1:
https://lkml.org/lkml/2015/4/30/188

Bartosz Golaszewski (9):
topology: rename topology_thread_cpumask()
Documentation: update cputopology.txt
coretemp: replace cpu_sibling_mask() with topology_sibling_cpumask()
powernow-k8: replace cpu_core_mask() with topology_core_cpumask()
p4-clockmod: replace cpu_sibling_mask() with topology_sibling_cpumask()
acpi-cpufreq: replace cpu_**_mask() with topology_**_cpumask()
speedstep-ich: replace cpu_sibling_mask() with topology_sibling_cpumask()
x86: replace cpu_**_mask() with topology_**_cpumask()
x86: remove cpu_sibling_mask() and cpu_core_mask()

 Documentation/cputopology.txt                      | 37 +++++++++++++------
 arch/arm/include/asm/topology.h                    |  2 +-
 arch/arm64/include/asm/topology.h                  |  2 +-
 arch/ia64/include/asm/topology.h                   |  2 +-
 arch/mips/include/asm/topology.h                   |  2 +-
 arch/powerpc/include/asm/topology.h                |  2 +-
 arch/powerpc/mm/tlb_nohash.c                       |  2 +-
 arch/s390/include/asm/topology.h                   |  3 +-
 arch/sparc/include/asm/topology_64.h               |  2 +-
 arch/tile/include/asm/topology.h                   |  2 +-
 arch/x86/include/asm/smp.h                         | 10 ------
 arch/x86/include/asm/topology.h                    |  2 +-
 arch/x86/kernel/cpu/perf_event_intel.c             |  6 ++--
 arch/x86/kernel/cpu/proc.c                         |  3 +-
 arch/x86/kernel/smpboot.c                          | 42 +++++++++++-----------
 arch/x86/kernel/tsc_sync.c                         |  2 +-
 block/blk-mq-cpumap.c                              |  2 +-
 drivers/acpi/acpi_pad.c                            |  2 +-
 drivers/base/topology.c                            |  2 +-
 drivers/cpufreq/acpi-cpufreq.c                     |  5 +--
 drivers/cpufreq/p4-clockmod.c                      |  2 +-
 drivers/cpufreq/powernow-k8.c                      | 13 ++-----
 drivers/cpufreq/speedstep-ich.c                    |  2 +-
 drivers/hwmon/coretemp.c                           |  3 +-
 drivers/net/ethernet/sfc/efx.c                     |  2 +-
 .../staging/lustre/lustre/libcfs/linux/linux-cpu.c |  2 +-
 drivers/staging/lustre/lustre/ptlrpc/service.c     |  4 +--
 include/linux/topology.h                           |  6 ++--
 lib/cpu_rmap.c                                     |  2 +-
 29 files changed, 87 insertions(+), 81 deletions(-)
Signature · 1 line
2.1.4
#1 lore raw

PATCH RESEND v2 1/9 topology: rename topology_thread_cpumask()

Rename topology_thread_cpumask() to topology_sibling_cpumask() for more consistency with scheduler code.

---
 Documentation/cputopology.txt                          | 2 +-
 arch/arm/include/asm/topology.h                        | 2 +-
 arch/arm64/include/asm/topology.h                      | 2 +-
 arch/ia64/include/asm/topology.h                       | 2 +-
 arch/mips/include/asm/topology.h                       | 2 +-
 arch/powerpc/include/asm/topology.h                    | 2 +-
 arch/powerpc/mm/tlb_nohash.c                           | 2 +-
 arch/s390/include/asm/topology.h                       | 3 ++-
 arch/sparc/include/asm/topology_64.h                   | 2 +-
 arch/tile/include/asm/topology.h                       | 2 +-
 arch/x86/include/asm/topology.h                        | 2 +-
 arch/x86/kernel/cpu/perf_event_intel.c                 | 6 +++---
 block/blk-mq-cpumap.c                                  | 2 +-
 drivers/acpi/acpi_pad.c                                | 2 +-
 drivers/base/topology.c                                | 2 +-
 drivers/net/ethernet/sfc/efx.c                         | 2 +-
 drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c | 2 +-
 drivers/staging/lustre/lustre/ptlrpc/service.c         | 4 ++--
 include/linux/topology.h                               | 6 +++---
 lib/cpu_rmap.c                                         | 2 +-
 20 files changed, 26 insertions(+), 25 deletions(-)
Documentation/cputopology.txt +1 -1
index 0aad6de..428a961 100644
@@ -44,7 +44,7 @@ these macros in include/asm-XXX/topology.h:
 #define topology_physical_package_id(cpu)
 #define topology_core_id(cpu)
 #define topology_book_id(cpu)
-#define topology_thread_cpumask(cpu)
+#define topology_sibling_cpumask(cpu)
 #define topology_core_cpumask(cpu)
 #define topology_book_cpumask(cpu)
 
arch/arm/include/asm/topology.h +1 -1
index 2fe85ff..370f7a7 100644
@@ -18,7 +18,7 @@ extern struct cputopo_arm cpu_topology[NR_CPUS];
 #define topology_physical_package_id(cpu)	(cpu_topology[cpu].socket_id)
 #define topology_core_id(cpu)		(cpu_topology[cpu].core_id)
 #define topology_core_cpumask(cpu)	(&cpu_topology[cpu].core_sibling)
-#define topology_thread_cpumask(cpu)	(&cpu_topology[cpu].thread_sibling)
+#define topology_sibling_cpumask(cpu)	(&cpu_topology[cpu].thread_sibling)
 
 void init_cpu_topology(void);
 void store_cpu_topology(unsigned int cpuid);
arch/arm64/include/asm/topology.h +1 -1
index 7ebcd31..225ec35 100644
@@ -18,7 +18,7 @@ extern struct cpu_topology cpu_topology[NR_CPUS];
 #define topology_physical_package_id(cpu)	(cpu_topology[cpu].cluster_id)
 #define topology_core_id(cpu)		(cpu_topology[cpu].core_id)
 #define topology_core_cpumask(cpu)	(&cpu_topology[cpu].core_sibling)
-#define topology_thread_cpumask(cpu)	(&cpu_topology[cpu].thread_sibling)
+#define topology_sibling_cpumask(cpu)	(&cpu_topology[cpu].thread_sibling)
 
 void init_cpu_topology(void);
 void store_cpu_topology(unsigned int cpuid);
arch/ia64/include/asm/topology.h +1 -1
index 6437ca2..3ad8f69 100644
@@ -53,7 +53,7 @@ void build_cpu_to_node_map(void);
 #define topology_physical_package_id(cpu)	(cpu_data(cpu)->socket_id)
 #define topology_core_id(cpu)			(cpu_data(cpu)->core_id)
 #define topology_core_cpumask(cpu)		(&cpu_core_map[cpu])
-#define topology_thread_cpumask(cpu)		(&per_cpu(cpu_sibling_map, cpu))
+#define topology_sibling_cpumask(cpu)		(&per_cpu(cpu_sibling_map, cpu))
 #endif
 
 extern void arch_fix_phys_package_id(int num, u32 slot);
arch/mips/include/asm/topology.h +1 -1
index 3e307ec..7afda41 100644
@@ -15,7 +15,7 @@
 #define topology_physical_package_id(cpu)	(cpu_data[cpu].package)
 #define topology_core_id(cpu)			(cpu_data[cpu].core)
 #define topology_core_cpumask(cpu)		(&cpu_core_map[cpu])
-#define topology_thread_cpumask(cpu)		(&cpu_sibling_map[cpu])
+#define topology_sibling_cpumask(cpu)		(&cpu_sibling_map[cpu])
 #endif
 
 #endif /* __ASM_TOPOLOGY_H */
arch/powerpc/include/asm/topology.h +1 -1
index 5f1048e..8b3b46b 100644
@@ -87,7 +87,7 @@ static inline int prrn_is_enabled(void)
 #include <asm/smp.h>
 
 #define topology_physical_package_id(cpu)	(cpu_to_chip_id(cpu))
-#define topology_thread_cpumask(cpu)	(per_cpu(cpu_sibling_map, cpu))
+#define topology_sibling_cpumask(cpu)	(per_cpu(cpu_sibling_map, cpu))
 #define topology_core_cpumask(cpu)	(per_cpu(cpu_core_map, cpu))
 #define topology_core_id(cpu)		(cpu_to_core_id(cpu))
 #endif
arch/powerpc/mm/tlb_nohash.c +1 -1
index cbd3d06..723a099 100644
@@ -217,7 +217,7 @@ static DEFINE_RAW_SPINLOCK(tlbivax_lock);
 static int mm_is_core_local(struct mm_struct *mm)
 {
 	return cpumask_subset(mm_cpumask(mm),
-			      topology_thread_cpumask(smp_processor_id()));
+			      topology_sibling_cpumask(smp_processor_id()));
 }
 
 struct tlb_flush_param {
arch/s390/include/asm/topology.h +2 -1
index b1453a2..4990f6c 100644
@@ -22,7 +22,8 @@ DECLARE_PER_CPU(struct cpu_topology_s390, cpu_topology);
 
 #define topology_physical_package_id(cpu) (per_cpu(cpu_topology, cpu).socket_id)
 #define topology_thread_id(cpu)		  (per_cpu(cpu_topology, cpu).thread_id)
-#define topology_thread_cpumask(cpu)	  (&per_cpu(cpu_topology, cpu).thread_mask)
+#define topology_sibling_cpumask(cpu) \
+		(&per_cpu(cpu_topology, cpu).thread_mask)
 #define topology_core_id(cpu)		  (per_cpu(cpu_topology, cpu).core_id)
 #define topology_core_cpumask(cpu)	  (&per_cpu(cpu_topology, cpu).core_mask)
 #define topology_book_id(cpu)		  (per_cpu(cpu_topology, cpu).book_id)
arch/sparc/include/asm/topology_64.h +1 -1
index ed8f071..9a928fc 100644
@@ -41,7 +41,7 @@ static inline int pcibus_to_node(struct pci_bus *pbus)
 #define topology_physical_package_id(cpu)	(cpu_data(cpu).proc_id)
 #define topology_core_id(cpu)			(cpu_data(cpu).core_id)
 #define topology_core_cpumask(cpu)		(&cpu_core_map[cpu])
-#define topology_thread_cpumask(cpu)		(&per_cpu(cpu_sibling_map, cpu))
+#define topology_sibling_cpumask(cpu)		(&per_cpu(cpu_sibling_map, cpu))
 #endif /* CONFIG_SMP */
 
 extern cpumask_t cpu_core_map[NR_CPUS];
arch/tile/include/asm/topology.h +1 -1
index 9383118..76b0d0e 100644
@@ -55,7 +55,7 @@ static inline const struct cpumask *cpumask_of_node(int node)
 #define topology_physical_package_id(cpu)       ((void)(cpu), 0)
 #define topology_core_id(cpu)                   (cpu)
 #define topology_core_cpumask(cpu)              ((void)(cpu), cpu_online_mask)
-#define topology_thread_cpumask(cpu)            cpumask_of(cpu)
+#define topology_sibling_cpumask(cpu)           cpumask_of(cpu)
 #endif
 
 #endif /* _ASM_TILE_TOPOLOGY_H */
arch/x86/include/asm/topology.h +1 -1
index 0e8f04f..5a77593f 100644
@@ -124,7 +124,7 @@ extern const struct cpumask *cpu_coregroup_mask(int cpu);
 
 #ifdef ENABLE_TOPO_DEFINES
 #define topology_core_cpumask(cpu)		(per_cpu(cpu_core_map, cpu))
-#define topology_thread_cpumask(cpu)		(per_cpu(cpu_sibling_map, cpu))
+#define topology_sibling_cpumask(cpu)		(per_cpu(cpu_sibling_map, cpu))
 #endif
 
 static inline void arch_fix_phys_package_id(int num, u32 slot)
arch/x86/kernel/cpu/perf_event_intel.c +3 -3
index 3998131..3248177 100644
@@ -2621,7 +2621,7 @@ static void intel_pmu_cpu_starting(int cpu)
 	if (!(x86_pmu.flags & PMU_FL_NO_HT_SHARING)) {
 		void **onln = &cpuc->kfree_on_online[X86_PERF_KFREE_SHARED];
 
-		for_each_cpu(i, topology_thread_cpumask(cpu)) {
+		for_each_cpu(i, topology_sibling_cpumask(cpu)) {
 			struct intel_shared_regs *pc;
 
 			pc = per_cpu(cpu_hw_events, i).shared_regs;
@@ -2641,7 +2641,7 @@ static void intel_pmu_cpu_starting(int cpu)
 	if (x86_pmu.flags & PMU_FL_EXCL_CNTRS) {
 		int h = x86_pmu.num_counters >> 1;
 
-		for_each_cpu(i, topology_thread_cpumask(cpu)) {
+		for_each_cpu(i, topology_sibling_cpumask(cpu)) {
 			struct intel_excl_cntrs *c;
 
 			c = per_cpu(cpu_hw_events, i).excl_cntrs;
@@ -3403,7 +3403,7 @@ static __init int fixup_ht_bug(void)
 	if (!(x86_pmu.flags & PMU_FL_EXCL_ENABLED))
 		return 0;
 
-	w = cpumask_weight(topology_thread_cpumask(cpu));
+	w = cpumask_weight(topology_sibling_cpumask(cpu));
 	if (w > 1) {
 		pr_info("PMU erratum BJ122, BV98, HSD29 worked around, HT is on\n");
 		return 0;
block/blk-mq-cpumap.c +1 -1
index 5f13f4d..1e28ddb 100644
@@ -24,7 +24,7 @@ static int get_first_sibling(unsigned int cpu)
 {
 	unsigned int ret;
 
-	ret = cpumask_first(topology_thread_cpumask(cpu));
+	ret = cpumask_first(topology_sibling_cpumask(cpu));
 	if (ret < nr_cpu_ids)
 		return ret;
 
drivers/acpi/acpi_pad.c +1 -1
index 6bc9cbc..00b3980 100644
@@ -105,7 +105,7 @@ static void round_robin_cpu(unsigned int tsk_index)
 	mutex_lock(&round_robin_lock);
 	cpumask_clear(tmp);
 	for_each_cpu(cpu, pad_busy_cpus)
-		cpumask_or(tmp, tmp, topology_thread_cpumask(cpu));
+		cpumask_or(tmp, tmp, topology_sibling_cpumask(cpu));
 	cpumask_andnot(tmp, cpu_online_mask, tmp);
 	/* avoid HT sibilings if possible */
 	if (cpumask_empty(tmp))
drivers/base/topology.c +1 -1
index 6491f45..8b7d7f8 100644
@@ -61,7 +61,7 @@ static DEVICE_ATTR_RO(physical_package_id);
 define_id_show_func(core_id);
 static DEVICE_ATTR_RO(core_id);
 
-define_siblings_show_func(thread_siblings, thread_cpumask);
+define_siblings_show_func(thread_siblings, sibling_cpumask);
 static DEVICE_ATTR_RO(thread_siblings);
 static DEVICE_ATTR_RO(thread_siblings_list);
 
drivers/net/ethernet/sfc/efx.c +1 -1
index 4b00545..65944dd 100644
@@ -1304,7 +1304,7 @@ static unsigned int efx_wanted_parallelism(struct efx_nic *efx)
 			if (!cpumask_test_cpu(cpu, thread_mask)) {
 				++count;
 				cpumask_or(thread_mask, thread_mask,
-					   topology_thread_cpumask(cpu));
+					   topology_sibling_cpumask(cpu));
 			}
 		}
 
drivers/staging/lustre/lustre/libcfs/linux/linux-cpu.c +1 -1
index cc3ab35..f926224 100644
@@ -87,7 +87,7 @@ static void cfs_cpu_core_siblings(int cpu, cpumask_t *mask)
 /* return cpumask of HTs in the same core */
 static void cfs_cpu_ht_siblings(int cpu, cpumask_t *mask)
 {
-	cpumask_copy(mask, topology_thread_cpumask(cpu));
+	cpumask_copy(mask, topology_sibling_cpumask(cpu));
 }
 
 static void cfs_node_to_cpumask(int node, cpumask_t *mask)
drivers/staging/lustre/lustre/ptlrpc/service.c +2 -2
index 8e61421..344189a 100644
@@ -557,7 +557,7 @@ ptlrpc_server_nthreads_check(struct ptlrpc_service *svc,
 		 * there are.
 		 */
 		/* weight is # of HTs */
-		if (cpumask_weight(topology_thread_cpumask(0)) > 1) {
+		if (cpumask_weight(topology_sibling_cpumask(0)) > 1) {
 			/* depress thread factor for hyper-thread */
 			factor = factor - (factor >> 1) + (factor >> 3);
 		}
@@ -2768,7 +2768,7 @@ int ptlrpc_hr_init(void)
 
 	init_waitqueue_head(&ptlrpc_hr.hr_waitq);
 
-	weight = cpumask_weight(topology_thread_cpumask(0));
+	weight = cpumask_weight(topology_sibling_cpumask(0));
 
 	cfs_percpt_for_each(hrp, i, ptlrpc_hr.hr_partitions) {
 		hrp->hrp_cpt = i;
include/linux/topology.h +3 -3
index 909b6e4..73ddad1 100644
@@ -191,8 +191,8 @@ static inline int cpu_to_mem(int cpu)
 #ifndef topology_core_id
 #define topology_core_id(cpu)			((void)(cpu), 0)
 #endif
-#ifndef topology_thread_cpumask
-#define topology_thread_cpumask(cpu)		cpumask_of(cpu)
+#ifndef topology_sibling_cpumask
+#define topology_sibling_cpumask(cpu)		cpumask_of(cpu)
 #endif
 #ifndef topology_core_cpumask
 #define topology_core_cpumask(cpu)		cpumask_of(cpu)
@@ -201,7 +201,7 @@ static inline int cpu_to_mem(int cpu)
 #ifdef CONFIG_SCHED_SMT
 static inline const struct cpumask *cpu_smt_mask(int cpu)
 {
-	return topology_thread_cpumask(cpu);
+	return topology_sibling_cpumask(cpu);
 }
 #endif
 
lib/cpu_rmap.c +1 -1
index 4f134d8..f610b2a 100644
@@ -191,7 +191,7 @@ int cpu_rmap_update(struct cpu_rmap *rmap, u16 index,
 	/* Update distances based on topology */
 	for_each_cpu(cpu, update_mask) {
 		if (cpu_rmap_copy_neigh(rmap, cpu,
-					topology_thread_cpumask(cpu), 1))
+					topology_sibling_cpumask(cpu), 1))
 			continue;
 		if (cpu_rmap_copy_neigh(rmap, cpu,
 					topology_core_cpumask(cpu), 2))
Signature · 1 line
2.1.4
#2 lore raw

PATCH RESEND v2 2/9 Documentation: update cputopology.txt

In reply to Bartosz Golaszewski

The documentation on cpu topology seems to be a bit out-of-date. It doesn't mention the **_siblings_list attributes and uses old names for topology_**_cpumask() macros.

Add information on missing attributes plus some additional clarifications.

---
 Documentation/cputopology.txt | 35 ++++++++++++++++++++++++++---------
 1 file changed, 26 insertions(+), 9 deletions(-)
Documentation/cputopology.txt +26 -9
index 428a961..12b1b25 100644
@@ -1,6 +1,6 @@
 
 Export CPU topology info via sysfs. Items (attributes) are similar
-to /proc/cpuinfo.
+to /proc/cpuinfo output of some architectures:
 
 1) /sys/devices/system/cpu/cpuX/topology/physical_package_id:
 
@@ -23,20 +23,35 @@ to /proc/cpuinfo.
 4) /sys/devices/system/cpu/cpuX/topology/thread_siblings:
 
 	internal kernel map of cpuX's hardware threads within the same
-	core as cpuX
+	core as cpuX.
 
-5) /sys/devices/system/cpu/cpuX/topology/core_siblings:
+5) /sys/devices/system/cpu/cpuX/topology/thread_siblings_list:
+
+	human-readable list of cpuX's hardware threads within the same
+	core as cpuX.
+
+6) /sys/devices/system/cpu/cpuX/topology/core_siblings:
 
 	internal kernel map of cpuX's hardware threads within the same
 	physical_package_id.
 
-6) /sys/devices/system/cpu/cpuX/topology/book_siblings:
+7) /sys/devices/system/cpu/cpuX/topology/core_siblings_list:
+
+	human-readable list of cpuX's hardware threads within the same
+	physical_package_id.
+
+8) /sys/devices/system/cpu/cpuX/topology/book_siblings:
 
 	internal kernel map of cpuX's hardware threads within the same
 	book_id.
 
+9) /sys/devices/system/cpu/cpuX/topology/book_siblings_list:
+
+	human-readable list of cpuX's hardware threads within the same
+	book_id.
+
 To implement it in an architecture-neutral way, a new source file,
-drivers/base/topology.c, is to export the 4 or 6 attributes. The two book
+drivers/base/topology.c, is to export the 6 or 9 attributes. The three book
 related sysfs files will only be created if CONFIG_SCHED_BOOK is selected.
 
 For an architecture to support this feature, it must define some of
@@ -48,16 +63,18 @@ these macros in include/asm-XXX/topology.h:
 #define topology_core_cpumask(cpu)
 #define topology_book_cpumask(cpu)
 
-The type of **_id is int.
-The type of siblings is (const) struct cpumask *.
+The type of **_id macros is int.
+The type of **_cpumask macros is (const) struct cpumask *. The latter
+correspond with appropriate **_siblings sysfs attributes (except for
+topology_sibling_cpumask() which corresponds with thread_siblings).
 
 To be consistent on all architectures, include/linux/topology.h
 provides default definitions for any of the above macros that are
 not defined by include/asm-XXX/topology.h:
 1) physical_package_id: -1
 2) core_id: 0
-3) thread_siblings: just the given CPU
-4) core_siblings: just the given CPU
+3) sibling_cpumask: just the given CPU
+4) core_cpumask: just the given CPU
 
 For architectures that don't support books (CONFIG_SCHED_BOOK) there are no
 default definitions for topology_book_id() and topology_book_cpumask().
Signature · 1 line
2.1.4
#3 lore raw

PATCH RESEND v2 3/9 coretemp: replace cpu_sibling_mask() with topology_sibling_cpumask()

In reply to Bartosz Golaszewski

The former duplicates the functionality of the latter but is neither documented nor arch-independent.

---
 drivers/hwmon/coretemp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/hwmon/coretemp.c +2 -1
index ed303ba..3e03379 100644
@@ -63,7 +63,8 @@ MODULE_PARM_DESC(tjmax, "TjMax value in degrees Celsius");
 #define TO_ATTR_NO(cpu)		(TO_CORE_ID(cpu) + BASE_SYSFS_ATTR_NO)
 
 #ifdef CONFIG_SMP
-#define for_each_sibling(i, cpu)	for_each_cpu(i, cpu_sibling_mask(cpu))
+#define for_each_sibling(i, cpu) \
+	for_each_cpu(i, topology_sibling_cpumask(cpu))
 #else
 #define for_each_sibling(i, cpu)	for (i = 0; false; )
 #endif
Signature · 1 line
2.1.4
#4 lore raw

PATCH RESEND v2 4/9 powernow-k8: replace cpu_core_mask() with topology_core_cpumask()

In reply to Bartosz Golaszewski

The former duplicates the functionality of the latter but is neither documented nor arch-independent.

---
 drivers/cpufreq/powernow-k8.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)
drivers/cpufreq/powernow-k8.c +3 -10
index f9ce7e4..5c035d0 100644
@@ -57,13 +57,6 @@ static DEFINE_PER_CPU(struct powernow_k8_data *, powernow_data);
 
 static struct cpufreq_driver cpufreq_amd64_driver;
 
-#ifndef CONFIG_SMP
-static inline const struct cpumask *cpu_core_mask(int cpu)
-{
-	return cpumask_of(0);
-}
-#endif
-
 /* Return a frequency in MHz, given an input fid */
 static u32 find_freq_from_fid(u32 fid)
 {
@@ -620,7 +613,7 @@ static int fill_powernow_table(struct powernow_k8_data *data,
 
 	pr_debug("cfid 0x%x, cvid 0x%x\n", data->currfid, data->currvid);
 	data->powernow_table = powernow_table;
-	if (cpumask_first(cpu_core_mask(data->cpu)) == data->cpu)
+	if (cpumask_first(topology_core_cpumask(data->cpu)) == data->cpu)
 		print_basics(data);
 
 	for (j = 0; j < data->numps; j++)
@@ -784,7 +777,7 @@ static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data)
 		CPUFREQ_TABLE_END;
 	data->powernow_table = powernow_table;
 
-	if (cpumask_first(cpu_core_mask(data->cpu)) == data->cpu)
+	if (cpumask_first(topology_core_cpumask(data->cpu)) == data->cpu)
 		print_basics(data);
 
 	/* notify BIOS that we exist */
@@ -1090,7 +1083,7 @@ static int powernowk8_cpu_init(struct cpufreq_policy *pol)
 	if (rc != 0)
 		goto err_out_exit_acpi;
 
-	cpumask_copy(pol->cpus, cpu_core_mask(pol->cpu));
+	cpumask_copy(pol->cpus, topology_core_cpumask(pol->cpu));
 	data->available_cores = pol->cpus;
 
 	/* min/max the cpu is capable of */
Signature · 1 line
2.1.4
#5 lore raw

PATCH RESEND v2 5/9 p4-clockmod: replace cpu_sibling_mask() with topology_sibling_cpumask()

In reply to Bartosz Golaszewski

The former duplicates the functionality of the latter but is neither documented nor arch-independent.

---
 drivers/cpufreq/p4-clockmod.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/p4-clockmod.c +1 -1
index 529cfd9..5dd95da 100644
@@ -172,7 +172,7 @@ static int cpufreq_p4_cpu_init(struct cpufreq_policy *policy)
 	unsigned int i;
 
 #ifdef CONFIG_SMP
-	cpumask_copy(policy->cpus, cpu_sibling_mask(policy->cpu));
+	cpumask_copy(policy->cpus, topology_sibling_cpumask(policy->cpu));
 #endif
 
 	/* Errata workaround */
Signature · 1 line
2.1.4
#6 lore raw

PATCH RESEND v2 6/9 acpi-cpufreq: replace cpu_**_mask() with topology_**_cpumask()

In reply to Bartosz Golaszewski

The former duplicate the functionalities of the latter but are neither documented nor arch-independent.

---
 drivers/cpufreq/acpi-cpufreq.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/cpufreq/acpi-cpufreq.c +3 -2
index b0c18ed..0136dfc 100644
@@ -699,13 +699,14 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
 	dmi_check_system(sw_any_bug_dmi_table);
 	if (bios_with_sw_any_bug && !policy_is_shared(policy)) {
 		policy->shared_type = CPUFREQ_SHARED_TYPE_ALL;
-		cpumask_copy(policy->cpus, cpu_core_mask(cpu));
+		cpumask_copy(policy->cpus, topology_core_cpumask(cpu));
 	}
 
 	if (check_amd_hwpstate_cpu(cpu) && !acpi_pstate_strict) {
 		cpumask_clear(policy->cpus);
 		cpumask_set_cpu(cpu, policy->cpus);
-		cpumask_copy(data->freqdomain_cpus, cpu_sibling_mask(cpu));
+		cpumask_copy(data->freqdomain_cpus,
+			     topology_sibling_cpumask(cpu));
 		policy->shared_type = CPUFREQ_SHARED_TYPE_HW;
 		pr_info_once(PFX "overriding BIOS provided _PSD data\n");
 	}
Signature · 1 line
2.1.4
#7 lore raw

PATCH RESEND v2 7/9 speedstep-ich: replace cpu_sibling_mask() with topology_sibling_cpumask()

In reply to Bartosz Golaszewski

The former duplicates the functionality of the latter but is neither documented nor arch-independent.

---
 drivers/cpufreq/speedstep-ich.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/speedstep-ich.c +1 -1
index e56d632..37555c6 100644
@@ -292,7 +292,7 @@ static int speedstep_cpu_init(struct cpufreq_policy *policy)
 
 	/* only run on CPU to be set, or on its sibling */
 #ifdef CONFIG_SMP
-	cpumask_copy(policy->cpus, cpu_sibling_mask(policy->cpu));
+	cpumask_copy(policy->cpus, topology_sibling_cpumask(policy->cpu));
 #endif
 	policy_cpu = cpumask_any_and(policy->cpus, cpu_online_mask);
 
Signature · 1 line
2.1.4
#8 lore raw

PATCH RESEND v2 8/9 x86: replace cpu_**_mask() with topology_**_cpumask()

In reply to Bartosz Golaszewski

The former duplicate the functionalities of the latter but are neither documented nor arch-independent.

---
 arch/x86/kernel/cpu/proc.c |  3 ++-
 arch/x86/kernel/smpboot.c  | 42 ++++++++++++++++++++++--------------------
 arch/x86/kernel/tsc_sync.c |  2 +-
 3 files changed, 25 insertions(+), 22 deletions(-)
arch/x86/kernel/cpu/proc.c +2 -1
index e7d8c76..18ca99f 100644
@@ -12,7 +12,8 @@ static void show_cpuinfo_core(struct seq_file *m, struct cpuinfo_x86 *c,
 {
 #ifdef CONFIG_SMP
 	seq_printf(m, "physical id\t: %d\n", c->phys_proc_id);
-	seq_printf(m, "siblings\t: %d\n", cpumask_weight(cpu_core_mask(cpu)));
+	seq_printf(m, "siblings\t: %d\n",
+		   cpumask_weight(topology_core_cpumask(cpu)));
 	seq_printf(m, "core id\t\t: %d\n", c->cpu_core_id);
 	seq_printf(m, "cpu cores\t: %d\n", c->booted_cores);
 	seq_printf(m, "apicid\t\t: %d\n", c->apicid);
arch/x86/kernel/smpboot.c +22 -20

103 lines not on this page · raw message

arch/x86/kernel/tsc_sync.c +1 -1
index 2648848..dd8d079 100644
@@ -113,7 +113,7 @@ static void check_tsc_warp(unsigned int timeout)
  */
 static inline unsigned int loop_timeout(int cpu)
 {
-	return (cpumask_weight(cpu_core_mask(cpu)) > 1) ? 2 : 20;
+	return (cpumask_weight(topology_core_cpumask(cpu)) > 1) ? 2 : 20;
 }
 
 /*
Signature · 1 line
2.1.4
#9 lore raw

PATCH RESEND v2 9/9 x86: remove cpu_sibling_mask() and cpu_core_mask()

In reply to Bartosz Golaszewski

These functions are arch-specific and duplicate the functionality of macros defined in linux/include/topology.h.

Remove them as all the callers in x86 have now switched to using the topology_**_cpumask() family.

---
 arch/x86/include/asm/smp.h | 10 ----------
 1 file changed, 10 deletions(-)
arch/x86/include/asm/smp.h +0 -10
index 17a8dce..222a6a3 100644
@@ -37,16 +37,6 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
 DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
 
-static inline struct cpumask *cpu_sibling_mask(int cpu)
-{
-	return per_cpu(cpu_sibling_map, cpu);
-}
-
-static inline struct cpumask *cpu_core_mask(int cpu)
-{
-	return per_cpu(cpu_core_map, cpu);
-}
-
 static inline struct cpumask *cpu_llc_shared_mask(int cpu)
 {
 	return per_cpu(cpu_llc_shared_map, cpu);
Signature · 1 line
2.1.4
#10 lore raw
In reply to Bartosz Golaszewski
Quoted 58 lines · Bartosz Golaszewski

Two functions defined in asm/smp.h: cpu_sibling_mask() and cpu_core_mask(), have the same functionality as macros defined in linux/topology.h:
topology_thread_cpumask() and topology_core_cpumask() respectively.

They are not documented and are architecture specific. Also: different naming for the same functionality (in case of cpu_sibling_mask() and topology_thread_cpumask()) is a bit misleading.

This series makes all the callers switch to using the topology.h macros and removes their smp.h counterparts. While we're at it: rename topology_thread_cpumask() to topology_sibling_cpumask() to be consistent with the term used in the scheduler.

The same duplication exists on powerpc.

NOTE: patch 2/9 had been already submitted separately but didn't receive any attention, so I'm attaching it to this series.

v2:
- renamed topology_thread_cpumask() to topology_sibling_cpumask()
- updated Documentation/cputopology.txt

v1:
https://lkml.org/lkml/2015/4/30/188

Bartosz Golaszewski (9):
topology: rename topology_thread_cpumask()
Documentation: update cputopology.txt
coretemp: replace cpu_sibling_mask() with topology_sibling_cpumask()
powernow-k8: replace cpu_core_mask() with topology_core_cpumask()
p4-clockmod: replace cpu_sibling_mask() with topology_sibling_cpumask()
acpi-cpufreq: replace cpu_**_mask() with topology_**_cpumask()
speedstep-ich: replace cpu_sibling_mask() with topology_sibling_cpumask()
x86: replace cpu_**_mask() with topology_**_cpumask()
x86: remove cpu_sibling_mask() and cpu_core_mask()

 Documentation/cputopology.txt                      | 37 +++++++++++++------
 arch/arm/include/asm/topology.h                    |  2 +-
 arch/arm64/include/asm/topology.h                  |  2 +-
 arch/ia64/include/asm/topology.h                   |  2 +-
 arch/mips/include/asm/topology.h                   |  2 +-
 arch/powerpc/include/asm/topology.h                |  2 +-
 arch/powerpc/mm/tlb_nohash.c                       |  2 +-
 arch/s390/include/asm/topology.h                   |  3 +-
 arch/sparc/include/asm/topology_64.h               |  2 +-
 arch/tile/include/asm/topology.h                   |  2 +-
 arch/x86/include/asm/smp.h                         | 10 ------
 arch/x86/include/asm/topology.h                    |  2 +-
 arch/x86/kernel/cpu/perf_event_intel.c             |  6 ++--
 arch/x86/kernel/cpu/proc.c                         |  3 +-
 arch/x86/kernel/smpboot.c                          | 42 +++++++++++-----------
 arch/x86/kernel/tsc_sync.c                         |  2 +-
 block/blk-mq-cpumap.c                              |  2 +-
 drivers/acpi/acpi_pad.c                            |  2 +-
 drivers/base/topology.c                            |  2 +-
 drivers/cpufreq/acpi-cpufreq.c                     |  5 +--
 drivers/cpufreq/p4-clockmod.c                      |  2 +-
 drivers/cpufreq/powernow-k8.c                      | 13 ++-----
Quoted 8 lines
 drivers/cpufreq/speedstep-ich.c                    |  2 +-
 drivers/hwmon/coretemp.c                           |  3 +-
 drivers/net/ethernet/sfc/efx.c                     |  2 +-
 .../staging/lustre/lustre/libcfs/linux/linux-cpu.c |  2 +-
 drivers/staging/lustre/lustre/ptlrpc/service.c     |  4 +--
 include/linux/topology.h                           |  6 ++--
 lib/cpu_rmap.c                                     |  2 +-
 29 files changed, 87 insertions(+), 81 deletions(-)

Please feel free to add an ACK from me to the cpufreq-related ones.

Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
#11 lore raw
In reply to Bartosz Golaszewski
Quoted 13 lines · Bartosz Golaszewski

Two functions defined in asm/smp.h: cpu_sibling_mask() and cpu_core_mask(), have the same functionality as macros defined in linux/topology.h:
topology_thread_cpumask() and topology_core_cpumask() respectively.

They are not documented and are architecture specific. Also: different naming for the same functionality (in case of cpu_sibling_mask() and topology_thread_cpumask()) is a bit misleading.

This series makes all the callers switch to using the topology.h macros and removes their smp.h counterparts. While we're at it: rename topology_thread_cpumask() to topology_sibling_cpumask() to be consistent with the term used in the scheduler.

Quoted 4 lines

The same duplication exists on powerpc.

NOTE: patch 2/9 had been already submitted separately but didn't receive any attention, so I'm attaching it to this series.

As this touches the world and some more, I think it should go through Andrews mm tree.

Andrew, can you please pick that up?

For the x86 parts: Reviewed-by: Thomas Gleixner <[email protected]>

Thanks,

tglx

#12 lore raw

2015-05-19 15:17 GMT+02:00 Thomas Gleixner <[email protected]>:

Quoted 5 lines

As this touches the world and some more, I think it should go through Andrews mm tree.

Andrew, can you please pick that up?

I've re-sent the series including Andrew in CC as there was no confirmation of the patches having been merged.

Best regards,
Bartosz Golaszewski