Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1740494
| From | Jason Wang <jasowang@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH net-next 3/3] tun: introduce cpu id based steering policy |
| Date | 2017-09-27 10:30 +0200 |
| Message-ID | <uufTd-8kl-29@gated-at.bofh.it> (permalink) |
| References | <uufTb-8kl-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
This patch introduces a simple queue selection policy which just
choose txq based on processor id. This maybe useful for connectless
workload or #queues is equal to #cpus.
Redirect UDP packets generated by MoonGen between two virtio-net ports
through xdp_redirect show 37.4% (from 0.8Mpps to 1.1Mpps) improvement
compared to automatic steering policy since the overhead of flow
caches/hasing was totally eliminated.
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
drivers/net/tun.c | 33 ++++++++++++++++++++++++++++++++-
include/uapi/linux/if_tun.h | 1 +
2 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 1106521..03b4506 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -190,6 +190,20 @@ struct tun_steering_ops {
u32 data);
};
+void tun_steering_xmit_nop(struct tun_struct *tun, struct sk_buff *skb)
+{
+}
+
+u32 tun_steering_pre_rx_nop(struct tun_struct *tun, struct sk_buff *skb)
+{
+ return 0;
+}
+
+void tun_steering_post_rx_nop(struct tun_struct *tun, struct tun_file *tfile,
+ u32 data)
+{
+}
+
struct tun_flow_entry {
struct hlist_node hash_link;
struct rcu_head rcu;
@@ -571,6 +585,11 @@ static u16 tun_automq_select_queue(struct tun_struct *tun, struct sk_buff *skb)
return txq;
}
+static u16 tun_cpu_select_queue(struct tun_struct *tun, struct sk_buff *skb)
+{
+ return smp_processor_id() % tun->numqueues;
+}
+
static u16 tun_select_queue(struct net_device *dev, struct sk_buff *skb,
void *accel_priv, select_queue_fallback_t fallback)
{
@@ -2152,6 +2171,13 @@ static struct tun_steering_ops tun_automq_ops = {
.post_rx = tun_automq_post_rx,
};
+static struct tun_steering_ops tun_cpu_ops = {
+ .select_queue = tun_cpu_select_queue,
+ .xmit = tun_steering_xmit_nop,
+ .pre_rx = tun_steering_pre_rx_nop,
+ .post_rx = tun_steering_post_rx_nop,
+};
+
static int tun_flags(struct tun_struct *tun)
{
return tun->flags & (TUN_FEATURES | IFF_PERSIST | IFF_TUN | IFF_TAP);
@@ -2775,6 +2801,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
case TUN_STEERING_AUTOMQ:
tun->steering_ops = &tun_automq_ops;
break;
+ case TUN_STEERING_CPU:
+ tun->steering_ops = &tun_cpu_ops;
+ break;
default:
ret = -EFAULT;
}
@@ -2784,6 +2813,8 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
ret = 0;
if (tun->steering_ops == &tun_automq_ops)
steering = TUN_STEERING_AUTOMQ;
+ else if (tun->steering_ops == &tun_cpu_ops)
+ steering = TUN_STEERING_CPU;
else
BUG();
if (copy_to_user(argp, &steering, sizeof(steering)))
@@ -2792,7 +2823,7 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
case TUNGETSTEERINGFEATURES:
ret = 0;
- steering = TUN_STEERING_AUTOMQ;
+ steering = TUN_STEERING_AUTOMQ | TUN_STEERING_CPU;
if (copy_to_user(argp, &steering, sizeof(steering)))
ret = -EFAULT;
break;
diff --git a/include/uapi/linux/if_tun.h b/include/uapi/linux/if_tun.h
index 109760e..5f71d29 100644
--- a/include/uapi/linux/if_tun.h
+++ b/include/uapi/linux/if_tun.h
@@ -112,5 +112,6 @@ struct tun_filter {
};
#define TUN_STEERING_AUTOMQ 0x01 /* Automatic flow steering */
+#define TUN_STEERING_CPU 0x02 /* Processor id based flow steering */
#endif /* _UAPI__IF_TUN_H */
--
2.7.4
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH net-next 0/3] support changing steering policies in tuntap Jason Wang <jasowang@redhat.com> - 2017-09-27 10:30 +0200
[PATCH net-next 3/3] tun: introduce cpu id based steering policy Jason Wang <jasowang@redhat.com> - 2017-09-27 10:30 +0200
Re: [PATCH net-next 0/3] support changing steering policies in tuntap "Michael S. Tsirkin" <mst@redhat.com> - 2017-09-28 00:20 +0200
Re: [PATCH net-next 0/3] support changing steering policies in tuntap Willem de Bruijn <willemdebruijn.kernel@gmail.com> - 2017-09-28 01:30 +0200
Re: [PATCH net-next 0/3] support changing steering policies in tuntap Tom Herbert <tom@herbertland.com> - 2017-09-28 07:10 +0200
Re: [PATCH net-next 0/3] support changing steering policies in tuntap Jason Wang <jasowang@redhat.com> - 2017-09-28 10:00 +0200
Re: [PATCH net-next 0/3] support changing steering policies in tuntap Jason Wang <jasowang@redhat.com> - 2017-09-28 09:30 +0200
Re: [PATCH net-next 0/3] support changing steering policies in tuntap Willem de Bruijn <willemdebruijn.kernel@gmail.com> - 2017-09-28 18:10 +0200
Re: [PATCH net-next 0/3] support changing steering policies in tuntap Jason Wang <jasowang@redhat.com> - 2017-09-29 11:50 +0200
Re: [PATCH net-next 0/3] support changing steering policies in tuntap "Michael S. Tsirkin" <mst@redhat.com> - 2017-10-01 05:30 +0200
Re: [PATCH net-next 0/3] support changing steering policies in tuntap Jason Wang <jasowang@redhat.com> - 2017-09-28 09:00 +0200
csiph-web