]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
s390/cpufeature: Convert MACHINE_HAS_TOPOLOGY to cpu_has_topology()
authorHeiko Carstens <hca@linux.ibm.com>
Fri, 7 Feb 2025 14:48:52 +0000 (15:48 +0100)
committerVasily Gorbik <gor@linux.ibm.com>
Tue, 4 Mar 2025 16:18:05 +0000 (17:18 +0100)
Convert MACHINE_HAS_... to cpu_has_...() which uses test_facility() instead
of testing the machine_flags lowcore member if the feature is present.

test_facility() generates better code since it results in a static branch
without accessing memory. The branch is patched via alternatives by the
decompressor depending on the availability of the required facility.

Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
arch/s390/include/asm/cpufeature.h
arch/s390/include/asm/setup.h
arch/s390/kernel/early.c
arch/s390/kernel/hiperdispatch.c
arch/s390/kernel/sysinfo.c
arch/s390/kernel/topology.c

index 6ba487a7c84233d938bc40322fdf2eb3625d55d5..5c7c535a3b5bcae07c6b23f505de46dfcf2f3cca 100644 (file)
@@ -27,5 +27,6 @@ int cpu_have_feature(unsigned int nr);
 #define cpu_has_rdp()          test_facility(194)
 #define cpu_has_seq_insn()     test_facility(85)
 #define cpu_has_tlb_lc()       test_facility(51)
+#define cpu_has_topology()     test_facility(11)
 
 #endif /* __ASM_S390_CPUFEATURE_H */
index b117f3a4b4c23fb391f912a1473cd2865d54a68e..25f4d5b6e23bb7032c08efacdcc5e4f5d9d54fdf 100644 (file)
@@ -25,7 +25,6 @@
 #define MACHINE_FLAG_IDTE      BIT(5)
 #define MACHINE_FLAG_EDAT1     BIT(7)
 #define MACHINE_FLAG_EDAT2     BIT(8)
-#define MACHINE_FLAG_TOPOLOGY  BIT(10)
 #define MACHINE_FLAG_TE                BIT(11)
 #define MACHINE_FLAG_TLB_GUEST BIT(14)
 #define MACHINE_FLAG_SCC       BIT(17)
@@ -82,7 +81,6 @@ extern unsigned long mio_wb_bit_mask;
 #define MACHINE_HAS_IDTE       (get_lowcore()->machine_flags & MACHINE_FLAG_IDTE)
 #define MACHINE_HAS_EDAT1      (get_lowcore()->machine_flags & MACHINE_FLAG_EDAT1)
 #define MACHINE_HAS_EDAT2      (get_lowcore()->machine_flags & MACHINE_FLAG_EDAT2)
-#define MACHINE_HAS_TOPOLOGY   (get_lowcore()->machine_flags & MACHINE_FLAG_TOPOLOGY)
 #define MACHINE_HAS_TE         (get_lowcore()->machine_flags & MACHINE_FLAG_TE)
 #define MACHINE_HAS_TLB_GUEST  (get_lowcore()->machine_flags & MACHINE_FLAG_TLB_GUEST)
 #define MACHINE_HAS_SCC                (get_lowcore()->machine_flags & MACHINE_FLAG_SCC)
index 1f22dd8094ecef8fec09dc4600e68ac6726e9b03..68685aa23c16e9268e28ef27537f453cc0b10abd 100644 (file)
@@ -8,6 +8,7 @@
 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
 
 #include <linux/sched/debug.h>
+#include <linux/cpufeature.h>
 #include <linux/compiler.h>
 #include <linux/init.h>
 #include <linux/errno.h>
