All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] LoongArch: Let cores_io_master cover the largest NR_CPUS
@ 2023-12-25  7:00 Huacai Chen
  2023-12-25  9:13 ` maobibo
  0 siblings, 1 reply; 6+ messages in thread
From: Huacai Chen @ 2023-12-25  7:00 UTC (permalink / raw
  To: Huacai Chen
  Cc: loongarch, Xuefeng Li, Guo Ren, Xuerui Wang, Jiaxun Yang,
	linux-kernel, loongson-kernel, Huacai Chen

Now loongson_system_configuration::cores_io_master only covers 64 cpus,
if NR_CPUS > 64 there will be memory corruption. So let cores_io_master
cover the largest NR_CPUS (256).

Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
---
 arch/loongarch/include/asm/bootinfo.h | 4 ++--
 arch/loongarch/kernel/acpi.c          | 2 +-
 arch/loongarch/kernel/smp.c           | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/loongarch/include/asm/bootinfo.h b/arch/loongarch/include/asm/bootinfo.h
index c60796869b2b..32fd0319594a 100644
--- a/arch/loongarch/include/asm/bootinfo.h
+++ b/arch/loongarch/include/asm/bootinfo.h
@@ -30,7 +30,7 @@ struct loongson_system_configuration {
 	int boot_cpu_id;
 	int cores_per_node;
 	int cores_per_package;
-	unsigned long cores_io_master;
+	unsigned long cores_io_master[4];
 	unsigned long suspend_addr;
 	const char *cpuname;
 };
@@ -42,7 +42,7 @@ extern struct loongson_system_configuration loongson_sysconf;
 
 static inline bool io_master(int cpu)
 {
-	return test_bit(cpu, &loongson_sysconf.cores_io_master);
+	return test_bit(cpu, loongson_sysconf.cores_io_master);
 }
 
 #endif /* _ASM_BOOTINFO_H */
diff --git a/arch/loongarch/kernel/acpi.c b/arch/loongarch/kernel/acpi.c
index 8e00a754e548..b6b097bbf866 100644
--- a/arch/loongarch/kernel/acpi.c
+++ b/arch/loongarch/kernel/acpi.c
@@ -119,7 +119,7 @@ acpi_parse_eio_master(union acpi_subtable_headers *header, const unsigned long e
 		return -EINVAL;
 
 	core = eiointc->node * CORES_PER_EIO_NODE;
-	set_bit(core, &(loongson_sysconf.cores_io_master));
+	set_bit(core, loongson_sysconf.cores_io_master);
 
 	return 0;
 }
diff --git a/arch/loongarch/kernel/smp.c b/arch/loongarch/kernel/smp.c
index 9e33b5e36122..a16e3dbe9f09 100644
--- a/arch/loongarch/kernel/smp.c
+++ b/arch/loongarch/kernel/smp.c
@@ -208,7 +208,7 @@ static void __init fdt_smp_setup(void)
 	}
 
 	loongson_sysconf.nr_cpus = num_processors;
-	set_bit(0, &(loongson_sysconf.cores_io_master));
+	set_bit(0, loongson_sysconf.cores_io_master);
 #endif
 }
 
-- 
2.39.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] LoongArch: Let cores_io_master cover the largest NR_CPUS
  2023-12-25  7:00 [PATCH] LoongArch: Let cores_io_master cover the largest NR_CPUS Huacai Chen
@ 2023-12-25  9:13 ` maobibo
  2023-12-25  9:19   ` Huacai Chen
  0 siblings, 1 reply; 6+ messages in thread
From: maobibo @ 2023-12-25  9:13 UTC (permalink / raw
  To: loongson-kernel, Huacai Chen
  Cc: loongarch, Xuefeng Li, Guo Ren, Xuerui Wang, Jiaxun Yang,
	linux-kernel, Huacai Chen



On 2023/12/25 下午3:00, Huacai Chen wrote:
> Now loongson_system_configuration::cores_io_master only covers 64 cpus,
> if NR_CPUS > 64 there will be memory corruption. So let cores_io_master
> cover the largest NR_CPUS (256).
> 
> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
> ---
>   arch/loongarch/include/asm/bootinfo.h | 4 ++--
>   arch/loongarch/kernel/acpi.c          | 2 +-
>   arch/loongarch/kernel/smp.c           | 2 +-
>   3 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/loongarch/include/asm/bootinfo.h b/arch/loongarch/include/asm/bootinfo.h
> index c60796869b2b..32fd0319594a 100644
> --- a/arch/loongarch/include/asm/bootinfo.h
> +++ b/arch/loongarch/include/asm/bootinfo.h
> @@ -30,7 +30,7 @@ struct loongson_system_configuration {
>   	int boot_cpu_id;
>   	int cores_per_node;
>   	int cores_per_package;
> -	unsigned long cores_io_master;
> +	unsigned long cores_io_master[4];
Can the hardcoded 4 be defined something like this?
    DIV_ROUND_UP(CONFIG_NR_CPUS, sizeof(long))

the others LGTM.

Regards
Bibo Mao
>   	unsigned long suspend_addr;
>   	const char *cpuname;
>   };
> @@ -42,7 +42,7 @@ extern struct loongson_system_configuration loongson_sysconf;
>   
>   static inline bool io_master(int cpu)
>   {
> -	return test_bit(cpu, &loongson_sysconf.cores_io_master);
> +	return test_bit(cpu, loongson_sysconf.cores_io_master);
>   }
>   
>   #endif /* _ASM_BOOTINFO_H */
> diff --git a/arch/loongarch/kernel/acpi.c b/arch/loongarch/kernel/acpi.c
> index 8e00a754e548..b6b097bbf866 100644
> --- a/arch/loongarch/kernel/acpi.c
> +++ b/arch/loongarch/kernel/acpi.c
> @@ -119,7 +119,7 @@ acpi_parse_eio_master(union acpi_subtable_headers *header, const unsigned long e
>   		return -EINVAL;
>   
>   	core = eiointc->node * CORES_PER_EIO_NODE;
> -	set_bit(core, &(loongson_sysconf.cores_io_master));
> +	set_bit(core, loongson_sysconf.cores_io_master);
>   
>   	return 0;
>   }
> diff --git a/arch/loongarch/kernel/smp.c b/arch/loongarch/kernel/smp.c
> index 9e33b5e36122..a16e3dbe9f09 100644
> --- a/arch/loongarch/kernel/smp.c
> +++ b/arch/loongarch/kernel/smp.c
> @@ -208,7 +208,7 @@ static void __init fdt_smp_setup(void)
>   	}
>   
>   	loongson_sysconf.nr_cpus = num_processors;
> -	set_bit(0, &(loongson_sysconf.cores_io_master));
> +	set_bit(0, loongson_sysconf.cores_io_master);
>   #endif
>   }
>   
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] LoongArch: Let cores_io_master cover the largest NR_CPUS
  2023-12-25  9:13 ` maobibo
