From: Alexander Lobakin <aleksander.lobakin@intel.com>
To: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Alexander Lobakin <aleksander.lobakin@intel.com>,
Dmitry Safonov <0x7f454c46@gmail.com>,
Heiner Kallweit <hkallweit1@gmail.com>,
nex.sw.ncis.osdt.itp.upstreaming@intel.com,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH net-next 2/2] netdev_queues: fix -Wshadow / Sparse shadow warnings throughout the file
Date: Fri, 29 Mar 2024 18:00:00 +0100 [thread overview]
Message-ID: <20240329170000.3241460-3-aleksander.lobakin@intel.com> (raw)
In-Reply-To: <20240329170000.3241460-1-aleksander.lobakin@intel.com>
Fix the following spam coming from <net/netdev_queues.h> when building
with W=12 and/or C=1:
Clang:
drivers/net/ethernet/intel/idpf/idpf_txrx.c:1992:9: warning: declaration shadows a local variable [-Wshadow]
1992 | return netif_txq_maybe_stop(nq, IDPF_DESC_UNUSED(tx_q), size, size);
| ^
./include/net/netdev_queues.h:137:11: note: expanded from macro 'netif_txq_maybe_stop'
137 | _res = netif_txq_try_stop(txq, get_desc, start_thrs); \
| ^
./include/net/netdev_queues.h:92:7: note: expanded from macro 'netif_txq_try_stop'
92 | int _res; \
| ^
drivers/net/ethernet/intel/idpf/idpf_txrx.c:1992:9: note: previous declaration is here
./include/net/netdev_queues.h:133:7: note: expanded from macro 'netif_txq_maybe_stop'
133 | int _res; \
| ^
Sparse:
drivers/net/ethernet/intel/idpf/idpf_txrx.c:1992:16: warning: symbol '_res' shadows an earlier one
drivers/net/ethernet/intel/idpf/idpf_txrx.c:1992:16: originally declared here
Use __UNIQUE_ID() in all of the macros which declare local variables.
Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com>
---
include/net/netdev_queues.h | 54 +++++++++++++++++++++++++++----------
1 file changed, 40 insertions(+), 14 deletions(-)
diff --git a/include/net/netdev_queues.h b/include/net/netdev_queues.h
index 1ec408585373..317d6bfe32c7 100644
--- a/include/net/netdev_queues.h
+++ b/include/net/netdev_queues.h
@@ -87,14 +87,14 @@ struct netdev_stat_ops {
* be updated before invoking the macros.
*/
-#define netif_txq_try_stop(txq, get_desc, start_thrs) \
+#define _netif_txq_try_stop(txq, get_desc, start_thrs, _res) \
({ \
int _res; \
\
netif_tx_stop_queue(txq); \
/* Producer index and stop bit must be visible \
* to consumer before we recheck. \
- * Pairs with a barrier in __netif_txq_completed_wake(). \
+ * Pairs with a barrier in ___netif_txq_completed_wake(). \
*/ \
smp_mb__after_atomic(); \
\
@@ -107,16 +107,20 @@ struct netdev_stat_ops {
_res = -1; \
} \
_res; \
- }) \
+ })
+#define netif_txq_try_stop(txq, get_desc, start_thrs) \
+ _netif_txq_try_stop(txq, get_desc, start_thrs, \
+ __UNIQUE_ID(res_))
/**
- * netif_txq_maybe_stop() - locklessly stop a Tx queue, if needed
+ * _netif_txq_maybe_stop() - locklessly stop a Tx queue, if needed
* @txq: struct netdev_queue to stop/start
* @get_desc: get current number of free descriptors (see requirements below!)
* @stop_thrs: minimal number of available descriptors for queue to be left
* enabled
* @start_thrs: minimal number of descriptors to re-enable the queue, can be
* equal to @stop_thrs or higher to avoid frequent waking
+ * @_res: __UNIQUE_ID() to avoid variable name clash
*
* All arguments may be evaluated multiple times, beware of side effects.
* @get_desc must be a formula or a function call, it must always
@@ -128,7 +132,8 @@ struct netdev_stat_ops {
* 1 if the queue was left enabled
* -1 if the queue was re-enabled (raced with waking)
*/
-#define netif_txq_maybe_stop(txq, get_desc, stop_thrs, start_thrs) \
+#define _netif_txq_maybe_stop(txq, get_desc, stop_thrs, start_thrs, \
+ _res) \
({ \
int _res; \
\
@@ -136,7 +141,10 @@ struct netdev_stat_ops {
if (unlikely(get_desc < stop_thrs)) \
_res = netif_txq_try_stop(txq, get_desc, start_thrs); \
_res; \
- }) \
+ })
+#define netif_txq_maybe_stop(txq, get_desc, stop_thrs, start_thrs) \
+ _netif_txq_maybe_stop(txq, get_desc, stop_thrs, start_thrs, \
+ __UNIQUE_ID(res_))
/* Variant of netdev_tx_completed_queue() which guarantees smp_mb() if
* @bytes != 0, regardless of kernel config.
@@ -152,7 +160,7 @@ netdev_txq_completed_mb(struct netdev_queue *dev_queue,
}
/**
- * __netif_txq_completed_wake() - locklessly wake a Tx queue, if needed
+ * ___netif_txq_completed_wake() - locklessly wake a Tx queue, if needed
* @txq: struct netdev_queue to stop/start
* @pkts: number of packets completed
* @bytes: number of bytes completed
@@ -160,6 +168,7 @@ netdev_txq_completed_mb(struct netdev_queue *dev_queue,
* @start_thrs: minimal number of descriptors to re-enable the queue
* @down_cond: down condition, predicate indicating that the queue should
* not be woken up even if descriptors are available
+ * @_res: __UNIQUE_ID() to avoid variable name clash
*
* All arguments may be evaluated multiple times.
* @get_desc must be a formula or a function call, it must always
@@ -171,15 +180,15 @@ netdev_txq_completed_mb(struct netdev_queue *dev_queue,
* 1 if the queue was already enabled (or disabled but @down_cond is true)
* -1 if the queue was left unchanged (@start_thrs not reached)
*/
-#define __netif_txq_completed_wake(txq, pkts, bytes, \
- get_desc, start_thrs, down_cond) \
+#define ___netif_txq_completed_wake(txq, pkts, bytes, get_desc, \
+ start_thrs, down_cond, _res) \
({ \
int _res; \
\
/* Report to BQL and piggy back on its barrier. \
* Barrier makes sure that anybody stopping the queue \
* after this point sees the new consumer index. \
- * Pairs with barrier in netif_txq_try_stop(). \
+ * Pairs with barrier in _netif_txq_try_stop(). \
*/ \
netdev_txq_completed_mb(txq, pkts, bytes); \
\
@@ -194,30 +203,43 @@ netdev_txq_completed_mb(struct netdev_queue *dev_queue,
} \
_res; \
})
+#define __netif_txq_completed_wake(txq, pkts, bytes, get_desc, \
+ start_thrs, down_cond) \
+ ___netif_txq_completed_wake(txq, pkts, bytes, get_desc, \
+ start_thrs, down_cond, \
+ __UNIQUE_ID(res_))
#define netif_txq_completed_wake(txq, pkts, bytes, get_desc, start_thrs) \
__netif_txq_completed_wake(txq, pkts, bytes, get_desc, start_thrs, false)
/* subqueue variants follow */
-#define netif_subqueue_try_stop(dev, idx, get_desc, start_thrs) \
+#define _netif_subqueue_try_stop(dev, idx, get_desc, start_thrs, txq) \
({ \
struct netdev_queue *txq; \
\
txq = netdev_get_tx_queue(dev, idx); \
netif_txq_try_stop(txq, get_desc, start_thrs); \
})
+#define netif_subqueue_try_stop(dev, idx, get_desc, start_thrs) \
+ _netif_subqueue_try_stop(dev, idx, get_desc, start_thrs, \
+ __UNIQUE_ID(txq_))
-#define netif_subqueue_maybe_stop(dev, idx, get_desc, stop_thrs, start_thrs) \
+#define _netif_subqueue_maybe_stop(dev, idx, get_desc, stop_thrs, \
+ start_thrs, txq) \
({ \
struct netdev_queue *txq; \
\
txq = netdev_get_tx_queue(dev, idx); \
netif_txq_maybe_stop(txq, get_desc, stop_thrs, start_thrs); \
})
+#define netif_subqueue_maybe_stop(dev, idx, get_desc, stop_thrs, \
+ start_thrs) \
+ _netif_subqueue_maybe_stop(dev, idx, get_desc, stop_thrs, \
+ start_thrs, __UNIQUE_ID(txq_))
-#define netif_subqueue_completed_wake(dev, idx, pkts, bytes, \
- get_desc, start_thrs) \
+#define _netif_subqueue_completed_wake(dev, idx, pkts, bytes, get_desc, \
+ start_thrs, txq) \
({ \
struct netdev_queue *txq; \
\
@@ -225,5 +247,9 @@ netdev_txq_completed_mb(struct netdev_queue *dev_queue,
netif_txq_completed_wake(txq, pkts, bytes, \
get_desc, start_thrs); \
})
+#define netif_subqueue_completed_wake(dev, idx, pkts, bytes, get_desc, \
+ start_thrs) \
+ _netif_subqueue_completed_wake(dev, idx, pkts, bytes, get_desc, \
+ start_thrs, __UNIQUE_ID(txq_))
#endif
--
2.44.0
next prev parent reply other threads:[~2024-03-29 17:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-29 16:59 [PATCH net-next 0/2] net: fix variable shadowing spam from headers Alexander Lobakin
2024-03-29 16:59 ` [PATCH net-next 1/2] net/tcp: fix -Wshadow / Sparse shadow warnings in tcp_hash_fail() Alexander Lobakin
2024-03-29 17:00 ` Alexander Lobakin [this message]
2024-03-29 20:18 ` [PATCH net-next 2/2] netdev_queues: fix -Wshadow / Sparse shadow warnings throughout the file Jakub Kicinski
2024-03-29 20:18 ` Jakub Kicinski
2024-03-29 20:53 ` Jakub Kicinski
2024-03-29 20:53 ` Jakub Kicinski
2024-04-02 11:53 ` Alexander Lobakin
2024-04-02 12:45 ` Eric Dumazet
2024-04-02 15:53 ` Alexander Lobakin
2024-04-02 16:48 ` Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240329170000.3241460-3-aleksander.lobakin@intel.com \
--to=aleksander.lobakin@intel.com \
--cc=0x7f454c46@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nex.sw.ncis.osdt.itp.upstreaming@intel.com \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®