@@ -167,9 +168,8 @@ static __init void setup_topology(void)
 {
        int max_mnest;
 
-       if (!test_facility(11))
+       if (!cpu_has_topology())
                return;
-       get_lowcore()->machine_flags |= MACHINE_FLAG_TOPOLOGY;
        for (max_mnest = 6; max_mnest > 1; max_mnest--) {
                if (stsi(&sysinfo_page, 15, 1, max_mnest) == 0)
                        break;
index 7857a7e8e56cb3a85fbad042b2f9ef9ab8b7d0a4..e7b66d046e8d3882bcf1418d9aeb7a7653102c06 100644 (file)
@@ -45,6 +45,7 @@
  * therefore delaying the throughput loss caused by using SMP threads.
  */
 
+#include <linux/cpufeature.h>
 #include <linux/cpumask.h>
 #include <linux/debugfs.h>
 #include <linux/device.h>
@@ -87,7 +88,7 @@ static DECLARE_DELAYED_WORK(hd_capacity_work, hd_capacity_work_fn);
 
 static int hd_set_hiperdispatch_mode(int enable)
 {
-       if (!MACHINE_HAS_TOPOLOGY)
+       if (!cpu_has_topology())
                enable = 0;
        if (hd_enabled == enable)
                return 0;
index 88055f58fbdab58740dfdb869dae511ed3daef26..a74154c6529eb2040185f5db069605e722b4cd60 100644 (file)
@@ -5,6 +5,7 @@
  *            Martin Schwidefsky <schwidefsky@de.ibm.com>,
  */
 
+#include <linux/cpufeature.h>
 #include <linux/debugfs.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
@@ -154,7 +155,7 @@ static void stsi_15_1_x(struct seq_file *m, struct sysinfo_15_1_x *info)
        int i;
 
        seq_putc(m, '\n');
-       if (!MACHINE_HAS_TOPOLOGY)
+       if (!cpu_has_topology())
                return;
        if (stsi(info, 15, 1, topology_max_mnest))
                return;
@@ -559,7 +560,7 @@ static __init int stsi_init_debugfs(void)
                sf = &stsi_file[i];
                debugfs_create_file(sf->name, 0400, stsi_root, NULL, sf->fops);
        }
-       if (IS_ENABLED(CONFIG_SCHED_TOPOLOGY) && MACHINE_HAS_TOPOLOGY) {
+       if (IS_ENABLED(CONFIG_SCHED_TOPOLOGY) && cpu_has_topology()) {
                char link_to[10];
 
                sprintf(link_to, "15_1_%d", topology_mnest_limit());
index 211cc8382e4a953954a40ff7c485ea76e7e5cf43..3df048e190b11436b215d9e376f0b011e7ff315c 100644 (file)
@@ -6,6 +6,7 @@
 #define KMSG_COMPONENT "cpu"
 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
 
+#include <linux/cpufeature.h>
 #include <linux/workqueue.h>
 #include <linux/memblock.h>
 #include <linux/uaccess.h>
@@ -240,7 +241,7 @@ int topology_set_cpu_management(int fc)
 {
        int cpu, rc;
 
-       if (!MACHINE_HAS_TOPOLOGY)
+       if (!cpu_has_topology())
                return -EOPNOTSUPP;
        if (fc)
                rc = ptf(PTF_VERTICAL);
@@ -315,13 +316,13 @@ static int __arch_update_cpu_topology(void)
        hd_status = 0;
        rc = 0;
        mutex_lock(&smp_cpu_state_mutex);
-       if (MACHINE_HAS_TOPOLOGY) {
+       if (cpu_has_topology()) {
                rc = 1;
                store_topology(info);
                tl_to_masks(info);
        }
        update_cpu_masks();
-       if (!MACHINE_HAS_TOPOLOGY)
+       if (!cpu_has_topology())
                topology_update_polarization_simple();
        if (cpu_management == 1)
                hd_status = hd_enable_hiperdispatch();
@@ -376,7 +377,7 @@ static void set_topology_timer(void)
 
 void topology_expect_change(void)
 {
-       if (!MACHINE_HAS_TOPOLOGY)
+       if (!cpu_has_topology())
                return;
        /* This is racy, but it doesn't matter since it is just a heuristic.
         * Worst case is that we poll in a higher frequency for a bit longer.
@@ -500,7 +501,7 @@ int topology_cpu_init(struct cpu *cpu)
        int rc;
 
        rc = sysfs_create_group(&cpu->dev.kobj, &topology_cpu_attr_group);
-       if (rc || !MACHINE_HAS_TOPOLOGY)
+       if (rc || !cpu_has_topology())
                return rc;
        rc = sysfs_create_group(&cpu->dev.kobj, &topology_extra_cpu_attr_group);
        if (rc)
@@ -569,12 +570,12 @@ void __init topology_init_early(void)
 
        set_sched_topology(s390_topology);
        if (topology_mode == TOPOLOGY_MODE_UNINITIALIZED) {
-               if (MACHINE_HAS_TOPOLOGY)
+               if (cpu_has_topology())
                        topology_mode = TOPOLOGY_MODE_HW;
                else
                        topology_mode = TOPOLOGY_MODE_SINGLE;
        }
-       if (!MACHINE_HAS_TOPOLOGY)
+       if (!cpu_has_topology())
                goto out;
        tl_info = memblock_alloc_or_panic(PAGE_SIZE, PAGE_SIZE);
        info = tl_info;
@@ -596,7 +597,7 @@ static inline int topology_get_mode(int enabled)
 {
        if (!enabled)
                return TOPOLOGY_MODE_SINGLE;
-       return MACHINE_HAS_TOPOLOGY ? TOPOLOGY_MODE_HW : TOPOLOGY_MODE_PACKAGE;
+       return cpu_has_topology() ? TOPOLOGY_MODE_HW : TOPOLOGY_MODE_PACKAGE;
 }
 
 static inline int topology_is_enabled(void)
@@ -686,7 +687,7 @@ static int __init topology_init(void)
        int rc = 0;
 
        timer_setup(&topology_timer, topology_timer_fn, TIMER_DEFERRABLE);
-       if (MACHINE_HAS_TOPOLOGY)
+       if (cpu_has_topology())
                set_topology_timer();
        else
                topology_update_polarization_simple();