@ 2023-12-25  9:19   ` Huacai Chen
  2023-12-25 11:11     ` Xi Ruoyao
  2023-12-25 14:02     ` Jiaxun Yang
  0 siblings, 2 replies; 6+ messages in thread
From: Huacai Chen @ 2023-12-25  9:19 UTC (permalink / raw
  To: maobibo
  Cc: loongson-kernel, loongarch, Xuefeng Li, Guo Ren, Xuerui Wang,
	Jiaxun Yang, linux-kernel, Huacai Chen

On Mon, Dec 25, 2023 at 5:13 PM maobibo <maobibo@loongson.cn> wrote:
>
>
>
> On 2023/12/25 下午3:00, Huacai Chen wrote:
> > Now loongson_system_configuration::cores_io_master only covers 64 cpus,
> > if NR_CPUS > 64 there will be memory corruption. So let cores_io_master
> > cover the largest NR_CPUS (256).
> >
> > Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
> > ---
> >   arch/loongarch/include/asm/bootinfo.h | 4 ++--
> >   arch/loongarch/kernel/acpi.c          | 2 +-
> >   arch/loongarch/kernel/smp.c           | 2 +-
> >   3 files changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/arch/loongarch/include/asm/bootinfo.h b/arch/loongarch/include/asm/bootinfo.h
> > index c60796869b2b..32fd0319594a 100644
> > --- a/arch/loongarch/include/asm/bootinfo.h
> > +++ b/arch/loongarch/include/asm/bootinfo.h
> > @@ -30,7 +30,7 @@ struct loongson_system_configuration {
> >       int boot_cpu_id;
> >       int cores_per_node;
> >       int cores_per_package;
> > -     unsigned long cores_io_master;
> > +     unsigned long cores_io_master[4];
> Can the hardcoded 4 be defined something like this?
>     DIV_ROUND_UP(CONFIG_NR_CPUS, sizeof(long))
Can this be used to define arrays?

Huacai

>
> the others LGTM.
>
> Regards
> Bibo Mao
> >       unsigned long suspend_addr;
> >       const char *cpuname;
> >   };
> > @@ -42,7 +42,7 @@ extern struct loongson_system_configuration loongson_sysconf;
> >
> >   static inline bool io_master(int cpu)
> >   {
> > -     return test_bit(cpu, &loongson_sysconf.cores_io_master);
> > +     return test_bit(cpu, loongson_sysconf.cores_io_master);
> >   }
> >
> >   #endif /* _ASM_BOOTINFO_H */
> > diff --git a/arch/loongarch/kernel/acpi.c b/arch/loongarch/kernel/acpi.c
> > index 8e00a754e548..b6b097bbf866 100644
> > --- a/arch/loongarch/kernel/acpi.c
> > +++ b/arch/loongarch/kernel/acpi.c
> > @@ -119,7 +119,7 @@ acpi_parse_eio_master(union acpi_subtable_headers *header, const unsigned long e
> >               return -EINVAL;
> >
> >       core = eiointc->node * CORES_PER_EIO_NODE;
> > -     set_bit(core, &(loongson_sysconf.cores_io_master));
> > +     set_bit(core, loongson_sysconf.cores_io_master);
> >
> >       return 0;
> >   }
> > diff --git a/arch/loongarch/kernel/smp.c b/arch/loongarch/kernel/smp.c
> > index 9e33b5e36122..a16e3dbe9f09 100644
> > --- a/arch/loongarch/kernel/smp.c
> > +++ b/arch/loongarch/kernel/smp.c
> > @@ -208,7 +208,7 @@ static void __init fdt_smp_setup(void)
> >       }
> >
> >       loongson_sysconf.nr_cpus = num_processors;
> > -     set_bit(0, &(loongson_sysconf.cores_io_master));
> > +     set_bit(0, loongson_sysconf.cores_io_master);
> >   #endif
> >   }
> >
> >
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] LoongArch: Let cores_io_master cover the largest NR_CPUS
  2023-12-25  9:19   ` Huacai Chen
