2022-10-09 02:18:37

by Tiezhu Yang

[permalink] [raw]
Subject: [PATCH v2] LoongArch: Do not create sysfs control file for io master CPUs

Now io master CPUs are not hotpluggable on LoongArch, in the current code,
only /sys/devices/system/cpu/cpu0/online is not created, let us set the
hotpluggable field of all the io master CPUs as 0, then prevent to create
sysfs control file for the other io master CPUs which confuses some user
space tools. This is similar with commit 9cce844abf07 ("MIPS: CPU#0 is not
hotpluggable").

Signed-off-by: Tiezhu Yang <[email protected]>
---
arch/loongarch/include/asm/bootinfo.h | 5 +++++
arch/loongarch/kernel/smp.c | 5 -----
arch/loongarch/kernel/topology.c | 3 ++-
3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/arch/loongarch/include/asm/bootinfo.h b/arch/loongarch/include/asm/bootinfo.h
index 8e5881b..ed0910e 100644
--- a/arch/loongarch/include/asm/bootinfo.h
+++ b/arch/loongarch/include/asm/bootinfo.h
@@ -40,4 +40,9 @@ extern unsigned long fw_arg0, fw_arg1, fw_arg2;
extern struct loongson_board_info b_info;
extern struct loongson_system_configuration loongson_sysconf;

+static inline bool io_master(int cpu)
+{
+ return test_bit(cpu, &loongson_sysconf.cores_io_master);
+}
+
#endif /* _ASM_BOOTINFO_H */
diff --git a/arch/loongarch/kernel/smp.c b/arch/loongarch/kernel/smp.c
index b5fab30..781a4d4 100644
--- a/arch/loongarch/kernel/smp.c
+++ b/arch/loongarch/kernel/smp.c
@@ -240,11 +240,6 @@ void loongson3_smp_finish(void)

#ifdef CONFIG_HOTPLUG_CPU

-static bool io_master(int cpu)
-{
- return test_bit(cpu, &loongson_sysconf.cores_io_master);
-}
-
int loongson3_cpu_disable(void)
{
unsigned long flags;
diff --git a/arch/loongarch/kernel/topology.c b/arch/loongarch/kernel/topology.c
index ab1a75c..caa7cd8 100644
--- a/arch/loongarch/kernel/topology.c
+++ b/arch/loongarch/kernel/topology.c
@@ -5,6 +5,7 @@
#include <linux/node.h>
#include <linux/nodemask.h>
#include <linux/percpu.h>
+#include <asm/bootinfo.h>

static DEFINE_PER_CPU(struct cpu, cpu_devices);

@@ -40,7 +41,7 @@ static int __init topology_init(void)
for_each_present_cpu(i) {
struct cpu *c = &per_cpu(cpu_devices, i);

- c->hotpluggable = !!i;
+ c->hotpluggable = !io_master(i);
ret = register_cpu(c, i);
if (ret < 0)
pr_warn("topology_init: register_cpu %d failed (%d)\n", i, ret);
--
2.1.0


2022-10-09 06:46:26

by Huacai Chen

[permalink] [raw]
Subject: Re: [PATCH v2] LoongArch: Do not create sysfs control file for io master CPUs

Queued for loongarch-next, thanks.

Huacai

On Sun, Oct 9, 2022 at 9:23 AM Tiezhu Yang <[email protected]> wrote:
>
> Now io master CPUs are not hotpluggable on LoongArch, in the current code,
> only /sys/devices/system/cpu/cpu0/online is not created, let us set the
> hotpluggable field of all the io master CPUs as 0, then prevent to create
> sysfs control file for the other io master CPUs which confuses some user
> space tools. This is similar with commit 9cce844abf07 ("MIPS: CPU#0 is not
> hotpluggable").
>
> Signed-off-by: Tiezhu Yang <[email protected]>
> ---
> arch/loongarch/include/asm/bootinfo.h | 5 +++++
> arch/loongarch/kernel/smp.c | 5 -----
> arch/loongarch/kernel/topology.c | 3 ++-
> 3 files changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/arch/loongarch/include/asm/bootinfo.h b/arch/loongarch/include/asm/bootinfo.h
> index 8e5881b..ed0910e 100644
> --- a/arch/loongarch/include/asm/bootinfo.h
> +++ b/arch/loongarch/include/asm/bootinfo.h
> @@ -40,4 +40,9 @@ extern unsigned long fw_arg0, fw_arg1, fw_arg2;
> extern struct loongson_board_info b_info;
> extern struct loongson_system_configuration loongson_sysconf;
>
> +static inline bool io_master(int cpu)
> +{
> + return test_bit(cpu, &loongson_sysconf.cores_io_master);
> +}
> +
> #endif /* _ASM_BOOTINFO_H */
> diff --git a/arch/loongarch/kernel/smp.c b/arch/loongarch/kernel/smp.c
> index b5fab30..781a4d4 100644
> --- a/arch/loongarch/kernel/smp.c
> +++ b/arch/loongarch/kernel/smp.c
> @@ -240,11 +240,6 @@ void loongson3_smp_finish(void)
>
> #ifdef CONFIG_HOTPLUG_CPU
>
> -static bool io_master(int cpu)
> -{
> - return test_bit(cpu, &loongson_sysconf.cores_io_master);
> -}
> -
> int loongson3_cpu_disable(void)
> {
> unsigned long flags;
> diff --git a/arch/loongarch/kernel/topology.c b/arch/loongarch/kernel/topology.c
> index ab1a75c..caa7cd8 100644
> --- a/arch/loongarch/kernel/topology.c
> +++ b/arch/loongarch/kernel/topology.c
> @@ -5,6 +5,7 @@
> #include <linux/node.h>
> #include <linux/nodemask.h>
> #include <linux/percpu.h>
> +#include <asm/bootinfo.h>
>
> static DEFINE_PER_CPU(struct cpu, cpu_devices);
>
> @@ -40,7 +41,7 @@ static int __init topology_init(void)
> for_each_present_cpu(i) {
> struct cpu *c = &per_cpu(cpu_devices, i);
>
> - c->hotpluggable = !!i;
> + c->hotpluggable = !io_master(i);
> ret = register_cpu(c, i);
> if (ret < 0)
> pr_warn("topology_init: register_cpu %d failed (%d)\n", i, ret);
> --
> 2.1.0
>