diff mbox

[1/1] netstamp_needed shouldn't be jump_label_key

Message ID 1322511796-6908-2-git-send-email-igorm@etf.rs
State Superseded, archived
Delegated to: David Miller
Headers show

Commit Message

Igor Maravić Nov. 28, 2011, 8:23 p.m. UTC
From: Igor Maravic <igorm@etf.rs>

Problem with setting netstamp_needed as jump_label_key is that
it inc/dec, functions net_enable_timestamp/net_disable_timestamp,
are called from interrupts.

That can cause DEADLOCK, because jump_label_{inc, dec} are using mutex locking,
that may sleep.

Signed-off-by: Igor Maravic <igorm@etf.rs>

:100644 100644 d1f1071... 4d88cac... M	net/core/dev.c

Comments

Eric Dumazet Nov. 28, 2011, 8:33 p.m. UTC | #1
Le lundi 28 novembre 2011 à 21:23 +0100, igorm@etf.rs a écrit :
> From: Igor Maravic <igorm@etf.rs>
> 
> Problem with setting netstamp_needed as jump_label_key is that
> it inc/dec, functions net_enable_timestamp/net_disable_timestamp,
> are called from interrupts.
> 
> That can cause DEADLOCK, because jump_label_{inc, dec} are using mutex locking,
> that may sleep.
> 
> Signed-off-by: Igor Maravic <igorm@etf.rs>
> 

Come on, we can find another way to handle this :)

Its net-next, we are allowed to try to find something better.



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/core/dev.c b/net/core/dev.c
index d1f1071..4d88cac 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1442,29 +1442,29 @@  int call_netdevice_notifiers(unsigned long val, struct net_device *dev)
 }
 EXPORT_SYMBOL(call_netdevice_notifiers);
 
-static struct jump_label_key netstamp_needed __read_mostly;
+static atomic_t netstamp_needed = ATOMIC_INIT(0);
 
 void net_enable_timestamp(void)
 {
-	jump_label_inc(&netstamp_needed);
+	atomic_inc(&netstamp_needed);
 }
 EXPORT_SYMBOL(net_enable_timestamp);
 
 void net_disable_timestamp(void)
 {
-	jump_label_dec(&netstamp_needed);
+	atomic_dec(&netstamp_needed);
 }
 EXPORT_SYMBOL(net_disable_timestamp);
 
 static inline void net_timestamp_set(struct sk_buff *skb)
 {
 	skb->tstamp.tv64 = 0;
-	if (static_branch(&netstamp_needed))
+	if (atomic_read(&netstamp_needed))
 		__net_timestamp(skb);
 }
 
 #define net_timestamp_check(COND, SKB)			\
-	if (static_branch(&netstamp_needed)) {		\
+	if (atomic_read(&netstamp_needed)) {		\
 		if ((COND) && !(SKB)->tstamp.tv64)	\
 			__net_timestamp(SKB);		\
 	}						\