net: Fixup netif_attrmask_next_and warning
Subsystems (2)
PATCH 1/1 net: Fixup netif_attrmask_next_and warning
From: Guo Ren <[email protected]>
Don't pass nr_bits as arg1, cpu_max_bits_warn would cause warning now.
------------[ cut here ]------------ WARNING: CPU: 2 PID: 1 at include/linux/cpumask.h:110 __netif_set_xps_queue+0x14e/0x770 Modules linked in: CPU: 2 PID: 1 Comm: swapper/0 Not tainted 6.0.0-rc4-00018-g854701ba4c39 #324 Hardware name: riscv-virtio,qemu (DT) epc : __netif_set_xps_queue+0x14e/0x770 ra : __netif_set_xps_queue+0x552/0x770
epc : ffffffff806fe448 ra : ffffffff806fe84c sp : ff600000023279d0
gp : ffffffff815fff88 tp : ff600000023a0000 t0 : ff6000000308ab40 t1 : 0000000000000003 t2 : 0000000000000000 s0 : ff60000002327a90 s1 : 0000000000000000 a0 : ff6000000308ab00 a1 : ff6000000308ab00 a2 : ff6000000308a8e8 a3 : 0000000000000004 a4 : 0000000000000000 a5 : 0000000000000000 a6 : 0000000000000000 a7 : 0000000000000000 s2 : 0000000000000000 s3 : 0000000000000000 s4 : ff60000002327aa0 s5 : ffffffff816031c8 s6 : 0000000000000000 s7 : 0000000000000001 s8 : 0000000000000000 s9 : 0000000000000004 s10: ff6000000308a8c0
s11: 0000000000000004 t3 : 0000000000000000 t4 : 0000000000000014 t5 : 0000000000000000 t6 : 0000000000000000
status: 0000000200000120 badaddr: 0000000000000000 cause: 0000000000000003
[<ffffffff805e5824>] virtnet_set_affinity+0x14a/0x1c0 [<ffffffff805e7b04>] virtnet_probe+0x7fc/0xee2 [<ffffffff8050e120>] virtio_dev_probe+0x164/0x2de [<ffffffff8055b69e>] really_probe+0x82/0x224 [<ffffffff8055b89a>] __driver_probe_device+0x5a/0xaa [<ffffffff8055b916>] driver_probe_device+0x2c/0xb8 [<ffffffff8055bf34>] __driver_attach+0x76/0x108 [<ffffffff805597c0>] bus_for_each_dev+0x4a/0x8e [<ffffffff8055b072>] driver_attach+0x1a/0x28 [<ffffffff8055ab8c>] bus_add_driver+0x13c/0x1a6 [<ffffffff8055c722>] driver_register+0x4a/0xfc [<ffffffff8050dc34>] register_virtio_driver+0x1c/0x2c [<ffffffff80a2bae4>] virtio_net_driver_init+0x7a/0xb0 [<ffffffff80002840>] do_one_initcall+0x66/0x2e4 [<ffffffff80a01212>] kernel_init_freeable+0x28a/0x304 [<ffffffff808b21e2>] kernel_init+0x1e/0x110 [<ffffffff80003c46>] ret_from_exception+0x0/0x10 ---[ end trace 0000000000000000 ]---
--- net/core/dev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/core/dev.c +2 -2
@@ -2589,8 +2589,8 @@ int __netif_set_xps_queue(struct net_device *dev, const unsigned long *mask, copy = true;/* allocate memory for queue storage */ -for (j =-1 ; j =netif_attrmask_next_and (j, online_mask, mask, nr_ids), - j < nr_ids;) { +for (j =-1 ; j < nr_ids; + j =netif_attrmask_next_and (j, online_mask, mask, nr_ids)) {if (!new_dev_maps) { new_dev_maps =kzalloc (maps_sz,GFP_KERNEL );if (!new_dev_maps) {
Signature · 1 line
2.36.1
Quoted 44 lines · On Fri, Oct 14, 2022 at 12:39 AM <[email protected]> wrote:
From: Guo Ren <[email protected]>
Don't pass
nr_bitsas arg1,cpu_max_bits_warnwould cause warning now.------------[ cut here ]------------ WARNING: CPU: 2 PID: 1 at include/linux/cpumask.h:110 __netif_set_xps_queue+0x14e/0x770 Modules linked in: CPU: 2 PID: 1 Comm: swapper/0 Not tainted 6.0.0-rc4-00018-g854701ba4c39 #324 Hardware name: riscv-virtio,qemu (DT) epc : __netif_set_xps_queue+0x14e/0x770 ra : __netif_set_xps_queue+0x552/0x770epc :
ffffffff806fe448ra :ffffffff806fe84csp :ff600000023279d0
gp :ffffffff815fff88tp :ff600000023a0000t0 :ff6000000308ab40t1 : 0000000000000003 t2 : 0000000000000000 s0 :ff60000002327a90s1 : 0000000000000000 a0 :ff6000000308ab00a1 :ff6000000308ab00a2 :ff6000000308a8e8a3 : 0000000000000004 a4 : 0000000000000000 a5 : 0000000000000000 a6 : 0000000000000000 a7 : 0000000000000000 s2 : 0000000000000000 s3 : 0000000000000000 s4 :ff60000002327aa0s5 :ffffffff816031c8s6 : 0000000000000000 s7 : 0000000000000001 s8 : 0000000000000000 s9 : 0000000000000004 s10:ff6000000308a8c0
s11: 0000000000000004 t3 : 0000000000000000 t4 : 0000000000000014 t5 : 0000000000000000 t6 : 0000000000000000
status: 0000000200000120 badaddr: 0000000000000000 cause: 0000000000000003[<ffffffff805e5824>] virtnet_set_affinity+0x14a/0x1c0 [<ffffffff805e7b04>] virtnet_probe+0x7fc/0xee2 [<ffffffff8050e120>] virtio_dev_probe+0x164/0x2de [<ffffffff8055b69e>] really_probe+0x82/0x224 [<ffffffff8055b89a>] __driver_probe_device+0x5a/0xaa [<ffffffff8055b916>] driver_probe_device+0x2c/0xb8 [<ffffffff8055bf34>] __driver_attach+0x76/0x108 [<ffffffff805597c0>] bus_for_each_dev+0x4a/0x8e [<ffffffff8055b072>] driver_attach+0x1a/0x28 [<ffffffff8055ab8c>] bus_add_driver+0x13c/0x1a6 [<ffffffff8055c722>] driver_register+0x4a/0xfc [<ffffffff8050dc34>] register_virtio_driver+0x1c/0x2c [<ffffffff80a2bae4>] virtio_net_driver_init+0x7a/0xb0 [<ffffffff80002840>] do_one_initcall+0x66/0x2e4 [<ffffffff80a01212>] kernel_init_freeable+0x28a/0x304 [<ffffffff808b21e2>] kernel_init+0x1e/0x110 [<ffffffff80003c46>] ret_from_exception+0x0/0x10 ---[ end trace 0000000000000000 ]---
Quoted 1 line
Fixes 944c417daeb6 ("net: fix cpu_max_bits_warn() usage in netif_attrmask_next{,_and}")
Sorry, the Fixes commit is 854701ba4c39.
----
commit 854701ba4c39afae2362ba19a580c461cb183e4f
Author: Yury Norov <[email protected]> Date: Mon Sep 19 14:05:54 2022 -0700
net: fix cpu_max_bits_warn() usage in netif_attrmask_next{,_and}
The functions require to be passed with a cpu index prior to one that is the first to start search, so the valid input range is [-1, nr_cpu_ids-1). However, the code checks against [-1, nr_cpu_ids).
Quoted 24 lines
Signed-off-by Guo Ren <[email protected]>Signed-off-by Guo Ren <[email protected]>--- net/core/dev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)net/core/dev.c +2
-3@@ -2589,8 +2589,8 @@ int __netif_set_xps_queue(struct net_device *dev, const unsigned long *mask, copy = true;/* allocate memory for queue storage */ -for (j =-1 ; j =netif_attrmask_next_and (j, online_mask, mask, nr_ids), - j < nr_ids;) { +for (j =-1 ; j < nr_ids; + j =netif_attrmask_next_and (j, online_mask, mask, nr_ids)) {if (!new_dev_maps) { new_dev_maps =kzalloc (maps_sz,GFP_KERNEL );if (!new_dev_maps) { --2.36.1
Signature · 2 lines
Best Regards Guo Ren
Quoted 3 lines
Quoted 1 line
Fixes 944c417daeb6 ("net: fix cpu_max_bits_warn() usage in netif_attrmask_next{,_and}")Sorry, the Fixes commit is
854701ba4c39.
1. it doesn't fix my commit. There's nothing to fix. It fixes net code.
2. https://lore.kernel.org/all/YznDSKbiDI99Om23@yury-laptop/t/#mf3a04206802c50ee7f5900e968aa03abdeb49c68
Quoted 6 lines · Yury Norov
Quoted 4 lines
Quoted 2 lines
Fixes 944c417daeb6 ("net: fix cpu_max_bits_warn() usage in netif_attrmask_next{,_and}")Sorry, the Fixes commit is
854701ba4c39.1. it doesn't fix my commit. There's nothing to fix. It fixes net code.
Okay, I would change to:
Quoted 1 line
Signature · 2 lines
Best Regards Guo Ren