[PATCH] netdevice: don't warn when capping txqueue 0

Kevin Mitchell posted 1 patch 1 year, 6 months ago
include/linux/netdevice.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] netdevice: don't warn when capping txqueue 0
Posted by Kevin Mitchell 1 year, 6 months ago
With commit d7dac083414e ("net-sysfs: update the queue counts in the
unregistration path"), we started seeing the following warning message
during our stress test that streams packets out of a device while
registering and unregistering it:

et3_11_1 selects TX queue 0, but real number of TX queues is 0

The issue is that remove_queue_kobjects() is setting real_num_tx_queues
to 0 before the last few packets are queued. When netdev_cap_txqueue()
is called to cap queue = 0, it emits this message.

However, when queue == real_num_tx_queues == 0, this message doesn't
make much sense because 0 is the fallback value returned
anyway. Therefore, omit the warning when queue is already the fallback
value of 0.

Fixes: d7dac083414e ("net-sysfs: update the queue counts in the unregistration path")
Link: https://lore.kernel.org/r/YzOjEqBMtF+Ib72v@chmeee/
Signed-off-by: Kevin Mitchell <kevmitch@arista.com>
---
 include/linux/netdevice.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 05d6f3facd5a..3fd1e50b6bf5 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -3493,7 +3493,7 @@ static inline void netdev_reset_queue(struct net_device *dev_queue)
  */
 static inline u16 netdev_cap_txqueue(struct net_device *dev, u16 queue_index)
 {
-	if (unlikely(queue_index >= dev->real_num_tx_queues)) {
+	if (unlikely(queue_index > 0 && queue_index >= dev->real_num_tx_queues)) {
 		net_warn_ratelimited("%s selects TX queue %d, but real number of TX queues is %d\n",
 				     dev->name, queue_index,
 				     dev->real_num_tx_queues);
-- 
2.37.2
Re: [PATCH] netdevice: don't warn when capping txqueue 0
Posted by Eric Dumazet 1 year, 6 months ago
On Fri, Sep 30, 2022 at 6:02 PM Kevin Mitchell <kevmitch@arista.com> wrote:
>
> With commit d7dac083414e ("net-sysfs: update the queue counts in the
> unregistration path"), we started seeing the following warning message
> during our stress test that streams packets out of a device while
> registering and unregistering it:
>
> et3_11_1 selects TX queue 0, but real number of TX queues is 0
>
> The issue is that remove_queue_kobjects() is setting real_num_tx_queues
> to 0 before the last few packets are queued. When netdev_cap_txqueue()
> is called to cap queue = 0, it emits this message.
>
> However, when queue == real_num_tx_queues == 0, this message doesn't
> make much sense because 0 is the fallback value returned
> anyway. Therefore, omit the warning when queue is already the fallback
> value of 0.

If there is no TX queue, I do not think we should select queue #0 ?

It seems we should fix the root cause, because
transmit should be prohibited first, then device can 'unregister'.

Something is definitely wrong with a driver, or a layer not properly
observing IFF_UP rules and/or rcu grace periods in device dismantles.


>
> Fixes: d7dac083414e ("net-sysfs: update the queue counts in the unregistration path")
> Link: https://lore.kernel.org/r/YzOjEqBMtF+Ib72v@chmeee/
> Signed-off-by: Kevin Mitchell <kevmitch@arista.com>
> ---
>  include/linux/netdevice.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 05d6f3facd5a..3fd1e50b6bf5 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -3493,7 +3493,7 @@ static inline void netdev_reset_queue(struct net_device *dev_queue)
>   */
>  static inline u16 netdev_cap_txqueue(struct net_device *dev, u16 queue_index)
>  {
> -       if (unlikely(queue_index >= dev->real_num_tx_queues)) {
> +       if (unlikely(queue_index > 0 && queue_index >= dev->real_num_tx_queues)) {
>                 net_warn_ratelimited("%s selects TX queue %d, but real number of TX queues is %d\n",
>                                      dev->name, queue_index,
>                                      dev->real_num_tx_queues);
> --
> 2.37.2
>