Skip to contentSkip to conversation

Patch "net: simplify napi_synchronize() to avoid warnings" has been added to the 4.4-stable tree

PATCH [email protected] 1 participant 1 message Sep 22, 2016

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

net: simplify napi_synchronize() to avoid warnings

to the 4.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
net-simplify-napi_synchronize-to-avoid-warnings.patch
and it can be found in the queue-4.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From facc432faa59414bd7c60c307ff1645154a66c98 Mon Sep 17 00:00:00 2001

From: Arnd Bergmann <[email protected]>
Date: Fri, 22 Jan 2016 11:43:44 +0100
Subject: net: simplify napi_synchronize() to avoid warnings

From: Arnd Bergmann <[email protected]>

commit facc432faa59414bd7c60c307ff1645154a66c98 upstream.

The napi_synchronize() function is defined twice: The definition for SMP builds waits for other CPUs to be done, while the uniprocessor variant just contains a barrier and ignores its argument.

In the mvneta driver, this leads to a warning about an unused variable when we lookup the NAPI struct of another CPU and then don't use it:

ethernet/marvell/mvneta.c: In function 'mvneta_percpu_notifier':
ethernet/marvell/mvneta.c:2910:30: error: unused variable 'other_port' [-Werror=unused-variable]

There are no other CPUs on a UP build, so that code never runs, but gcc does not know this.

The nicest solution seems to be to turn the napi_synchronize() helper into an inline function for the UP case as well, as that leads gcc to not complain about the argument being unused. Once we do that, we can also combine the two cases into a single function definition and use if(IS_ENABLED()) rather than #ifdef to make it look a bit nicer.

The warning first came up in linux-4.4, but I failed to catch it earlier.

Fixes f86428854480 ("net: mvneta: Statically assign queues to CPUs")
---
 include/linux/netdevice.h |   11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
include/linux/netdevice.h +5 -6
@@ -511,7 +511,6 @@ static inline void napi_enable(struct na
 	clear_bit(NAPI_STATE_NPSVC, &n->state);
 }
 
-#ifdef CONFIG_SMP
 /**
  *	napi_synchronize - wait until NAPI is not running
  *	@n: napi context
@@ -522,12 +521,12 @@ static inline void napi_enable(struct na
  */
 static inline void napi_synchronize(const struct napi_struct *n)
 {
-	while (test_bit(NAPI_STATE_SCHED, &n->state))
-		msleep(1);
+	if (IS_ENABLED(CONFIG_SMP))
+		while (test_bit(NAPI_STATE_SCHED, &n->state))
+			msleep(1);
+	else
+		barrier();
 }
-#else
-# define napi_synchronize(n)	barrier()
-#endif
 
 enum netdev_queue_state_t {
 	__QUEUE_STATE_DRV_XOFF,

Patches currently in stable-queue which might be from [email protected] are

queue-4.4/mmc-dw_mmc-use-resource_size_t-to-store-physical-address.patch queue-4.4/net-simplify-napi_synchronize-to-avoid-warnings.patch queue-4.4/soc-qcom-spm-shut-up-uninitialized-variable-warning.patch queue-4.4/kconfig-tinyconfig-provide-whole-choice-blocks-to-avoid-warnings.patch queue-4.4/pinctrl-at91-pio4-use-pr-format-string-for-resource.patch