@ 2023-12-25 11:11     ` Xi Ruoyao
  2023-12-25 14:02     ` Jiaxun Yang
  1 sibling, 0 replies; 6+ messages in thread
From: Xi Ruoyao @ 2023-12-25 11:11 UTC (permalink / raw
  To: Huacai Chen, maobibo
  Cc: loongson-kernel, loongarch, Xuefeng Li, Guo Ren, Xuerui Wang,
	Jiaxun Yang, linux-kernel, Huacai Chen

On Mon, 2023-12-25 at 17:19 +0800, Huacai Chen wrote:
> On Mon, Dec 25, 2023 at 5:13 PM maobibo <maobibo@loongson.cn> wrote:
> > 
> > 
> > 
> > On 2023/12/25 下午3:00, Huacai Chen wrote:
> > > Now loongson_system_configuration::cores_io_master only covers 64 cpus,
> > > if NR_CPUS > 64 there will be memory corruption. So let cores_io_master
> > > cover the largest NR_CPUS (256).
> > > 
> > > Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
> > > ---
> > >    arch/loongarch/include/asm/bootinfo.h | 4 ++--
> > >    arch/loongarch/kernel/acpi.c          | 2 +-
> > >    arch/loongarch/kernel/smp.c           | 2 +-
> > >    3 files changed, 4 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/arch/loongarch/include/asm/bootinfo.h b/arch/loongarch/include/asm/bootinfo.h
> > > index c60796869b2b..32fd0319594a 100644
> > > --- a/arch/loongarch/include/asm/bootinfo.h
> > > +++ b/arch/loongarch/include/asm/bootinfo.h
> > > @@ -30,7 +30,7 @@ struct loongson_system_configuration {
> > >        int boot_cpu_id;
> > >        int cores_per_node;
> > >        int cores_per_package;
> > > -     unsigned long cores_io_master;
> > > +     unsigned long cores_io_master[4];
> > Can the hardcoded 4 be defined something like this?
> >      DIV_ROUND_UP(CONFIG_NR_CPUS, sizeof(long))
> Can this be used to define arrays?

Yes, it's basically just expanded to (((CONFIG_NR_CPUS) + (sizeof(long))
- 1) / (sizeof(long)).  Per the C standard (C99 section 6.6 p6) it's an
integer constant expression and can be used as array size.

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] LoongArch: Let cores_io_master cover the largest NR_CPUS
  2023-12-25  9:19   ` Huacai Chen
  2023-12-25 11:11     ` Xi Ruoyao
@ 2023-12-25 14:02     ` Jiaxun Yang
  2023-12-27  1:09       ` maobibo
  1 sibling, 1 reply; 6+ messages in thread
