All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tom Herbert <tom@herbertland.com>
To: netdev@vger.kernel.org
Cc: Tom Herbert <tom@herbertland.com>
Subject: [RFC PATCH 03/11] arfs: Create set_arfs_queue
Date: Wed, 24 Jun 2020 10:17:42 -0700	[thread overview]
Message-ID: <20200624171749.11927-4-tom@herbertland.com> (raw)
In-Reply-To: <20200624171749.11927-1-tom@herbertland.com>

Abstract out the code for steering a flow to an aRFS queue (via
ndo_rx_flow_steer) into its own function. This allows the function to
be called in other use cases.
---
 net/core/dev.c | 67 +++++++++++++++++++++++++++++---------------------
 1 file changed, 39 insertions(+), 28 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index 6bc2388141f6..9f7a3e78e23a 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4250,42 +4250,53 @@ EXPORT_SYMBOL(rps_needed);
 struct static_key_false rfs_needed __read_mostly;
 EXPORT_SYMBOL(rfs_needed);
 
+#ifdef CONFIG_RFS_ACCEL
+static void set_arfs_queue(struct net_device *dev, struct sk_buff *skb,
+			   struct rps_dev_flow *rflow, u16 rxq_index)
+{
+	struct rps_dev_flow_table *flow_table;
+	struct netdev_rx_queue *rxqueue;
+	struct rps_dev_flow *old_rflow;
+	u32 flow_id;
+	int rc;
+
+	rxqueue = dev->_rx + rxq_index;
+
+	flow_table = rcu_dereference(rxqueue->rps_flow_table);
+	if (!flow_table)
+		return;
+
+	flow_id = skb_get_hash(skb) & flow_table->mask;
+	rc = dev->netdev_ops->ndo_rx_flow_steer(dev, skb,
+						rxq_index, flow_id);
+	if (rc < 0)
+		return;
+
+	old_rflow = rflow;
+	rflow = &flow_table->flows[flow_id];
+	rflow->filter = rc;
+	if (old_rflow->filter == rflow->filter)
+		old_rflow->filter = RPS_NO_FILTER;
+}
+#endif
+
 static struct rps_dev_flow *
 set_rps_cpu(struct net_device *dev, struct sk_buff *skb,
 	    struct rps_dev_flow *rflow, u16 next_cpu)
 {
 	if (next_cpu < nr_cpu_ids) {
 #ifdef CONFIG_RFS_ACCEL
-		struct netdev_rx_queue *rxqueue;
-		struct rps_dev_flow_table *flow_table;
-		struct rps_dev_flow *old_rflow;
-		u32 flow_id;
-		u16 rxq_index;
-		int rc;
 
 		/* Should we steer this flow to a different hardware queue? */
-		if (!skb_rx_queue_recorded(skb) || !dev->rx_cpu_rmap ||
-		    !(dev->features & NETIF_F_NTUPLE))
-			goto out;
-		rxq_index = cpu_rmap_lookup_index(dev->rx_cpu_rmap, next_cpu);
-		if (rxq_index == skb_get_rx_queue(skb))
-			goto out;
-
-		rxqueue = dev->_rx + rxq_index;
-		flow_table = rcu_dereference(rxqueue->rps_flow_table);
-		if (!flow_table)
-			goto out;
-		flow_id = skb_get_hash(skb) & flow_table->mask;
-		rc = dev->netdev_ops->ndo_rx_flow_steer(dev, skb,
-							rxq_index, flow_id);
-		if (rc < 0)
-			goto out;
-		old_rflow = rflow;
-		rflow = &flow_table->flows[flow_id];
-		rflow->filter = rc;
-		if (old_rflow->filter == rflow->filter)
-			old_rflow->filter = RPS_NO_FILTER;
-	out:
+		if (skb_rx_queue_recorded(skb) && dev->rx_cpu_rmap &&
+		    (dev->features & NETIF_F_NTUPLE)) {
+			u16 rxq_index;
+
+			rxq_index = cpu_rmap_lookup_index(dev->rx_cpu_rmap,
+							  next_cpu);
+			if (rxq_index != skb_get_rx_queue(skb))
+				set_arfs_queue(dev, skb, rflow, rxq_index);
+		}
 #endif
 		rflow->last_qtail =
 			per_cpu(softnet_data, next_cpu).input_queue_head;
-- 
2.25.1


  parent reply	other threads:[~2020-06-24 17:19 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-24 17:17 [RFC PATCH 00/11] ptq: Per Thread Queues Tom Herbert
2020-06-24 17:17 ` [RFC PATCH 01/11] cgroup: Export cgroup_{procs,threads}_start and cgroup_procs_next Tom Herbert
2020-06-24 17:17 ` [RFC PATCH 02/11] net: Create netqueue.h and define NO_QUEUE Tom Herbert
2020-06-24 17:17 ` Tom Herbert [this message]
2020-06-24 17:17 ` [RFC PATCH 04/11] net-sysfs: Create rps_create_sock_flow_table Tom Herbert
2020-06-24 17:17 ` [RFC PATCH 05/11] net: Infrastructure for per queue aRFS Tom Herbert
2020-06-28  8:55   ` kernel test robot
2020-06-24 17:17 ` [RFC PATCH 06/11] net: Function to check against maximum number for RPS queues Tom Herbert
2020-06-24 17:17 ` [RFC PATCH 07/11] net: Introduce global queues Tom Herbert
2020-06-24 23:00   ` kernel test robot
2020-06-24 23:58   ` kernel test robot
2020-06-25  0:23   ` kernel test robot
2020-06-30 21:06   ` Jonathan Lemon
2020-06-24 17:17 ` [RFC PATCH 08/11] ptq: Per Thread Queues Tom Herbert
2020-06-24 21:20   ` kernel test robot
2020-06-25  1:50   ` [RFC PATCH] ptq: null_pcdesc can be static kernel test robot
2020-06-25  7:26   ` [RFC PATCH 08/11] ptq: Per Thread Queues kernel test robot
2020-06-24 17:17 ` [RFC PATCH 09/11] ptq: Hook up transmit side of Per Queue Threads Tom Herbert
2020-06-24 17:17 ` [RFC PATCH 10/11] ptq: Hook up receive " Tom Herbert
2020-06-24 17:17 ` [RFC PATCH 11/11] doc: Documentation for Per Thread Queues Tom Herbert
2020-06-25  2:20   ` kernel test robot
2020-06-25 23:00   ` Jacob Keller
2020-06-29  6:28   ` Saeed Mahameed
2020-06-29 15:10     ` Tom Herbert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200624171749.11927-4-tom@herbertland.com \
    --to=tom@herbertland.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.