Skip to contentSkip to conversation

Revert "cpumask: fix checking valid cpu range"

PATCH In review [email protected] 3 participants 7 messages Oct 15, 2022 – Oct 18, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Revert "cpumask: fix checking valid cpu range"

From: Guo Ren <[email protected]>

This reverts commit 78e5a3399421ad79fc024e6d78e2deb7809d26af.

------------[ cut here ]------------
WARNING: CPU: 3 PID: 1 at include/linux/cpumask.h:110 cpumask_next_wrap+0x5c/0x80

Let's back this out and retry with a larger clean up in -next.

Fixes 78e5a3399421 ("cpumask: fix checking valid cpu range")
Cc Jakub Kicinski <[email protected]>
---
 include/linux/cpumask.h | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)
include/linux/cpumask.h +11 -8
index 2f065ad97541..c2aa0aa26b45 100644
@@ -174,8 +174,9 @@ static inline unsigned int cpumask_last(const struct cpumask *srcp)
 static inline
 unsigned int cpumask_next(int n, const struct cpumask *srcp)
 {
-	/* n is a prior cpu */
-	cpumask_check(n + 1);
+	/* -1 is a legal arg here. */
+	if (n != -1)
+		cpumask_check(n);
 	return find_next_bit(cpumask_bits(srcp), nr_cpumask_bits, n + 1);
 }
 
@@ -188,8 +189,9 @@ unsigned int cpumask_next(int n, const struct cpumask *srcp)
  */
 static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
 {
-	/* n is a prior cpu */
-	cpumask_check(n + 1);
+	/* -1 is a legal arg here. */
+	if (n != -1)
+		cpumask_check(n);
 	return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
 }
 
@@ -229,8 +231,9 @@ static inline
 unsigned int cpumask_next_and(int n, const struct cpumask *src1p,
 		     const struct cpumask *src2p)
 {
-	/* n is a prior cpu */
-	cpumask_check(n + 1);
+	/* -1 is a legal arg here. */
+	if (n != -1)
+		cpumask_check(n);
 	return find_next_and_bit(cpumask_bits(src1p), cpumask_bits(src2p),
 		nr_cpumask_bits, n + 1);
 }
