Commit 9e4cc1ed83e5459a43085e0cab26aa269bb2dfb3

Authored by Eric Dumazet
Committed by Greg Kroah-Hartman
1 parent 8e9f6bdb35

net: rps: fix cpu unplug

[ Upstream commit ac64da0b83d82abe62f78b3d0e21cca31aea24fa ]

softnet_data.input_pkt_queue is protected by a spinlock that
we must hold when transferring packets from victim queue to an active
one. This is because other cpus could still be trying to enqueue packets
into victim queue.

A second problem is that when we transfert the NAPI poll_list from
victim to current cpu, we absolutely need to special case the percpu
backlog, because we do not want to add complex locking to protect
process_queue : Only owner cpu is allowed to manipulate it, unless cpu
is offline.

Based on initial patch from Prasad Sodagudi & Subash Abhinov
Kasiviswanathan.

This version is better because we do not slow down packet processing,
only make migration safer.

Reported-by: Prasad Sodagudi <psodagud@codeaurora.org>
Reported-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Tom Herbert <therbert@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Showing 1 changed file with 15 additions and 5 deletions Side-by-side Diff

... ... @@ -6990,10 +6990,20 @@
6990 6990 oldsd->output_queue = NULL;
6991 6991 oldsd->output_queue_tailp = &oldsd->output_queue;
6992 6992 }
6993   - /* Append NAPI poll list from offline CPU. */
6994   - if (!list_empty(&oldsd->poll_list)) {
6995   - list_splice_init(&oldsd->poll_list, &sd->poll_list);
6996   - raise_softirq_irqoff(NET_RX_SOFTIRQ);
  6993 + /* Append NAPI poll list from offline CPU, with one exception :
  6994 + * process_backlog() must be called by cpu owning percpu backlog.
  6995 + * We properly handle process_queue & input_pkt_queue later.
  6996 + */
  6997 + while (!list_empty(&oldsd->poll_list)) {
  6998 + struct napi_struct *napi = list_first_entry(&oldsd->poll_list,
  6999 + struct napi_struct,
  7000 + poll_list);
  7001 +
  7002 + list_del_init(&napi->poll_list);
  7003 + if (napi->poll == process_backlog)
  7004 + napi->state = 0;
  7005 + else
  7006 + ____napi_schedule(sd, napi);
6997 7007 }
6998 7008  
6999 7009 raise_softirq_irqoff(NET_TX_SOFTIRQ);
... ... @@ -7004,7 +7014,7 @@
7004 7014 netif_rx_internal(skb);
7005 7015 input_queue_head_incr(oldsd);
7006 7016 }
7007   - while ((skb = __skb_dequeue(&oldsd->input_pkt_queue))) {
  7017 + while ((skb = skb_dequeue(&oldsd->input_pkt_queue))) {
7008 7018 netif_rx_internal(skb);
7009 7019 input_queue_head_incr(oldsd);
7010 7020 }