Message ID | 20231225070002.1350705-1-chenhuacai@loongson.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-10916-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp264223dyb; Sun, 24 Dec 2023 23:00:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IFEOOBRoXCci8SkdWuHV7yktLnSEiGHPYGD8adF52fznMn90Ffpf84jkJp66Ni+ybpgZ+D1 X-Received: by 2002:a05:620a:171e:b0:77e:fbba:6470 with SMTP id az30-20020a05620a171e00b0077efbba6470mr10705867qkb.79.1703487639627; Sun, 24 Dec 2023 23:00:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703487639; cv=none; d=google.com; s=arc-20160816; b=Xg7xNnFWPYmIohEZ1b6LFO5qXou9X2GSFj1LXPplu4W3m2ZtILC9qL3I+BkZBnb5QD BWmuuyL8T1P1LhgYtOXl63e9lNBVTbmzLRQjAWI2oCZph0Du1MpOyNmLcVSsRfR+m0DY +IlX+KQTnpp77XRmSUiMk7uP36QS6kU8DbSSZoADZjznNhMWt1jAkwC5QGReOOC+UFV9 JTOk03nJ/rncIef2uasw5JwR9hbCIDWhDBLHlnmk1bibeLBZf8Ki6t4UyBppEY9oqL4V OaX7nGMl2LJKfqGGtt1iZUiZ35XMzp4FLZFIK/52YuD4hYsnBaYOLvqCxOvQWl4msA6b 1YGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=5sxXnn06dGsVQgk15D4nckV+SLQFUoGpeov8sA5Oi+g=; fh=y7VKX694VLH2eb03/y0ljujQLJGtNdYVa6lu5bfy0Mc=; b=NYQYyteqBE+E7bueHObP1/BuRkjDzuU2YyGN/v90VS+F56zwnVBesDYDSf7/3xWApl 2x06VD2GMPbsackMPDenTI3Cr3qGqQuJy9CLiXSSLVltVfg9Nde7kOSj0zD5NYR9iR9T 7dyrw/KsaTcfZBgpE+C87k/1ZP3uQRia5KQl+DiqV4XzXDdaNRpH7PgDcQC2xNxl+MUW BWniGz+pQZ3BvV8/Mw/mKHSj/VlIMB2yJ2CERfm0pZCtfslhphat1cH73aQ2zYcWZxPy uYSJJodpMM5JYF/GLAwvVGwrEvjvnaSRe283zw+p/92l6fhS9EpGOudhbDD5NBTiionI K7Aw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-10916-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10916-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id h13-20020a05620a400d00b0077f44291e20si10627368qko.254.2023.12.24.23.00.39 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Dec 2023 23:00:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10916-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-10916-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10916-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 6DF2D1C2103C for <ouuuleilei@gmail.com>; Mon, 25 Dec 2023 07:00:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BC4AB23B0; Mon, 25 Dec 2023 07:00:25 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5260A1116; Mon, 25 Dec 2023 07:00:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C9C7C433C7; Mon, 25 Dec 2023 07:00:20 +0000 (UTC) From: Huacai Chen <chenhuacai@loongson.cn> To: Huacai Chen <chenhuacai@kernel.org> Cc: loongarch@lists.linux.dev, Xuefeng Li <lixuefeng@loongson.cn>, Guo Ren <guoren@kernel.org>, Xuerui Wang <kernel@xen0n.name>, Jiaxun Yang <jiaxun.yang@flygoat.com>, linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn, Huacai Chen <chenhuacai@loongson.cn> Subject: [PATCH] LoongArch: Let cores_io_master cover the largest NR_CPUS Date: Mon, 25 Dec 2023 15:00:02 +0800 Message-Id: <20231225070002.1350705-1-chenhuacai@loongson.cn> X-Mailer: git-send-email 2.39.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786236255530199515 X-GMAIL-MSGID: 1786236255530199515 |
Series |
LoongArch: Let cores_io_master cover the largest NR_CPUS
|
|
Commit Message
Huacai Chen
Dec. 25, 2023, 7 a.m. UTC
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(-)
Comments
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 > } > >
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 > > } > > > > >
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.
在 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
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
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 }