From: Jiaxun Yang @ 2023-12-25 14:02 UTC (permalink / raw
  To: Huacai Chen, maobibo
  Cc: loongson-kernel, loongarch, Xuefeng Li, Guo Ren, Xuerui Wang,
	linux-kernel, Huacai Chen



在 2023/12/25 09:19, Huacai Chen 写道:
> On Mon, Dec 25, 2023 at 5:13 PM maobibo <maobibo@loongson.cn> wrote:
>>
>>
>>
>> On 2023/12/25 下午3:00, Huacai Chen wrote:
>>> Now loongson_system_configuration::cores_io_master only covers 64 cpus,
>>> if NR_CPUS > 64 there will be memory corruption. So let cores_io_master
>>> cover the largest NR_CPUS (256).
>>>
>>> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
>>> ---
>>>    arch/loongarch/include/asm/bootinfo.h | 4 ++--
>>>    arch/loongarch/kernel/acpi.c          | 2 +-
>>>    arch/loongarch/kernel/smp.c           | 2 +-
>>>    3 files changed, 4 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/arch/loongarch/include/asm/bootinfo.h b/arch/loongarch/include/asm/bootinfo.h
>>> index c60796869b2b..32fd0319594a 100644
>>> --- a/arch/loongarch/include/asm/bootinfo.h
>>> +++ b/arch/loongarch/include/asm/bootinfo.h
>>> @@ -30,7 +30,7 @@ struct loongson_system_configuration {
>>>        int boot_cpu_id;
>>>        int cores_per_node;
>>>        int cores_per_package;
>>> -     unsigned long cores_io_master;
>>> +     unsigned long cores_io_master[4];
>> Can the hardcoded 4 be defined something like this?
>>      DIV_ROUND_UP(CONFIG_NR_CPUS, sizeof(long))
> Can this be used to define arrays?

I think DECLARE_BITMAP should work.

See how are we dealing with cpumask_t:
```
typedef struct cpumask { DECLARE_BITMAP(bits, NR_CPUS); } cpumask_t;
```

Thanks
- Jiaxun
[...]

> 
> Huacai

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] LoongArch: Let cores_io_master cover the largest NR_CPUS
  2023-12-25 14:02     ` Jiaxun Yang
@ 2023-12-27  1:09       ` maobibo
  0 siblings, 0 replies; 6+ messages in thread
From: maobibo @ 2023-12-27  1:09 UTC (permalink / raw
  To: Jiaxun Yang, Huacai Chen
  Cc: loongson-kernel, loongarch, Xuefeng Li, Guo Ren, Xuerui Wang,
	linux-kernel, Huacai Chen



On 2023/12/25 下午10:02, Jiaxun Yang wrote:
> 
> 
> 在 2023/12/25 09:19, Huacai Chen 写道:
>> On Mon, Dec 25, 2023 at 5:13 PM maobibo <maobibo@loongson.cn> wrote:
>>>
>>>
>>>
>>> On 2023/12/25 下午3:00, Huacai Chen wrote:
>>>> Now loongson_system_configuration::cores_io_master only covers 64 cpus,
>>>> if NR_CPUS > 64 there will be memory corruption. So let cores_io_master
>>>> cover the largest NR_CPUS (256).
>>>>
>>>> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
>>>> ---
>>>>    arch/loongarch/include/asm/bootinfo.h | 4 ++--
>>>>    arch/loongarch/kernel/acpi.c          | 2 +-
>>>>    arch/loongarch/kernel/smp.c           | 2 +-
>>>>    3 files changed, 4 insertions(+), 4 deletions(-)
>>>>
>>>> diff --git a/arch/loongarch/include/asm/bootinfo.h 
>>>> b/arch/loongarch/include/asm/bootinfo.h
>>>> index c60796869b2b..32fd0319594a 100644
>>>> --- a/arch/loongarch/include/asm/bootinfo.h
>>>> +++ b/arch/loongarch/include/asm/bootinfo.h
>>>> @@ -30,7 +30,7 @@ struct loongson_system_configuration {
>>>>        int boot_cpu_id;
>>>>        int cores_per_node;
>>>>        int cores_per_package;
>>>> -     unsigned long cores_io_master;
>>>> +     unsigned long cores_io_master[4];
>>> Can the hardcoded 4 be defined something like this?
>>>      DIV_ROUND_UP(CONFIG_NR_CPUS, sizeof(long))
>> Can this be used to define arrays?
> 
> I think DECLARE_BITMAP should work.
> 
> See how are we dealing with cpumask_t:
> ```
> typedef struct cpumask { DECLARE_BITMAP(bits, NR_CPUS); } cpumask_t;
> ```
Yeap, that will be better.

Regards
Bibo Mao
> 
> Thanks
> - Jiaxun
> [...]
> 
>>
>> Huacai


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-12-27  1:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-25  7:00 [PATCH] LoongArch: Let cores_io_master cover the largest NR_CPUS Huacai Chen
2023-12-25  9:13 ` maobibo
2023-12-25  9:19   ` Huacai Chen
2023-12-25 11:11     ` Xi Ruoyao
2023-12-25 14:02     ` Jiaxun Yang
2023-12-27  1:09       ` maobibo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.