Skip to content

Commit cece194

Browse files
xiaosuodavem330
authored andcommitted
net: disable preemption before call smp_processor_id()
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ba78e2d commit cece194

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

net/core/dev.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2517,6 +2517,7 @@ int netif_rx(struct sk_buff *skb)
25172517
struct rps_dev_flow voidflow, *rflow = &voidflow;
25182518
int cpu;
25192519

2520+
preempt_disable();
25202521
rcu_read_lock();
25212522

25222523
cpu = get_rps_cpu(skb->dev, skb, &rflow);
@@ -2526,6 +2527,7 @@ int netif_rx(struct sk_buff *skb)
25262527
ret = enqueue_to_backlog(skb, cpu, &rflow->last_qtail);
25272528

25282529
rcu_read_unlock();
2530+
preempt_enable();
25292531
}
25302532
#else
25312533
{

0 commit comments

Comments
 (0)