Skip to contentSkip to conversation

arch_topology: Do not set llc_sibling if llc_id is invalid

PATCH In review Qing Wang 4 participants 5 messages Apr 11, 2022 – Apr 12, 2022

Subsystems (2)
lore
Share & tools
lore

Qing Wang

author
#0 lore raw

PATCH 1/1 arch_topology: Do not set llc_sibling if llc_id is invalid

From: Wang Qing <[email protected]>

When ACPI is not enabled, cpuid_topo->llc_id = cpu_topo->llc_id = -1, which will set llc_sibling 0xff(...), this is misleading.

Don't set llc_sibling(default 0) if we don't know the cache topology.

---
 drivers/base/arch_topology.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/arch_topology.c +1 -1
index 1d6636e..5c3a642
@@ -684,7 +684,7 @@ void update_siblings_masks(unsigned int cpuid)
 	for_each_online_cpu(cpu) {
 		cpu_topo = &cpu_topology[cpu];
 
-		if (cpuid_topo->llc_id == cpu_topo->llc_id) {
+		if (cpu_topo->llc_id != -1 && cpuid_topo->llc_id == cpu_topo->llc_id) {
 			cpumask_set_cpu(cpu, &cpuid_topo->llc_sibling);
 			cpumask_set_cpu(cpuid, &cpu_topo->llc_sibling);
 		}
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#1 lore raw

Hi Qing,

Quoted 7 lines · Qing Wang

From: Wang Qing <[email protected]>

When ACPI is not enabled, cpuid_topo->llc_id = cpu_topo->llc_id = -1, which will set llc_sibling 0xff(...), this is misleading.

Don't set llc_sibling(default 0) if we don't know the cache topology.

Makes sense to me and thanks for splitting the patch and pointing this out clearly. Your earlier patches mixed other things and made it hard to highlight this one.

Hi Greg,

Can you pick this up ? IMO It can go as fix in -rc as it is kind of misleading though I am not sure if it is breaking any platform.

--
Regards,
Sudeep

#2 lore raw
Quoted 15 lines · Sudeep Holla

Hi Qing,

Quoted 7 lines · Qing Wang

From: Wang Qing <[email protected]>

When ACPI is not enabled, cpuid_topo->llc_id = cpu_topo->llc_id = -1, which will set llc_sibling 0xff(...), this is misleading.

Don't set llc_sibling(default 0) if we don't know the cache topology.

Makes sense to me and thanks for splitting the patch and pointing this out clearly. Your earlier patches mixed other things and made it hard to highlight this one.

Quoted 6 lines

Hi Greg,

Can you pick this up ? IMO It can go as fix in -rc as it is kind of misleading though I am not sure if it is breaking any platform.

Will do, thanks.

greg k-h

#3 lore raw
In reply to Qing Wang
Quoted 5 lines · Qing Wang

From: Wang Qing <[email protected]>

When ACPI is not enabled, cpuid_topo->llc_id = cpu_topo->llc_id = -1, which will set llc_sibling 0xff(...), this is misleading.

Shouldn't it be a Fixes tag then?

Quoted 1 line

Don't set llc_sibling(default 0) if we don't know the cache topology.

...

drivers/base/arch_topology.c void update_siblings_masks(unsigned int cpuid) · line 687

Quoted 2 lines
drivers/base/arch_topology.c +1 -1
-               if (cpuid_topo->llc_id == cpu_topo->llc_id) {
+               if (cpu_topo->llc_id != -1 && cpuid_topo->llc_id == cpu_topo->llc_id) {

I'm wondering if more strict check is better here, i.e.

               if (cpu_topo->llc_id >= 0 && cpuid_topo->llc_id ==

cpu_topo->llc_id) {

Quoted 3 lines
                        cpumask_set_cpu(cpu, &cpuid_topo->llc_sibling);
                        cpumask_set_cpu(cpuid, &cpu_topo->llc_sibling);
                }
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#4 lore raw
Quoted 9 lines · Andy Shevchenko
Quoted 5 lines · Qing Wang

From: Wang Qing <[email protected]>

When ACPI is not enabled, cpuid_topo->llc_id = cpu_topo->llc_id = -1, which will set llc_sibling 0xff(...), this is misleading.

Shouldn't it be a Fixes tag then?

I thought about that. One the file has moved and lot of refactoring before the move after the code was first introduced. Since no one has seen any issues as the mask matches all the CPUs on a single chip SoC and this is not user visible, I didn't push for the fixes tag.

Anyways the original commit introducing the feature is
Commit 37c3ec2d810f ("arm64: topology: divorce MC scheduling domain from core_siblings") which was merged in v4.18 if I read git log correctly.

I am happy to backport if needed.

Quoted 4 lines
Quoted 1 line

Don't set llc_sibling(default 0) if we don't know the cache topology.

...

Quoted 8 lines

drivers/base/arch_topology.c void update_siblings_masks(unsigned int cpuid) · line 687

Quoted 2 lines
drivers/base/arch_topology.c +1 -1
-               if (cpuid_topo->llc_id == cpu_topo->llc_id) {
+               if (cpu_topo->llc_id != -1 && cpuid_topo->llc_id == cpu_topo->llc_id) {

I'm wondering if more strict check is better here, i.e.

               if (cpu_topo->llc_id >= 0 && cpuid_topo->llc_id ==

cpu_topo->llc_id) {

Yes I would agree. But I think Qing is just following other similar checks in the file. All such ids are initialised to -1 and are assigned only valid values >= 0. I am OK to keep it as is to keep it aligned with other similar checks.

Signature · 2 lines
Regards,
Sudeep