* [PATCH] net: disable preemption before call smp_processor_id()
@ 2010-08-07 9:26 Changli Gao
2010-08-08 3:37 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: Changli Gao @ 2010-08-07 9:26 UTC (permalink / raw)
To: David S. Miller; +Cc: Paul E. McKenney, Tom Herbert, netdev, Changli Gao
Although netif_rx() isn't expected to be called in process context with
preemption enabled, it'd better handle this case. And this is why get_cpu()
is used in the non-RPS #ifdef branch. If tree RCU is selected,
rcu_read_lock() won't disable preemption, so preempt_disable() should be
called explictly.
Signed-off-by: Changli Gao <xiaosuo@gmail.com>
---
net/core/dev.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/core/dev.c b/net/core/dev.c
index 2b50896..1ae6543 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2517,6 +2517,7 @@ int netif_rx(struct sk_buff *skb)
struct rps_dev_flow voidflow, *rflow = &voidflow;
int cpu;
+ preempt_disable();
rcu_read_lock();
cpu = get_rps_cpu(skb->dev, skb, &rflow);
@@ -2526,6 +2527,7 @@ int netif_rx(struct sk_buff *skb)
ret = enqueue_to_backlog(skb, cpu, &rflow->last_qtail);
rcu_read_unlock();
+ preempt_enable();
}
#else
{
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] net: disable preemption before call smp_processor_id()
2010-08-07 9:26 [PATCH] net: disable preemption before call smp_processor_id() Changli Gao
@ 2010-08-08 3:37 ` David Miller
2010-08-08 4:57 ` Paul E. McKenney
0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2010-08-08 3:37 UTC (permalink / raw)
To: xiaosuo; +Cc: paulmck, therbert, netdev
From: Changli Gao <xiaosuo@gmail.com>
Date: Sat, 7 Aug 2010 17:26:02 +0800
> Although netif_rx() isn't expected to be called in process context with
> preemption enabled, it'd better handle this case. And this is why get_cpu()
> is used in the non-RPS #ifdef branch. If tree RCU is selected,
> rcu_read_lock() won't disable preemption, so preempt_disable() should be
> called explictly.
>
> Signed-off-by: Changli Gao <xiaosuo@gmail.com>
Applied, thanks Changli.
Paul, perhaps the comment above rcu_read_lock()'s definition should
be updated in rcupdate.h? It says blocking is not allowed inside
of a read side critical section, but obviously with tree-rcu that
is not the case.
Either we should add a mention of tree-rcu's semantics or just remote
this part of the comment altogether.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net: disable preemption before call smp_processor_id()
2010-08-08 3:37 ` David Miller
@ 2010-08-08 4:57 ` Paul E. McKenney
2010-08-08 5:25 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: Paul E. McKenney @ 2010-08-08 4:57 UTC (permalink / raw)
To: David Miller; +Cc: xiaosuo, therbert, netdev
On Sat, Aug 07, 2010 at 08:37:00PM -0700, David Miller wrote:
> From: Changli Gao <xiaosuo@gmail.com>
> Date: Sat, 7 Aug 2010 17:26:02 +0800
>
> > Although netif_rx() isn't expected to be called in process context with
> > preemption enabled, it'd better handle this case. And this is why get_cpu()
> > is used in the non-RPS #ifdef branch. If tree RCU is selected,
> > rcu_read_lock() won't disable preemption, so preempt_disable() should be
> > called explictly.
> >
> > Signed-off-by: Changli Gao <xiaosuo@gmail.com>
>
> Applied, thanks Changli.
>
> Paul, perhaps the comment above rcu_read_lock()'s definition should
> be updated in rcupdate.h? It says blocking is not allowed inside
> of a read side critical section, but obviously with tree-rcu that
> is not the case.
>
> Either we should add a mention of tree-rcu's semantics or just remote
> this part of the comment altogether.
Good point, that last sentence is quite obsolete. It also survived a
recent cleanup. :-/
If I cover preemptible RCU's semantics, a first cut comes out like this:
* In non-preemptible RCU implementations (TREE_RCU and TINY_RCU), it
* is illegal to block while in an RCU read-side critical section. In
* preemptible RCU implementations (TREE_PREEMPT_RCU and TINY_PREEMPT_RCU)
* in CONFIG_PREEMPT kernel builds, RCU read-side critical sections may
* be preempted, but explicit blocking is illegal. Finally, in preemptible
* RCU implementations in real-time (CONFIG_PREEMPT_RT) kernel builds,
* RCU read-side critical sections may be preempted and they may also
* block, but only when acquiring spinlocks that are subject to priority
* inheritance.
Does that seem reasonable?
Thanx, Paul
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net: disable preemption before call smp_processor_id()
2010-08-08 4:57 ` Paul E. McKenney
@ 2010-08-08 5:25 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2010-08-08 5:25 UTC (permalink / raw)
To: paulmck; +Cc: xiaosuo, therbert, netdev
From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Date: Sat, 7 Aug 2010 21:57:51 -0700
> If I cover preemptible RCU's semantics, a first cut comes out like this:
>
> * In non-preemptible RCU implementations (TREE_RCU and TINY_RCU), it
> * is illegal to block while in an RCU read-side critical section. In
> * preemptible RCU implementations (TREE_PREEMPT_RCU and TINY_PREEMPT_RCU)
> * in CONFIG_PREEMPT kernel builds, RCU read-side critical sections may
> * be preempted, but explicit blocking is illegal. Finally, in preemptible
> * RCU implementations in real-time (CONFIG_PREEMPT_RT) kernel builds,
> * RCU read-side critical sections may be preempted and they may also
> * block, but only when acquiring spinlocks that are subject to priority
> * inheritance.
>
> Does that seem reasonable?
Sounds good to me.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-08-08 5:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-07 9:26 [PATCH] net: disable preemption before call smp_processor_id() Changli Gao
2010-08-08 3:37 ` David Miller
2010-08-08 4:57 ` Paul E. McKenney
2010-08-08 5:25 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.