From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Thu, 6 May 2010 23:51:21 +0000 (+0000)
Subject: rps: avoid one atomic in enqueue_to_backlog
X-Git-Tag: firefly_0821_release~9833^2~2087^2~82
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ebda37c27d0c768947e9b058332d7ea798210cf8;p=firefly-linux-kernel-4.4.55.git

rps: avoid one atomic in enqueue_to_backlog

If CONFIG_SMP=y, then we own a queue spinlock, we can avoid the atomic
test_and_set_bit() from napi_schedule_prep().

We now have same number of atomic ops per netif_rx() calls than with
pre-RPS kernel.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
---

diff --git a/net/core/dev.c b/net/core/dev.c
index 988e42912e72..cdcb9cbedf41 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2432,8 +2432,10 @@ enqueue:
 			return NET_RX_SUCCESS;
 		}
 
-		/* Schedule NAPI for backlog device */
-		if (napi_schedule_prep(&sd->backlog)) {
+		/* Schedule NAPI for backlog device
+		 * We can use non atomic operation since we own the queue lock
+		 */
+		if (!__test_and_set_bit(NAPI_STATE_SCHED, &sd->backlog.state)) {
 			if (!rps_ipi_queued(sd))
 				____napi_schedule(sd, &sd->backlog);
 		}