@@ -260,8 +263,8 @@ static inline
 unsigned int cpumask_next_wrap(int n, const struct cpumask *mask, int start, bool wrap)
 {
 	cpumask_check(start);
-	/* n is a prior cpu */
-	cpumask_check(n + 1);
+	if (n != -1)
+		cpumask_check(n);
 
 	/*
 	 * Return the first available CPU when wrapping, or when starting before cpu0,
Signature · 1 line
2.36.1
#1 lore raw
Quoted 9 lines · On Sat, Oct 15, 2022 at 09:05:48AM -0400, [email protected] wrote:

From: Guo Ren <[email protected]>

This reverts commit 78e5a3399421ad79fc024e6d78e2deb7809d26af.

------------[ cut here ]------------
WARNING: CPU: 3 PID: 1 at include/linux/cpumask.h:110 cpumask_next_wrap+0x5c/0x80

Let's back this out and retry with a larger clean up in -next.

Unfortunately the revert triggers (or exposes ?) another backtrace.

WARNING: CPU: 0 PID: 1 at include/linux/cpumask.h:110 __netif_set_xps_queue+0x194/0x976
Modules linked in:
CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.0.0-12199-g277163563de8 #1
Hardware name: riscv-virtio,qemu (DT)
epc : __netif_set_xps_queue+0x194/0x976
ra : __netif_set_xps_queue+0x3b0/0x976

epc : c089a664 ra : c089a880 sp : c2515c60 gp : c1d8e760 tp : c2578040 t0 : c364f980 t1 : 00000000 t2 : 00001fff s0 : c2515cd0 s1 : c2515ce4 a0 : c364f940 a1 : 00000000 a2 : c364f940 a3 : 00000000 a4 : c364f950 a5 : c364f890 a6 : 00000003 a7 : 00000000 s2 : 00000001 s3 : c1d382c0 s4 : 00000000 s5 : 00000000 s6 : 00000000 s7 : c364f880 s8 : 00000000 s9 : 00000001 s10: 00000001
s11: 00000000 t3 : 00000018 t4 : 7fd38a0e t5 : 00000007 t6 : c3639470
status: 00000120 badaddr: 00000000 cause: 00000003

[<c074548a>] virtnet_set_affinity+0x13a/0x1a2
[<c07478de>] virtnet_probe+0x884/0xfdc
[<c063ce9a>] virtio_dev_probe+0x1d6/0x354
[<c0683d6e>] really_probe+0x82/0x214
[<c0683f58>] __driver_probe_device+0x58/0xa2
[<c0683fd2>] driver_probe_device+0x30/0xaa
[<c0684596>] __driver_attach+0x56/0x11c
[<c0681f26>] bus_for_each_dev+0x52/0x90
[<c06837c0>] driver_attach+0x1a/0x22
[<c068331a>] bus_add_driver+0x148/0x1b6
[<c0684d70>] driver_register+0x52/0xea
[<c063c924>] register_virtio_driver+0x1a/0x28
[<c0c2428e>] virtio_net_driver_init+0x7a/0xa6
[<c0002824>] do_one_initcall+0x5e/0x2e2
[<c0c01130>] kernel_init_freeable+0x298/0x306
[<c0aa0ac2>] kernel_init+0x1e/0x10e
[<c0003ad8>] ret_from_exception+0x0/0x10
irq event stamp: 106012
hardirqs last  enabled at (106011): [<c0aa9284>] _raw_spin_unlock_irqrestore+0x54/0x62
hardirqs last disabled at (106012): [<c0007534>] __trace_hardirqs_off+0xc/0x14
softirqs last  enabled at (105764): [<c0886392>] napi_get_frags_check+0x0/0x50
softirqs last disabled at (105758): [<c0886392>] napi_get_frags_check+0x0/0x50

This is the result of commit 854701ba4c39 ("net: fix cpu_max_bits_warn() usage in netif_attrmask_next{,_and}").

Guenter

author
#2 lore raw
Quoted 6 lines · Guenter Roeck
Quoted 4 lines · On Sat, Oct 15, 2022 at 09:05:48AM -0400, [email protected] wrote:

From: Guo Ren <[email protected]>

This reverts commit 78e5a3399421ad79fc024e6d78e2deb7809d26af.

Quoted 7 lines
Quoted 5 lines
------------[ cut here ]------------
WARNING: CPU: 3 PID: 1 at include/linux/cpumask.h:110 cpumask_next_wrap+0x5c/0x80

Let's back this out and retry with a larger clean up in -next.

Unfortunately the revert triggers (or exposes ?) another backtrace.

This should be fixed by another Revert patch.

https://lore.kernel.org/netdev/166582921612.1299.769135677399153914.git-patchwork-notify@kernel.org/T/#m0111a76380626b2f91e072ecdd5827578d5cbf60

Please have a try.

Quoted 46 lines
WARNING: CPU: 0 PID: 1 at include/linux/cpumask.h:110 __netif_set_xps_queue+0x194/0x976
Modules linked in:
CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.0.0-12199-g277163563de8 #1
Hardware name: riscv-virtio,qemu (DT)
epc : __netif_set_xps_queue+0x194/0x976
ra : __netif_set_xps_queue+0x3b0/0x976

epc : c089a664 ra : c089a880 sp : c2515c60 gp : c1d8e760 tp : c2578040 t0 : c364f980 t1 : 00000000 t2 : 00001fff s0 : c2515cd0 s1 : c2515ce4 a0 : c364f940 a1 : 00000000 a2 : c364f940 a3 : 00000000 a4 : c364f950 a5 : c364f890 a6 : 00000003 a7 : 00000000 s2 : 00000001 s3 : c1d382c0 s4 : 00000000 s5 : 00000000 s6 : 00000000 s7 : c364f880 s8 : 00000000 s9 : 00000001 s10: 00000001
s11: 00000000 t3 : 00000018 t4 : 7fd38a0e t5 : 00000007 t6 : c3639470
status: 00000120 badaddr: 00000000 cause: 00000003

[<c074548a>] virtnet_set_affinity+0x13a/0x1a2
[<c07478de>] virtnet_probe+0x884/0xfdc
[<c063ce9a>] virtio_dev_probe+0x1d6/0x354
[<c0683d6e>] really_probe+0x82/0x214
[<c0683f58>] __driver_probe_device+0x58/0xa2
[<c0683fd2>] driver_probe_device+0x30/0xaa
[<c0684596>] __driver_attach+0x56/0x11c
[<c0681f26>] bus_for_each_dev+0x52/0x90
[<c06837c0>] driver_attach+0x1a/0x22
[<c068331a>] bus_add_driver+0x148/0x1b6
[<c0684d70>] driver_register+0x52/0xea
[<c063c924>] register_virtio_driver+0x1a/0x28
[<c0c2428e>] virtio_net_driver_init+0x7a/0xa6
[<c0002824>] do_one_initcall+0x5e/0x2e2
[<c0c01130>] kernel_init_freeable+0x298/0x306
[<c0aa0ac2>] kernel_init+0x1e/0x10e
[<c0003ad8>] ret_from_exception+0x0/0x10
irq event stamp: 106012
hardirqs last  enabled at (106011): [<c0aa9284>] _raw_spin_unlock_irqrestore+0x54/0x62
hardirqs last disabled at (106012): [<c0007534>] __trace_hardirqs_off+0xc/0x14
softirqs last  enabled at (105764): [<c0886392>] napi_get_frags_check+0x0/0x50
softirqs last disabled at (105758): [<c0886392>] napi_get_frags_check+0x0/0x50

This is the result of commit 854701ba4c39 ("net: fix cpu_max_bits_warn() usage in netif_attrmask_next{,_and}").

Guenter

Signature · 2 lines
Best Regards
 Guo Ren
#3 lore raw
Quoted 13 lines · Guo Ren
Quoted 12 lines · Guenter Roeck
Quoted 9 lines · On Sat, Oct 15, 2022 at 09:05:48AM -0400, [email protected] wrote:

From: Guo Ren <[email protected]>

This reverts commit 78e5a3399421ad79fc024e6d78e2deb7809d26af.

------------[ cut here ]------------
WARNING: CPU: 3 PID: 1 at include/linux/cpumask.h:110 cpumask_next_wrap+0x5c/0x80

Let's back this out and retry with a larger clean up in -next.

Quoted 7 lines
Quoted 1 line

Unfortunately the revert triggers (or exposes ?) another backtrace.

This should be fixed by another Revert patch.

https://lore.kernel.org/netdev/166582921612.1299.769135677399153914.git-patchwork-notify@kernel.org/T/#m0111a76380626b2f91e072ecdd5827578d5cbf60

Please have a try.

Yes, I already tested that one and confirmed that it fixes the warning below. Thanks for the pointer.

Guenter

Quoted 49 lines
Quoted 46 lines
WARNING: CPU: 0 PID: 1 at include/linux/cpumask.h:110 __netif_set_xps_queue+0x194/0x976
Modules linked in:
CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.0.0-12199-g277163563de8 #1
Hardware name: riscv-virtio,qemu (DT)
epc : __netif_set_xps_queue+0x194/0x976
ra : __netif_set_xps_queue+0x3b0/0x976

epc : c089a664 ra : c089a880 sp : c2515c60 gp : c1d8e760 tp : c2578040 t0 : c364f980 t1 : 00000000 t2 : 00001fff s0 : c2515cd0 s1 : c2515ce4 a0 : c364f940 a1 : 00000000 a2 : c364f940 a3 : 00000000 a4 : c364f950 a5 : c364f890 a6 : 00000003 a7 : 00000000 s2 : 00000001 s3 : c1d382c0 s4 : 00000000 s5 : 00000000 s6 : 00000000 s7 : c364f880 s8 : 00000000 s9 : 00000001 s10: 00000001
s11: 00000000 t3 : 00000018 t4 : 7fd38a0e t5 : 00000007 t6 : c3639470
status: 00000120 badaddr: 00000000 cause: 00000003

[<c074548a>] virtnet_set_affinity+0x13a/0x1a2
[<c07478de>] virtnet_probe+0x884/0xfdc
[<c063ce9a>] virtio_dev_probe+0x1d6/0x354
[<c0683d6e>] really_probe+0x82/0x214
[<c0683f58>] __driver_probe_device+0x58/0xa2
[<c0683fd2>] driver_probe_device+0x30/0xaa
[<c0684596>] __driver_attach+0x56/0x11c
[<c0681f26>] bus_for_each_dev+0x52/0x90
[<c06837c0>] driver_attach+0x1a/0x22
[<c068331a>] bus_add_driver+0x148/0x1b6
[<c0684d70>] driver_register+0x52/0xea
[<c063c924>] register_virtio_driver+0x1a/0x28
[<c0c2428e>] virtio_net_driver_init+0x7a/0xa6
[<c0002824>] do_one_initcall+0x5e/0x2e2
[<c0c01130>] kernel_init_freeable+0x298/0x306
[<c0aa0ac2>] kernel_init+0x1e/0x10e
[<c0003ad8>] ret_from_exception+0x0/0x10
irq event stamp: 106012
hardirqs last  enabled at (106011): [<c0aa9284>] _raw_spin_unlock_irqrestore+0x54/0x62
hardirqs last disabled at (106012): [<c0007534>] __trace_hardirqs_off+0xc/0x14
softirqs last  enabled at (105764): [<c0886392>] napi_get_frags_check+0x0/0x50
softirqs last disabled at (105758): [<c0886392>] napi_get_frags_check+0x0/0x50

This is the result of commit 854701ba4c39 ("net: fix cpu_max_bits_warn() usage in netif_attrmask_next{,_and}").

Guenter

author
#4 lore raw

Ping Jakub Kicinski <[email protected]>.

You seem to miss this Revert fixup on cpumask_check(n + 1).

Your patch has merged in v6.1-rc1, but that is not enough.
https://lore.kernel.org/netdev/166582921612.1299.769135677399153914.git-patchwork-notify@kernel.org/T/#m0111a76380626b2f91e072ecdd5827578d5cbf60

Without the patch, there still is a warning.

Quoted 20 lines · Guenter Roeck
Quoted 18 lines · Guo Ren
Quoted 6 lines · Guenter Roeck
Quoted 4 lines · On Sat, Oct 15, 2022 at 09:05:48AM -0400, [email protected] wrote:

From: Guo Ren <[email protected]>

This reverts commit 78e5a3399421ad79fc024e6d78e2deb7809d26af.

Quoted 7 lines
Quoted 5 lines
------------[ cut here ]------------
WARNING: CPU: 3 PID: 1 at include/linux/cpumask.h:110 cpumask_next_wrap+0x5c/0x80

Let's back this out and retry with a larger clean up in -next.

Unfortunately the revert triggers (or exposes ?) another backtrace.

This should be fixed by another Revert patch.

https://lore.kernel.org/netdev/166582921612.1299.769135677399153914.git-patchwork-notify@kernel.org/T/#m0111a76380626b2f91e072ecdd5827578d5cbf60

Quoted 58 lines
Quoted 2 lines

Please have a try.

Yes, I already tested that one and confirmed that it fixes the warning below. Thanks for the pointer.

Guenter

Quoted 49 lines
Quoted 46 lines
WARNING: CPU: 0 PID: 1 at include/linux/cpumask.h:110 __netif_set_xps_queue+0x194/0x976
Modules linked in:
CPU: 0 PID: 1 Comm: swapper/0 Not tainted 6.0.0-12199-g277163563de8 #1
Hardware name: riscv-virtio,qemu (DT)
epc : __netif_set_xps_queue+0x194/0x976
ra : __netif_set_xps_queue+0x3b0/0x976

epc : c089a664 ra : c089a880 sp : c2515c60 gp : c1d8e760 tp : c2578040 t0 : c364f980 t1 : 00000000 t2 : 00001fff s0 : c2515cd0 s1 : c2515ce4 a0 : c364f940 a1 : 00000000 a2 : c364f940 a3 : 00000000 a4 : c364f950 a5 : c364f890 a6 : 00000003 a7 : 00000000 s2 : 00000001 s3 : c1d382c0 s4 : 00000000 s5 : 00000000 s6 : 00000000 s7 : c364f880 s8 : 00000000 s9 : 00000001 s10: 00000001
s11: 00000000 t3 : 00000018 t4 : 7fd38a0e t5 : 00000007 t6 : c3639470
status: 00000120 badaddr: 00000000 cause: 00000003

[<c074548a>] virtnet_set_affinity+0x13a/0x1a2
[<c07478de>] virtnet_probe+0x884/0xfdc
[<c063ce9a>] virtio_dev_probe+0x1d6/0x354
[<c0683d6e>] really_probe+0x82/0x214
[<c0683f58>] __driver_probe_device+0x58/0xa2
[<c0683fd2>] driver_probe_device+0x30/0xaa
[<c0684596>] __driver_attach+0x56/0x11c
[<c0681f26>] bus_for_each_dev+0x52/0x90
[<c06837c0>] driver_attach+0x1a/0x22
[<c068331a>] bus_add_driver+0x148/0x1b6
[<c0684d70>] driver_register+0x52/0xea
[<c063c924>] register_virtio_driver+0x1a/0x28
[<c0c2428e>] virtio_net_driver_init+0x7a/0xa6
[<c0002824>] do_one_initcall+0x5e/0x2e2
[<c0c01130>] kernel_init_freeable+0x298/0x306
[<c0aa0ac2>] kernel_init+0x1e/0x10e
[<c0003ad8>] ret_from_exception+0x0/0x10
irq event stamp: 106012
hardirqs last  enabled at (106011): [<c0aa9284>] _raw_spin_unlock_irqrestore+0x54/0x62
hardirqs last disabled at (106012): [<c0007534>] __trace_hardirqs_off+0xc/0x14
softirqs last  enabled at (105764): [<c0886392>] napi_get_frags_check+0x0/0x50
softirqs last disabled at (105758): [<c0886392>] napi_get_frags_check+0x0/0x50

This is the result of commit 854701ba4c39 ("net: fix cpu_max_bits_warn() usage in netif_attrmask_next{,_and}").

Guenter

--
Best Regards
Guo Ren

maintainer
#5 lore raw
Quoted 8 lines · On Mon, 17 Oct 2022 10:56:05 +0800 Guo Ren wrote:

Ping Jakub Kicinski <[email protected]>.

You seem to miss this Revert fixup on cpumask_check(n + 1).

Your patch has merged in v6.1-rc1, but that is not enough.
https://lore.kernel.org/netdev/166582921612.1299.769135677399153914.git-patchwork-notify@kernel.org/T/#m0111a76380626b2f91e072ecdd5827578d5cbf60

Without the patch, there still is a warning.

Sorry, I don't know what you mean. I was only putting a workaround back into the core networking code - I'm guessing this patch will silence the warning that comes from virtio? I haven't looked into that one.

author
#6 lore raw
Quoted 6 lines · Jakub Kicinski
Quoted 4 lines · On Mon, 17 Oct 2022 10:56:05 +0800 Guo Ren wrote:

Ping Jakub Kicinski <[email protected]>.

You seem to miss this Revert fixup on cpumask_check(n + 1).

Quoted 8 lines
Quoted 4 lines

Your patch has merged in v6.1-rc1, but that is not enough.
https://lore.kernel.org/netdev/166582921612.1299.769135677399153914.git-patchwork-notify@kernel.org/T/#m0111a76380626b2f91e072ecdd5827578d5cbf60

Without the patch, there still is a warning.

Sorry, I don't know what you mean. I was only putting a workaround back into the core networking code - I'm guessing this patch will silence the warning that comes from virtio? I haven't looked into that one.

Without the patch, Linux-v6.1-rc1 would warn when
CONFIG_DEBUG_PER_CPU_MAPS was enabled.

[    2.130438] virtio_blk virtio0: 1/0/0 default/read/poll queues
[    2.137585] virtio_blk virtio0: [vda] 122880 512-byte logical
blocks (62.9 MB/60.0 MiB)
[    2.196181] lkdtm: No crash points registered, enable through debugfs
[    2.246658] ------------[ cut here ]------------
[    2.247468] WARNING: CPU: 3 PID: 1 at include/linux/cpumask.h:110
__netif_set_xps_queue+0x14e/0x792
[    2.248738] Modules linked in:
[    2.249323] CPU: 3 PID: 1 Comm: swapper/0 Not tainted 6.1.0-rc1 #336
[    2.250038] Hardware name: riscv-virtio,qemu (DT)
[    2.250697] epc : __netif_set_xps_queue+0x14e/0x792
[    2.251538]  ra : __netif_set_xps_queue+0x56c/0x792
[    2.252029] epc : ffffffff806f2972 ra : ffffffff806f2d90 sp :
ff600000023279d0
[    2.252664]  gp : ffffffff81603d88 tp : ff600000023a0000 t0 :
ff60000003068a40
[    2.253270]  t1 : 0000000000000003 t2 : 0000000000000000 s0 :
ff60000002327a90
[    2.253878]  s1 : 0000000000000000 a0 : ff60000003068a00 a1 :
ff60000003068a00
[    2.254491]  a2 : ff600000030687e8 a3 : 0000000000000004 a4 :
0000000000000000
[    2.255521]  a5 : 0000000000000000 a6 : 0000000000000000 a7 :
0000000000000000
[    2.256506]  s2 : 0000000000000000 s3 : 0000000000000000 s4 :
ff60000002327aa0
[    2.257161]  s5 : ffffffff816071c0 s6 : 0000000000000000 s7 :
0000000000000001
[    2.257761]  s8 : 0000000000000000 s9 : 0000000000000004 s10:
ff600000030687c0
[    2.258369]  s11: 0000000000000004 t3 : 0000000000000000 t4 :
0000000000000014
[    2.259368]  t5 : 0000000000000000 t6 : 0000000000000000
[    2.260270] status: 0000000200000120 badaddr: 0000000000000000
cause: 0000000000000003
[    2.261200] [<ffffffff805d941e>] virtnet_set_affinity+0x14a/0x1c0
[    2.261837] [<ffffffff805db734>] virtnet_probe+0x832/0xf1e
[    2.262319] [<ffffffff804ff5d0>] virtio_dev_probe+0x164/0x2de
[    2.263055] [<ffffffff8054d478>] really_probe+0x82/0x224
[    2.263858] [<ffffffff8054d674>] __driver_probe_device+0x5a/0xaa
[    2.264445] [<ffffffff8054d6f0>] driver_probe_device+0x2c/0xb8
[    2.264987] [<ffffffff8054dd1a>] __driver_attach+0x76/0x108
[    2.265495] [<ffffffff8054b436>] bus_for_each_dev+0x52/0x9a
[    2.265996] [<ffffffff8054ce40>] driver_attach+0x1a/0x28
[    2.266475] [<ffffffff8054c94a>] bus_add_driver+0x154/0x1c2
[    2.267383] [<ffffffff8054e546>] driver_register+0x52/0x108
[    2.268198] [<ffffffff804ff0d4>] register_virtio_driver+0x1c/0x2c
[    2.268778] [<ffffffff80a291a0>] virtio_net_driver_init+0x7a/0xb0
[    2.269323] [<ffffffff80002854>] do_one_initcall+0x66/0x2e4
[    2.269834] [<ffffffff80a01226>] kernel_init_freeable+0x28a/0x304
[    2.270372] [<ffffffff808cc8b6>] kernel_init+0x1e/0x110
[    2.271099] [<ffffffff80003d42>] ret_from_exception+0x0/0x10
[    2.272015] ---[ end trace 0000000000000000 ]---
Signature · 2 lines
Best Regards
 Guo Ren