From: Amritha Nambiar <amritha.nambiar@intel.com>
To: netdev@vger.kernel.org, davem@davemloft.net
Cc: alexander.h.duyck@intel.com, willemdebruijn.kernel@gmail.com,
amritha.nambiar@intel.com, sridhar.samudrala@intel.com,
alexander.duyck@gmail.com, edumazet@google.com,
hannes@stressinduktion.org, tom@herbertland.com
Subject: [net-next PATCH v4 5/7] net: Enable Tx queue selection based on Rx queues
Date: Mon, 25 Jun 2018 11:04:40 -0700 [thread overview]
Message-ID: <152994988080.9733.10385317895413246222.stgit@anamhost.jf.intel.com> (raw)
In-Reply-To: <152994950582.9733.3330634251364177102.stgit@anamhost.jf.intel.com>
This patch adds support to pick Tx queue based on the Rx queue(s) map
configuration set by the admin through the sysfs attribute
for each Tx queue. If the user configuration for receive queue(s) map
does not apply, then the Tx queue selection falls back to CPU(s) map
based selection and finally to hashing.
Signed-off-by: Amritha Nambiar <amritha.nambiar@intel.com>
---
include/net/sock.h | 4 +++
net/core/dev.c | 62 ++++++++++++++++++++++++++++++++++++++--------------
2 files changed, 49 insertions(+), 17 deletions(-)
diff --git a/include/net/sock.h b/include/net/sock.h
index 0ff4416..cb18139 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1710,6 +1710,10 @@ static inline void sk_rx_queue_set(struct sock *sk, const struct sk_buff *skb)
#endif
}
+static inline int sk_rx_queue_get(const struct sock *sk)
+{
+ return sk ? sk->sk_rx_queue_mapping - 1 : -1;
+}
static inline void sk_set_socket(struct sock *sk, struct socket *sock)
{
sk_tx_queue_clear(sk);
diff --git a/net/core/dev.c b/net/core/dev.c
index df2a78d..2450c5e 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3454,35 +3454,63 @@ sch_handle_egress(struct sk_buff *skb, int *ret, struct net_device *dev)
}
#endif /* CONFIG_NET_EGRESS */
-static inline int get_xps_queue(struct net_device *dev, struct sk_buff *skb)
+#ifdef CONFIG_XPS
+static int __get_xps_queue_idx(struct net_device *dev, struct sk_buff *skb,
+ struct xps_dev_maps *dev_maps, unsigned int tci)
+{
+ struct xps_map *map;
+ int queue_index = -1;
+
+ if (dev->num_tc) {
+ tci *= dev->num_tc;
+ tci += netdev_get_prio_tc_map(dev, skb->priority);
+ }
+
+ map = rcu_dereference(dev_maps->attr_map[tci]);
+ if (map) {
+ if (map->len == 1)
+ queue_index = map->queues[0];
+ else
+ queue_index = map->queues[reciprocal_scale(
+ skb_get_hash(skb), map->len)];
+ if (unlikely(queue_index >= dev->real_num_tx_queues))
+ queue_index = -1;
+ }
+ return queue_index;
+}
+#endif
+
+static int get_xps_queue(struct net_device *dev, struct sk_buff *skb)
{
#ifdef CONFIG_XPS
struct xps_dev_maps *dev_maps;
- struct xps_map *map;
+ struct sock *sk = skb->sk;
int queue_index = -1;
if (!static_key_false(&xps_needed))
return -1;
rcu_read_lock();
- dev_maps = rcu_dereference(dev->xps_cpus_map);
+ if (!static_key_false(&xps_rxqs_needed))
+ goto get_cpus_map;
+
+ dev_maps = rcu_dereference(dev->xps_rxqs_map);
if (dev_maps) {
- unsigned int tci = skb->sender_cpu - 1;
+ int tci = sk_rx_queue_get(sk);
- if (dev->num_tc) {
- tci *= dev->num_tc;
- tci += netdev_get_prio_tc_map(dev, skb->priority);
- }
+ if (tci >= 0 && tci < dev->num_rx_queues)
+ queue_index = __get_xps_queue_idx(dev, skb, dev_maps,
+ tci);
+ }
- map = rcu_dereference(dev_maps->attr_map[tci]);
- if (map) {
- if (map->len == 1)
- queue_index = map->queues[0];
- else
- queue_index = map->queues[reciprocal_scale(skb_get_hash(skb),
- map->len)];
- if (unlikely(queue_index >= dev->real_num_tx_queues))
- queue_index = -1;
+get_cpus_map:
+ if (queue_index < 0) {
+ dev_maps = rcu_dereference(dev->xps_cpus_map);
+ if (dev_maps) {
+ unsigned int tci = skb->sender_cpu - 1;
+
+ queue_index = __get_xps_queue_idx(dev, skb, dev_maps,
+ tci);
}
}
rcu_read_unlock();
next prev parent reply other threads:[~2018-06-25 23:06 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-25 18:04 [net-next PATCH v4 0/7] Symmetric queue selection using XPS for Rx queues Amritha Nambiar
2018-06-25 18:04 ` [net-next PATCH v4 1/7] net: Refactor XPS for CPUs and " Amritha Nambiar
2018-06-26 22:53 ` Tom Herbert
2018-06-28 0:47 ` Nambiar, Amritha
2018-06-25 18:04 ` [net-next PATCH v4 2/7] net: Use static_key for XPS maps Amritha Nambiar
2018-06-26 22:54 ` Tom Herbert
2018-06-25 18:04 ` [net-next PATCH v4 3/7] net: sock: Change tx_queue_mapping in sock_common to unsigned short Amritha Nambiar
[not found] ` <CALx6S37uFs1shuPmno+L=p_Hyy1Q2qNaK+AqYvrk4HXTApL_Vg@mail.gmail.com>
2018-06-26 3:25 ` Alexander Duyck
2018-06-26 23:54 ` Nambiar, Amritha
2018-06-26 10:58 ` Willem de Bruijn
2018-06-27 0:00 ` Nambiar, Amritha
2018-06-25 18:04 ` [net-next PATCH v4 4/7] net: Record receive queue number for a connection Amritha Nambiar
2018-06-25 18:04 ` Amritha Nambiar [this message]
2018-06-26 2:04 ` [net-next PATCH v4 5/7] net: Enable Tx queue selection based on Rx queues kbuild test robot
2018-06-26 11:04 ` Willem de Bruijn
2018-06-27 0:36 ` Nambiar, Amritha
2018-06-27 10:47 ` Willem de Bruijn
2018-06-28 0:48 ` Nambiar, Amritha
2018-06-25 18:04 ` [net-next PATCH v4 6/7] net-sysfs: Add interface for Rx queue(s) map per Tx queue Amritha Nambiar
2018-06-26 10:55 ` Willem de Bruijn
2018-06-27 0:21 ` Nambiar, Amritha
2018-06-25 18:04 ` [net-next PATCH v4 7/7] Documentation: Add explanation for XPS using Rx-queue(s) map Amritha Nambiar
2018-06-26 22:59 ` 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=152994988080.9733.10385317895413246222.stgit@anamhost.jf.intel.com \
--to=amritha.nambiar@intel.com \
--cc=alexander.duyck@gmail.com \
--cc=alexander.h.duyck@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hannes@stressinduktion.org \
--cc=netdev@vger.kernel.org \
--cc=sridhar.samudrala@intel.com \
--cc=tom@herbertland.com \
--cc=willemdebruijn.kernel@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox