net: low latency Ethernet device polling
Subsystems (7)
v10 cover net: low latency Ethernet device polling
David,
I removed the select/poll patch (was 5/7 in v9) from the set. The rest are the same patches that were in v9.
Please consider applying.
Thanks to everyone for their input.
-Eliezer
Change log:
v10
- removed select/poll support. (we will work on this some more and try again) v9
- correct sysctl proc_handler, reported by Eric Dumazet and Amir Vadai.
- more int -> bool changes, reported by Eric Dumazet.
- better mask testing in sock_poll(), reported by Eric Dumazet.
v8
- split out udp and select/poll into separate patches. what used to be patch 2/5 is now three patches.
- type corrections from Amir Vadai and Cong Wang:
one unsigned long that was left when changing to cycles_t int -> bool
- more detailed patch descriptions.
v7
- suggested by Ben Hutchings and Eric Dumazet:
type fixes, static for globals in net/core.c,
avoid napi_id collisions in napi_hash_add()
v6
- many small fixes suggested by Eric Dumazet:
data locality, typos, documentation
protect napi_hash insert/delete with a spinlock (napi_gen_id is no longer atomic_t since it's only accessed with the spinlock held.)
- added IPv6 TCP and UDP support (only minimally tested)
v5
- corrections suggested by Ben Hutchings:
fixed typos, moved the config option and sysctl value from IPv4 to net
- moved sk_mark_ll() to the protocol handlers
- removed global id mechanism, replaced with a hashed napi_id. based on code sample from Eric Dumazet
Note that ixgbe_free_q_vector() already waits an rcu grace period before freeing the q_vector, so nothing additional needs to be done when adding a call to napi_hash_del().
- simple poll/select support
v4
- removed separate config option for TCP as suggested Eric Dumazet.
- added linux mib counter for packets received through the low latency path, as suggested by Andi Kleen.
- re-allow module unloading, remove module param, use a global generation id instead to prevent the use of a stale napi pointer, as suggested by Eric Dumazet
- updated Documentation/networking/ip-sysctl.txt text
v3
- coding style changes suggested by Dave Miller
v2
- the sysctl knob is now in microseconds. The default value is now 0 (off).
- for now the code depends at configure time on CONFIG_I86_TSC
- the napi reference in struct skb is now a union with the dma cookie since the former is only used on RX and the latter on TX,
as suggested by Eric Dumazet.
- we do a better job at honoring non-blocking operations.
- removed busy-polling support for tcp_read_sock()
- remove dynamic disabling of GRO
- coding style fixes
- disallow unloading the device module after the feature has been used
Credit:
Jesse Brandeburg, Arun Chekhov Ilango, Julie Cummings, Alexander Duyck, Eric Geisler, Jason Neighbors, Yadong Li, Mike Polehn, Anil Vasudevan, Don Wood
Special thanks for finding bugs in earlier versions:
Willem de Bruijn and Andi Kleen
PATCH v10 1/6 net: add napi_id and hash
Adds a napi_id and a hashing mechanism to lookup a napi by id. This will be used by subsequent patches to implement low latency Ethernet device polling.
Based on a code sample by Eric Dumazet.
---
include/linux/netdevice.h | 29 ++++++++++++++++++++++ net/core/dev.c | 59 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 0 deletions(-)
include/linux/netdevice.h +29 -0
@@ -324,12 +324,15 @@ struct napi_struct {struct sk_buff *gro_list;struct sk_buff *skb;struct list_head dev_list; +struct hlist_node napi_hash_node; +unsigned int napi_id; };enum {NAPI_STATE_SCHED ,/* Poll is scheduled */ NAPI_STATE_DISABLE ,/* Disable pending */ NAPI_STATE_NPSVC ,/* Netpoll - don't dequeue from poll_list */ +NAPI_STATE_HASHED ,/* In NAPI hash */ };enum gro_result {
@@ -446,6 +449,32 @@ extern void __napi_complete(struct napi_struct *n);extern void napi_complete (struct napi_struct *n);/** +* napi_by_id - lookup a NAPI by napi_id +* @napi_id: hashed napi_id +* +* lookup @napi_id in napi_hash table +* must be called under rcu_read_lock() +*/ +extern struct napi_struct *napi_by_id (unsigned int napi_id); + +/** +* napi_hash_add - add a NAPI to global hashtable +* @napi: napi context +* +* generate a new napi_id and store a @napi under it in napi_hash +*/ +extern void napi_hash_add (struct napi_struct *napi); + +/** +* napi_hash_del - remove a NAPI from global table +* @napi: napi context +* +* Warning: caller must observe rcu grace period +* before freeing memory containing @napi +*/ +extern void napi_hash_del (struct napi_struct *napi); + +/** * napi_disable - prevent NAPI from scheduling * @n: napi context *
net/core/dev.c +59 -0
77 lines not on this page · raw message
------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
_______________________________________________
E1000-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel® Ethernet, visit http://communities.intel.com/community/wired
Re: [PATCH v10 net-next 1/6] net: add napi_id and hash
Quoted 11 lines · Eliezer Tamir
Adds a
napi_idand a hashing mechanism to lookup a napi by id. This will be used by subsequent patches to implement low latency Ethernet device polling.
Based on a code sample by Eric Dumazet.Signed-off-by Eliezer Tamir <[email protected]>---
include/linux/netdevice.h | 29 ++++++++++++++++++++++ net/core/dev.c | 59 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 0 deletions(-)
------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
_______________________________________________
E1000-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel® Ethernet, visit http://communities.intel.com/community/wired
Re: [PATCH v10 net-next 1/6] net: add napi_id and hash
Quoted 6 lines · Eric Dumazet
Quoted 5 lines · Eliezer Tamir
Adds a
napi_idand a hashing mechanism to lookup a napi by id. This will be used by subsequent patches to implement low latency Ethernet device polling.
Based on a code sample by Eric Dumazet.
Quoted 9 lines
Quoted 6 lines
Signed-off-by Eliezer Tamir <[email protected]>---
include/linux/netdevice.h | 29 ++++++++++++++++++++++ net/core/dev.c | 59 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 0 deletions(-)Signed-off-by Eric Dumazet <[email protected]>
(per Eliezer's request)
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
E1000-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel® Ethernet, visit http://communities.intel.com/community/wired
PATCH v10 2/6 net: add low latency socket poll
In reply to Eliezer TamirAdds an ndo_ll_poll method and the code that supports it. This method can be used by low latency applications to busy-poll Ethernet device queues directly from the socket code. sysctl_net_ll_poll controls how many microseconds to poll. Default is zero (disabled).
Individual protocol support will be added by subsequent patches.
---
Documentation/sysctl/net.txt | 7 ++ include/linux/netdevice.h | 3 + include/linux/skbuff.h | 8 ++ include/net/ll_poll.h | 148 ++++++++++++++++++++++++++++++++++++++++++ include/net/sock.h | 4 + include/uapi/linux/snmp.h | 1 net/Kconfig | 12 +++ net/core/skbuff.c | 4 + net/core/sock.c | 6 ++ net/core/sysctl_net_core.c | 10 +++ net/ipv4/proc.c | 1 net/socket.c | 6 ++ 12 files changed, 208 insertions(+), 2 deletions(-) create mode 100644 include/net/ll_poll.h
Documentation/sysctl/net.txt +7 -0
@@ -50,6 +50,13 @@ The maximum number of packets that kernel can handle on a NAPI interrupt, it's a Per-CPU variable. Default: 64 +low_latency_poll +---------------- +Low latency busy poll timeout. (needs CONFIG_NET_LL_RX_POLL) +Approximate time in us to spin waiting for packets on the device queue. +Recommended value is 50. May increase power usage. +Default: 0 (off) + rmem_default ------------
include/linux/netdevice.h +3 -0
@@ -972,6 +972,9 @@ struct net_device_ops { gfp_t gfp);void (*ndo_netpoll_cleanup)(struct net_device *dev);#endif +#ifdef CONFIG_NET_LL_RX_POLL +int (*ndo_ll_poll)(struct napi_struct *dev); +#endif int (*ndo_set_vf_mac)(struct net_device *dev,int queue,u8 *mac); int (*ndo_set_vf_vlan)(struct net_device *dev,
include/linux/skbuff.h +6 -2
@@ -386,6 +386,7 @@ typedef unsigned char *sk_buff_data_t;* @no_fcs: Request NIC to treat last 4 bytes as Ethernet FCS * @dma_cookie: a cookie to one of several possible DMA operations * done by skb DMA functions +* @napi_id: id of the NAPI struct this skb came from * @secmark: security marking * @mark: Generic packet mark * @dropcount: total number of sk_receive_queue overflows
@@ -500,8 +501,11 @@ struct sk_buff {/* 7/9 bit hole (depending on ndisc_nodetype presence) */ kmemcheck_bitfield_end (flags2); -#ifdef CONFIG_NET_DMA -dma_cookie_t dma_cookie; +#if definedCONFIG_NET_DMA || definedCONFIG_NET_LL_RX_POLL +union { +unsigned int napi_id; +dma_cookie_t dma_cookie; + };#endif #ifdef CONFIG_NETWORK_SECMARK __u32 secmark;
include/net/ll_poll.h new file +148 -0
148 lines not on this page · raw message
include/net/sock.h +4 -0
@@ -229,6 +229,7 @@ struct cg_proto;* @sk_omem_alloc: "o" is "option" or "other" * @sk_wmem_queued: persistent queue size * @sk_forward_alloc: space allocated forward +* @sk_napi_id: id of the last napi context to receive data for sk * @sk_allocation: allocation mode * @sk_sndbuf: size of send buffer in bytes * @sk_flags: %SO_LINGER (l_onoff), %SO_BROADCAST, %SO_KEEPALIVE,
@@ -325,6 +326,9 @@ struct sock {#ifdef CONFIG_RPS __u32 sk_rxhash;#endif +#ifdef CONFIG_NET_LL_RX_POLL +unsigned int sk_napi_id; +#endif atomic_t sk_drops;int sk_rcvbuf;
include/uapi/linux/snmp.h +1 -0
@@ -253,6 +253,7 @@ enumLINUX_MIB_TCPFASTOPENLISTENOVERFLOW ,/* TCPFastOpenListenOverflow */ LINUX_MIB_TCPFASTOPENCOOKIEREQD ,/* TCPFastOpenCookieReqd */ LINUX_MIB_TCPSPURIOUS_RTX_HOSTQUEUES ,/* TCPSpuriousRtxHostQueues */ +LINUX_MIB_LOWLATENCYRXPACKETS ,/* LowLatencyRxPackets */ __LINUX_MIB_MAX };
net/Kconfig +12 -0
@@ -243,6 +243,18 @@ config NETPRIO_CGROUP Cgroup subsystem for use in assigning processes to network priorities on a per-interface basis +config NET_LL_RX_POLL + bool "Low Latency Receive Poll" + depends on X86_TSC + default n + ---help--- + Support Low Latency Receive Queue Poll. + (For network card drivers which support this option.) + When waiting for data in read or poll call directly into the the device driver + to flush packets which may be pending on the device queues into the stack. + + If unsure, say N. + config BQL boolean depends on SYSFS
net/core/skbuff.c +4 -0
@@ -733,6 +733,10 @@ static void __copy_skb_header(struct sk_buff *new, const struct sk_buff *old) new->vlan_tci = old->vlan_tci;skb_copy_secmark (new, old); + +#ifdef CONFIG_NET_LL_RX_POLL + new->napi_id = old->napi_id; +#endif }/*
net/core/sock.c +6 -0
@@ -139,6 +139,8 @@#include <net/tcp.h> #endif +#include <net/ll_poll.h> +static DEFINE_MUTEX (proto_list_mutex);static LIST_HEAD (proto_list);
@@ -2284,6 +2286,10 @@ void sock_init_data(struct socket *sock, struct sock *sk) sk->sk_stamp =ktime_set (-1L ,0 ); +#ifdef CONFIG_NET_LL_RX_POLL + sk->sk_napi_id =0 ; +#endif +/* * Before updating sk_refcnt, we must commit prior changes to memory * (Documentation/RCU/rculist_nulls.txt for details)
net/core/sysctl_net_core.c +10 -0
@@ -19,6 +19,7 @@#include <net/ip.h> #include <net/sock.h> #include <net/net_ratelimit.h> +#include <net/ll_poll.h> static int one =1 ;
@@ -284,6 +285,15 @@ static struct ctl_table net_core_table[] = { .proc_handler = flow_limit_table_len_sysctl }, #endif /* CONFIG_NET_FLOW_LIMIT */ +#ifdef CONFIG_NET_LL_RX_POLL + { + .procname = "low_latency_poll", + .data = &sysctl_net_ll_poll, + .maxlen = sizeof(unsigned long), + .mode = 0644, + .proc_handler = proc_doulongvec_minmax + }, +#endif #endif /* CONFIG_NET */ { .procname = "netdev_budget",
net/ipv4/proc.c +1 -0
@@ -273,6 +273,7 @@ static const struct snmp_mib snmp4_net_list[] = {SNMP_MIB_ITEM ("TCPFastOpenListenOverflow" ,LINUX_MIB_TCPFASTOPENLISTENOVERFLOW ),SNMP_MIB_ITEM ("TCPFastOpenCookieReqd" ,LINUX_MIB_TCPFASTOPENCOOKIEREQD ),SNMP_MIB_ITEM ("TCPSpuriousRtxHostQueues" ,LINUX_MIB_TCPSPURIOUS_RTX_HOSTQUEUES ), +SNMP_MIB_ITEM ("LowLatencyRxPackets" ,LINUX_MIB_LOWLATENCYRXPACKETS ), SNMP_MIB_SENTINEL };
net/socket.c +6 -0
@@ -104,6 +104,12 @@#include <linux/route.h> #include <linux/sockios.h> #include <linux/atalk.h> +#include <net/ll_poll.h> + +#ifdef CONFIG_NET_LL_RX_POLL +unsigned long sysctl_net_ll_poll__read_mostly ; +EXPORT_SYMBOL_GPL (sysctl_net_ll_poll); +#endif static int sock_no_open (struct inode *irrelevant,struct file *dontcare); static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
_______________________________________________
E1000-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel® Ethernet, visit http://communities.intel.com/community/wired
Re: [PATCH v10 net-next 2/6] net: add low latency socket poll
Quoted 12 lines · Eliezer Tamir
Adds an
ndo_ll_pollmethod and the code that supports it. This method can be used by low latency applications to busy-poll Ethernet device queues directly from the socket code.sysctl_net_ll_pollcontrols how many microseconds to poll. Default is zero (disabled).
Individual protocol support will be added by subsequent patches.Signed-off-by Alexander Duyck <[email protected]>Signed-off-by Jesse Brandeburg <[email protected]>Signed-off-by Eliezer Tamir <[email protected]>---
Quoted 14 lines
Documentation/sysctl/net.txt | 7 ++ include/linux/netdevice.h | 3 + include/linux/skbuff.h | 8 ++ include/net/ll_poll.h | 148 ++++++++++++++++++++++++++++++++++++++++++ include/net/sock.h | 4 + include/uapi/linux/snmp.h | 1 net/Kconfig | 12 +++ net/core/skbuff.c | 4 + net/core/sock.c | 6 ++ net/core/sysctl_net_core.c | 10 +++ net/ipv4/proc.c | 1 net/socket.c | 6 ++ 12 files changed, 208 insertions(+), 2 deletions(-) create mode 100644 include/net/ll_poll.h
Re: [PATCH v10 net-next 2/6] net: add low latency socket poll
Quoted 28 lines · Eric Dumazet
Quoted 12 lines · Eliezer Tamir
Adds an
ndo_ll_pollmethod and the code that supports it. This method can be used by low latency applications to busy-poll Ethernet device queues directly from the socket code.sysctl_net_ll_pollcontrols how many microseconds to poll. Default is zero (disabled).
Individual protocol support will be added by subsequent patches.Signed-off-by Alexander Duyck <[email protected]>Signed-off-by Jesse Brandeburg <[email protected]>Signed-off-by Eliezer Tamir <[email protected]>---
Quoted 14 lines
Documentation/sysctl/net.txt | 7 ++ include/linux/netdevice.h | 3 + include/linux/skbuff.h | 8 ++ include/net/ll_poll.h | 148 ++++++++++++++++++++++++++++++++++++++++++ include/net/sock.h | 4 + include/uapi/linux/snmp.h | 1 net/Kconfig | 12 +++ net/core/skbuff.c | 4 + net/core/sock.c | 6 ++ net/core/sysctl_net_core.c | 10 +++ net/ipv4/proc.c | 1 net/socket.c | 6 ++ 12 files changed, 208 insertions(+), 2 deletions(-) create mode 100644 include/net/ll_poll.h
Quoted 2 lines
Acked-by Eric Dumazet <[email protected]>
Per Eliezer's request, I applied v10 to a small set of workloads (netperf tcp_rr, udp_rr, 100x tcp_rr, 100x udp_rr and a poll()-based tcp rr) for some functional testing.
PATCH v10 3/6 udp: add low latency socket poll support
In reply to Eliezer TamirAdd upport for busy-polling on UDP sockets.
In __udp[46]_lib_rcv add a call to sk_mark_ll() to copy the napi_id from the skb into the sk.
This is done at the earliest possible moment, right after we identify which socket this skb is for.
In __skb_recv_datagram When there is no data and the user tries to read we busy poll.
---
net/core/datagram.c | 4 ++++ net/ipv4/udp.c | 6 +++++- net/ipv6/udp.c | 6 +++++- 3 files changed, 14 insertions(+), 2 deletions(-)
net/core/datagram.c +4 -0
@@ -56,6 +56,7 @@#include <net/sock.h> #include <net/tcp_states.h> #include <trace/events/skb.h> +#include <net/ll_poll.h> /* * Is a socket 'connection oriented' ?
@@ -207,6 +208,9 @@ struct sk_buff *__skb_recv_datagram(struct sock *sk, unsigned int flags, }spin_unlock_irqrestore (&queue->lock, cpu_flags); +if (sk_valid_ll (sk) &&sk_poll_ll (sk, flags &MSG_DONTWAIT )) +continue ; +/* User doesn't want to wait */ error = -EAGAIN ;if (!timeo)
net/ipv4/udp.c +5 -1
@@ -109,6 +109,7 @@#include <trace/events/udp.h> #include <linux/static_key.h> #include <trace/events/skb.h> +#include <net/ll_poll.h> #include "udp_impl.h" struct udp_table udp_table__read_mostly ;
@@ -1709,7 +1710,10 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable, sk =__udp4_lib_lookup_skb (skb, uh->source, uh->dest, udptable);if (sk !=NULL ) { -int ret =udp_queue_rcv_skb (sk, skb); +int ret; + +sk_mark_ll (sk, skb); + ret =udp_queue_rcv_skb (sk, skb);sock_put (sk);/* a return value > 0 means to resubmit the input, but
net/ipv6/udp.c +5 -1
@@ -46,6 +46,7 @@#include <net/ip6_checksum.h> #include <net/xfrm.h> #include <net/inet6_hashtables.h> +#include <net/ll_poll.h> #include <linux/proc_fs.h> #include <linux/seq_file.h>
@@ -841,7 +842,10 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,*/ sk =__udp6_lib_lookup_skb (skb, uh->source, uh->dest, udptable);if (sk !=NULL ) { -int ret =udpv6_queue_rcv_skb (sk, skb); +int ret; + +sk_mark_ll (sk, skb); + ret =udpv6_queue_rcv_skb (sk, skb);sock_put (sk);/* a return value > 0 means to resubmit the input, but
------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
_______________________________________________
E1000-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel® Ethernet, visit http://communities.intel.com/community/wired
Re: [PATCH v10 net-next 3/6] udp: add low latency socket poll support
Quoted 11 lines · Eliezer Tamir
Add upport for busy-polling on UDP sockets.
In __udp[46]_lib_rcv add a call tosk_mark_ll()to copy thenapi_idfrom the skb into the sk.
This is done at the earliest possible moment, right after we identify which socket this skb is for.
In__skb_recv_datagramWhen there is no data and the user tries to read we busy poll.Signed-off-by Alexander Duyck <[email protected]>Signed-off-by Jesse Brandeburg <[email protected]>Signed-off-by Eliezer Tamir <[email protected]>
Quoted 6 lines
---
net/core/datagram.c | 4 ++++ net/ipv4/udp.c | 6 +++++- net/ipv6/udp.c | 6 +++++- 3 files changed, 14 insertions(+), 2 deletions(-)
Re: [PATCH v10 net-next 3/6] udp: add low latency socket poll support
Quoted 14 lines · Eric Dumazet
Quoted 13 lines · Eliezer Tamir
Add upport for busy-polling on UDP sockets.
In __udp[46]_lib_rcv add a call tosk_mark_ll()to copy thenapi_idfrom the skb into the sk.
This is done at the earliest possible moment, right after we identify which socket this skb is for.
In__skb_recv_datagramWhen there is no data and the user tries to read we busy poll.Signed-off-by Alexander Duyck <[email protected]>Signed-off-by Jesse Brandeburg <[email protected]>Signed-off-by Eliezer Tamir <[email protected]>---
Quoted 7 lines
Quoted 4 lines
net/core/datagram.c | 4 ++++ net/ipv4/udp.c | 6 +++++- net/ipv6/udp.c | 6 +++++- 3 files changed, 14 insertions(+), 2 deletions(-)Acked-by Eric Dumazet <[email protected]>
(per Eliezer's request)
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
E1000-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel® Ethernet, visit http://communities.intel.com/community/wired
PATCH v10 4/6 tcp: add low latency socket poll support.
In reply to Eliezer TamirAdds low latency socket poll support for TCP.
In tcp_v[46]_rcv() add a call to sk_mark_ll() to copy the napi_id from the skb to the sk.
In tcp_recvmsg(), when there is no data in the socket we busy-poll. This is a good example of how to add busy-poll support to more protocols.
---
net/ipv4/tcp.c | 5 +++++ net/ipv4/tcp_ipv4.c | 2 ++ net/ipv6/tcp_ipv6.c | 2 ++ 3 files changed, 9 insertions(+), 0 deletions(-)
net/ipv4/tcp.c +5 -0
@@ -279,6 +279,7 @@#include <asm/uaccess.h> #include <asm/ioctls.h> +#include <net/ll_poll.h> int sysctl_tcp_fin_timeout__read_mostly =TCP_FIN_TIMEOUT ;
@@ -1553,6 +1554,10 @@ int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,struct sk_buff *skb;u32 urg_hole =0 ; +if (sk_valid_ll (sk) &&skb_queue_empty (&sk->sk_receive_queue) + && (sk->sk_state ==TCP_ESTABLISHED )) +sk_poll_ll (sk, nonblock); +lock_sock (sk); err = -ENOTCONN ;
net/ipv4/tcp_ipv4.c +2 -0
@@ -75,6 +75,7 @@#include <net/netdma.h> #include <net/secure_seq.h> #include <net/tcp_memcontrol.h> +#include <net/ll_poll.h> #include <linux/inet.h> #include <linux/ipv6.h>
@@ -1993,6 +1994,7 @@ process:if (sk_filter (sk, skb)) goto discard_and_relse; +sk_mark_ll (sk, skb); skb->dev =NULL ;bh_lock_sock_nested (sk);
net/ipv6/tcp_ipv6.c +2 -0
@@ -63,6 +63,7 @@#include <net/inet_common.h> #include <net/secure_seq.h> #include <net/tcp_memcontrol.h> +#include <net/ll_poll.h> #include <asm/uaccess.h>
@@ -1498,6 +1499,7 @@ process:if (sk_filter (sk, skb)) goto discard_and_relse; +sk_mark_ll (sk, skb); skb->dev =NULL ;bh_lock_sock_nested (sk);
------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
_______________________________________________
E1000-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel® Ethernet, visit http://communities.intel.com/community/wired
Re: [PATCH v10 net-next 4/6] tcp: add low latency socket poll support.
Quoted 10 lines · Eliezer Tamir
Adds low latency socket poll support for TCP.
In tcp_v[46]_rcv() add a call tosk_mark_ll()to copy thenapi_idfrom the skb to the sk.
Intcp_recvmsg(), when there is no data in the socket we busy-poll. This is a good example of how to add busy-poll support to more protocols.Signed-off-by Alexander Duyck <[email protected]>Signed-off-by Jesse Brandeburg <[email protected]>Signed-off-by Eliezer Tamir <[email protected]>---
------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
_______________________________________________
E1000-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel® Ethernet, visit http://communities.intel.com/community/wired
Re: [PATCH v10 net-next 4/6] tcp: add low latency socket poll support.
Quoted 7 lines · Eric Dumazet
Quoted 6 lines · Eliezer Tamir
Adds low latency socket poll support for TCP.
In tcp_v[46]_rcv() add a call tosk_mark_ll()to copy thenapi_idfrom the skb to the sk.
Intcp_recvmsg(), when there is no data in the socket we busy-poll. This is a good example of how to add busy-poll support to more protocols.
Quoted 7 lines
Quoted 4 lines
Signed-off-by Alexander Duyck <[email protected]>Signed-off-by Jesse Brandeburg <[email protected]>Signed-off-by Eliezer Tamir <[email protected]>---
Acked-by Eric Dumazet <[email protected]>
(per Eliezer's request)
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
E1000-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel® Ethernet, visit http://communities.intel.com/community/wired
PATCH v10 5/6 ixgbe: add support for ndo_ll_poll
In reply to Eliezer TamirAdd the ixgbe driver code implementing ndo_ll_poll.
Adds ndo_ll_poll method and locking between it and the napi poll. When receiving a packet we use skb_mark_ll to record the napi it came from. Add each napi to the napi_hash right after netif_napi_add().
---
drivers/net/ethernet/intel/ixgbe/ixgbe.h | 120 +++++++++++++++++++++++++ drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c | 2 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 63 +++++++++++-- 3 files changed, 177 insertions(+), 8 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe.h +120 -0
@@ -52,6 +52,8 @@#include <linux/dca.h> #endif +#include <net/ll_poll.h> +/* common prefix used by pr_<> macros */ #undef pr_fmt#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt
@@ -356,9 +358,127 @@ struct ixgbe_q_vector {struct rcu_head rcu;/* to avoid race with update stats on free */ char name[IFNAMSIZ +9 ]; +#ifdef CONFIG_NET_LL_RX_POLL +unsigned int state; +#define IXGBE_QV_STATE_IDLE 0 +#define IXGBE_QV_STATE_NAPI 1/* NAPI owns this QV */ +#define IXGBE_QV_STATE_POLL 2/* poll owns this QV */ +#define IXGBE_QV_LOCKED (IXGBE_QV_STATE_NAPI | IXGBE_QV_STATE_POLL) +#define IXGBE_QV_STATE_NAPI_YIELD 4/* NAPI yielded this QV */ +#define IXGBE_QV_STATE_POLL_YIELD 8/* poll yielded this QV */ +#define IXGBE_QV_YIELD (IXGBE_QV_STATE_NAPI_YIELD | IXGBE_QV_STATE_POLL_YIELD) +#define IXGBE_QV_USER_PEND (IXGBE_QV_STATE_POLL | IXGBE_QV_STATE_POLL_YIELD) +spinlock_t lock; +#endif /* CONFIG_NET_LL_RX_POLL */ +/* for dynamic allocation of rings associated with this q_vector */ struct ixgbe_ring ring[0 ]____cacheline_internodealigned_in_smp ; }; +#ifdef CONFIG_NET_LL_RX_POLL +static inline void ixgbe_qv_init_lock (struct ixgbe_q_vector *q_vector) +{ + +spin_lock_init (&q_vector->lock); + q_vector->state =IXGBE_QV_STATE_IDLE ; +} + +/* called from the device poll routine to get ownership of a q_vector */ +static inline bool ixgbe_qv_lock_napi (struct ixgbe_q_vector *q_vector) +{ +int rc = true; +spin_lock (&q_vector->lock); +if (q_vector->state &IXGBE_QV_LOCKED ) { +WARN_ON (q_vector->state &IXGBE_QV_STATE_NAPI ); + q_vector->state |=IXGBE_QV_STATE_NAPI_YIELD ; + rc = false; + }else +/* we don't care if someone yielded */ + q_vector->state =IXGBE_QV_STATE_NAPI ; +spin_unlock (&q_vector->lock); +return rc; +} + +/* returns true is someone tried to get the qv while napi had it */ +static inline bool ixgbe_qv_unlock_napi (struct ixgbe_q_vector *q_vector) +{ +int rc = false; +spin_lock (&q_vector->lock); +WARN_ON (q_vector->state & (IXGBE_QV_STATE_POLL | +IXGBE_QV_STATE_NAPI_YIELD )); + +if (q_vector->state &IXGBE_QV_STATE_POLL_YIELD ) + rc = true; + q_vector->state =IXGBE_QV_STATE_IDLE ; +spin_unlock (&q_vector->lock); +return rc; +} + +/* called from ixgbe_low_latency_poll() */ +static inline bool ixgbe_qv_lock_poll (struct ixgbe_q_vector *q_vector) +{ +int rc = true; +spin_lock_bh (&q_vector->lock); +if ((q_vector->state &IXGBE_QV_LOCKED )) { + q_vector->state |=IXGBE_QV_STATE_POLL_YIELD ; + rc = false; + }else +/* preserve yield marks */ + q_vector->state |=IXGBE_QV_STATE_POLL ; +spin_unlock_bh (&q_vector->lock); +return rc; +} + +/* returns true if someone tried to get the qv while it was locked */ +static inline bool ixgbe_qv_unlock_poll (struct ixgbe_q_vector *q_vector) +{ +int rc = false; +spin_lock_bh (&q_vector->lock); +WARN_ON (q_vector->state & (IXGBE_QV_STATE_NAPI )); + +if (q_vector->state &IXGBE_QV_STATE_POLL_YIELD ) + rc = true; + q_vector->state =IXGBE_QV_STATE_IDLE ; +spin_unlock_bh (&q_vector->lock); +return rc; +} + +/* true if a socket is polling, even if it did not get the lock */ +static inline bool ixgbe_qv_ll_polling (struct ixgbe_q_vector *q_vector) +{ +WARN_ON (!(q_vector->state &IXGBE_QV_LOCKED )); +return q_vector->state &IXGBE_QV_USER_PEND ; +} +#else /* CONFIG_NET_LL_RX_POLL */ +static inline void ixgbe_qv_init_lock (struct ixgbe_q_vector *q_vector) +{ +} + +static inline bool ixgbe_qv_lock_napi (struct ixgbe_q_vector *q_vector) +{ +return true; +} + +static inline bool ixgbe_qv_unlock_napi (struct ixgbe_q_vector *q_vector) +{ +return false; +} + +static inline bool ixgbe_qv_lock_poll (struct ixgbe_q_vector *q_vector) +{ +return false; +} + +static inline bool ixgbe_qv_unlock_poll (struct ixgbe_q_vector *q_vector) +{ +return false; +} + +static inline bool ixgbe_qv_ll_polling (struct ixgbe_q_vector *q_vector) +{ +return false; +} +#endif /* CONFIG_NET_LL_RX_POLL */ +#ifdef CONFIG_IXGBE_HWMON #define IXGBE_HWMON_TYPE_LOC 0
drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c +2 -0
@@ -811,6 +811,7 @@ static int ixgbe_alloc_q_vector(struct ixgbe_adapter *adapter,/* initialize NAPI */ netif_napi_add (adapter->netdev, &q_vector->napi, ixgbe_poll,64 ); +napi_hash_add (&q_vector->napi);/* tie q_vector and adapter together */ adapter->q_vector[v_idx] = q_vector;
@@ -931,6 +932,7 @@ static void ixgbe_free_q_vector(struct ixgbe_adapter *adapter, int v_idx) adapter->rx_ring[ring->queue_index] =NULL ; adapter->q_vector[v_idx] =NULL ; +napi_hash_del (&q_vector->napi);netif_napi_del (&q_vector->napi);/*
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +55 -8
123 lines not on this page · raw message
------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
_______________________________________________
E1000-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel® Ethernet, visit http://communities.intel.com/community/wired
Re: [PATCH v10 net-next 5/6] ixgbe: add support for ndo_ll_poll
Quoted 9 lines · Eliezer Tamir
Add the ixgbe driver code implementing
ndo_ll_poll.
Addsndo_ll_pollmethod and locking between it and the napi poll. When receiving a packet we useskb_mark_llto record the napi it came from. Add each napi to thenapi_hashright afternetif_napi_add().Signed-off-by Alexander Duyck <[email protected]>Signed-off-by Jesse Brandeburg <[email protected]>Signed-off-by Eliezer Tamir <[email protected]>---
Keller, Jacob E
Acked-byRE: [PATCH v10 net-next 5/6] ixgbe: add support for ndo_ll_poll
Quoted 23 lines
-----Original Message-----
From: [email protected] [mailto:netdev- [email protected]] On Behalf Of Eric Dumazet
Sent: Monday, June 10, 2013 7:59 AM
To: Eliezer Tamir
Cc: David Miller; [email protected]; [email protected]; Brandeburg, Jesse; Skidmore, Donald C; e1000- [email protected]; Willem de Bruijn; Ben Hutchings; Andi Kleen; HPA; Eilon Greenstien; Or Gerlitz; Amir Vadai; Eliezer Tamir
Subject: Re: [PATCH v10 net-next 5/6] ixgbe: add support forndo_ll_pollQuoted 3 lines · Eliezer Tamir
Add the ixgbe driver code implementing
ndo_ll_poll.
Addsndo_ll_pollmethod and locking between it and the napi poll. When receiving a packet we useskb_mark_llto record the napi it camefrom.
Quoted 6 lines
Add each napi to the
napi_hashright afternetif_napi_add().Signed-off-by Alexander Duyck <[email protected]>Signed-off-by Jesse Brandeburg <[email protected]>Signed-off-by Eliezer Tamir <[email protected]>---
Quoted 4 lines
Reviewed-by Eric Dumazet <[email protected]>--
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
E1000-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel® Ethernet, visit http://communities.intel.com/community/wired
PATCH v10 6/6 ixgbe: add extra stats for ndo_ll_poll
In reply to Eliezer TamirAdd additional statistics to the ixgbe driver for ndo_ll_poll Defined under LL_EXTENDED_STATS
---
drivers/net/ethernet/intel/ixgbe/ixgbe.h | 14 ++++++++ drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 40 ++++++++++++++++++++++ drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 6 +++ 3 files changed, 60 insertions(+), 0 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe.h +14 -0
@@ -54,6 +54,9 @@#include <net/ll_poll.h> +#ifdef CONFIG_NET_LL_RX_POLL +#define LL_EXTENDED_STATS +#endif /* common prefix used by pr_<> macros */ #undef pr_fmt#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt
@@ -184,6 +187,11 @@ struct ixgbe_rx_buffer {struct ixgbe_queue_stats {u64 packets;u64 bytes; +#ifdef LL_EXTENDED_STATS +u64 yields; +u64 misses; +u64 cleaned; +#endif /* LL_EXTENDED_STATS */ };struct ixgbe_tx_queue_stats {
@@ -391,6 +399,9 @@ static inline bool ixgbe_qv_lock_napi(struct ixgbe_q_vector *q_vector)WARN_ON (q_vector->state &IXGBE_QV_STATE_NAPI ); q_vector->state |=IXGBE_QV_STATE_NAPI_YIELD ; rc = false; +#ifdef LL_EXTENDED_STATS + q_vector->tx.ring->stats.yields++; +#endif }else /* we don't care if someone yielded */ q_vector->state =IXGBE_QV_STATE_NAPI ;
@@ -421,6 +432,9 @@ static inline bool ixgbe_qv_lock_poll(struct ixgbe_q_vector *q_vector)if ((q_vector->state &IXGBE_QV_LOCKED )) { q_vector->state |=IXGBE_QV_STATE_POLL_YIELD ; rc = false; +#ifdef LL_EXTENDED_STATS + q_vector->rx.ring->stats.yields++; +#endif }else /* preserve yield marks */ q_vector->state |=IXGBE_QV_STATE_POLL ;
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +40 -0
@@ -1054,6 +1054,12 @@ static void ixgbe_get_ethtool_stats(struct net_device *netdev, data[i] =0 ; data[i+1 ] =0 ; i +=2 ; +#ifdef LL_EXTENDED_STATS + data[i] =0 ; + data[i+1 ] =0 ; + data[i+2 ] =0 ; + i +=3 ; +#endif continue ; }
@@ -1063,6 +1069,12 @@ static void ixgbe_get_ethtool_stats(struct net_device *netdev, data[i+1 ] = ring->stats.bytes; }while (u64_stats_fetch_retry_bh (&ring->syncp, start)); i +=2 ; +#ifdef LL_EXTENDED_STATS + data[i] = ring->stats.yields; + data[i+1 ] = ring->stats.misses; + data[i+2 ] = ring->stats.cleaned; + i +=3 ; +#endif }for (j =0 ; j <IXGBE_NUM_RX_QUEUES ; j++) { ring = adapter->rx_ring[j];
@@ -1070,6 +1082,12 @@ static void ixgbe_get_ethtool_stats(struct net_device *netdev, data[i] =0 ; data[i+1 ] =0 ; i +=2 ; +#ifdef LL_EXTENDED_STATS + data[i] =0 ; + data[i+1 ] =0 ; + data[i+2 ] =0 ; + i +=3 ; +#endif continue ; }
@@ -1079,6 +1097,12 @@ static void ixgbe_get_ethtool_stats(struct net_device *netdev, data[i+1 ] = ring->stats.bytes; }while (u64_stats_fetch_retry_bh (&ring->syncp, start)); i +=2 ; +#ifdef LL_EXTENDED_STATS + data[i] = ring->stats.yields; + data[i+1 ] = ring->stats.misses; + data[i+2 ] = ring->stats.cleaned; + i +=3 ; +#endif }for (j =0 ; j <IXGBE_MAX_PACKET_BUFFERS ; j++) {
@@ -1115,12 +1139,28 @@ static void ixgbe_get_strings(struct net_device *netdev, u32 stringset, p +=ETH_GSTRING_LEN ;sprintf (p,"tx_queue_%u_bytes" , i); p +=ETH_GSTRING_LEN ; +#ifdef LL_EXTENDED_STATS +sprintf (p,"tx_q_%u_napi_yield" , i); + p +=ETH_GSTRING_LEN ; +sprintf (p,"tx_q_%u_misses" , i); + p +=ETH_GSTRING_LEN ; +sprintf (p,"tx_q_%u_cleaned" , i); + p +=ETH_GSTRING_LEN ; +#endif /* LL_EXTENDED_STATS */ }for (i =0 ; i <IXGBE_NUM_RX_QUEUES ; i++) {sprintf (p,"rx_queue_%u_packets" , i); p +=ETH_GSTRING_LEN ;sprintf (p,"rx_queue_%u_bytes" , i); p +=ETH_GSTRING_LEN ; +#ifdef LL_EXTENDED_STATS +sprintf (p,"rx_q_%u_ll_poll_yield" , i); + p +=ETH_GSTRING_LEN ; +sprintf (p,"rx_q_%u_misses" , i); + p +=ETH_GSTRING_LEN ; +sprintf (p,"rx_q_%u_cleaned" , i); + p +=ETH_GSTRING_LEN ; +#endif /* LL_EXTENDED_STATS */ }for (i =0 ; i <IXGBE_MAX_PACKET_BUFFERS ; i++) {sprintf (p,"tx_pb_%u_pxon" , i);
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +6 -0
@@ -2016,6 +2016,12 @@ static int ixgbe_low_latency_recv(struct napi_struct *napi)ixgbe_for_each_ring (ring, q_vector->rx) { found =ixgbe_clean_rx_irq (q_vector, ring,4 ); +#ifdef LL_EXTENDED_STATS +if (found) + ring->stats.cleaned += found; +else + ring->stats.misses++; +#endif if (found)break ; }
------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
_______________________________________________
E1000-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel® Ethernet, visit http://communities.intel.com/community/wired
David Miller
maintainerFrom: Eliezer Tamir <[email protected]>
Date: Mon, 10 Jun 2013 11:39:30 +0300
Quoted 6 lines
I removed the select/poll patch (was 5/7 in v9) from the set. The rest are the same patches that were in v9.
Please consider applying.
Thanks to everyone for their input.
There used to be a really nice, detailed and verbose, description of the goals and general idea of these changes, along with a lot of benchmark data.
Now I don't see it, either here in this posting, or in any of the patch commit messages.
Don't get rid of stuff like that, for a set of changes of this magnitude you can basically consider such details descriptions and information mandatory.
Reply to this email with some text to put in the merge commit, including basic benchmark results, so that I can apply this series.
Thanks.
Quoted 9 lines · David Miller
From: Eliezer Tamir <[email protected]>
Date: Mon, 10 Jun 2013 11:39:30 +0300Quoted 2 lines
I removed the select/poll patch (was 5/7 in v9) from the set. The rest are the same patches that were in v9.
Reply to this email with some text to put in the merge commit, including basic benchmark results, so that I can apply this series.
sorry,
Here is the text from the RFC and v2 cover letters, updated and merged. If this is too long, please tell me what you think should be removed.
Thanks,
Eliezer
---
This patch set adds the ability for the socket layer code to poll directly on an Ethernet device's RX queue.
This eliminates the cost of the interrupt and context switch and with proper tuning allows us to get very close to the HW latency.
This is a follow up to Jesse Brandeburg's Kernel Plumbers talk from last year
http://www.linuxplumbersconf.org/2012/wp-content/uploads/2012/09/2012-lpc-Low-Latency-Sockets-slides-brandeburg.pdf
Patch 1 adds a napi_id and a hashing mechanism to lookup a napi by id. Patch 2 adds an ndo_ll_poll method and the code that supports it. Patch 3 adds support for busy-polling on UDP sockets.
Patch 4 adds support for TCP.
Patch 5 adds the ixgbe driver code implementing ndo_ll_poll. Patch 6 adds additional statistics to the ixgbe driver for ndo_ll_poll.
Performance numbers:
setup TCP_RR UDP_RR
kernel Config C3/6 rx-usecs tps cpu% S.dem tps cpu% S.dem patched optimized on 100 87k 3.13 11.4 94K 3.17 10.7 patched optimized on 0 71k 3.12 14.0 84k 3.19 12.0 patched optimized on adaptive 80k 3.13 12.5 90k 3.46 12.2 patched typical on 100 72 3.13 14.0 79k 3.17 12.8 patched typical on 0 60k 2.13 16.5 71k 3.18 14.0 patched typical on adaptive 67k 3.51 16.7 75k 3.36 14.5 3.9 optimized on adaptive 25k 1.0 12.7 28k 0.98 11.2 3.9 typical off 0 48k 1.09 7.3 52k 1.11 4.18 3.9 typical 0ff adaptive 35k 1.12 4.08 38k 0.65 5.49 3.9 optimized off adaptive 40k 0.82 4.83 43k 0.70 5.23 3.9 optimized off 0 57k 1.17 4.08 62k 1.04 3.95
Test setup details:
Machines: each with two Intel Xeon 2680 CPUs and X520 (82599) optical NICs
Tests: Netperf tcp_rr and udp_rr, 1 byte (round trips per second)
Kernel: unmodified 3.9 and patched 3.9
Config: typical is derived from RH6.2, optimized is a stripped down config. Interrupt coalescing (ethtool rx-usecs) settings: 0=off, 1=adaptive, 100 us When C3/6 states were turned on (via BIOS) the performance governor was used.
These performance numbers were measured with v2 of the patch set. Performance of the optimized config with an rx-usecs setting of 100 (the first line in the table above) was tracked during the evolution of the patches and has never varied by more than 1%.
Design:
A global hash table that allows us to look up a struct napi by a unique id was added.
A napi_id field was added both to struct sk_buff and struct sk. This is used to track which NAPI we need to poll for a specific socket.
The device driver marks every incoming skb with this id.
This is propagated to the sk when the socket is looked up in the protocol handler.
When the socket code does not find any more data on the socket queue, it now may call ndo_ll_poll which will crank the device's rx queue and feed incoming packets to the stack directly from the context of the socket.
A sysctl value (net.core4.low_latency_poll) controls how many
microseconds we busy-wait before giving up. (setting to 0 globally disables busy-polling)
Locking:
1. Locking between napi poll and ndo_ll_poll:
Since what needs to be locked between a device's NAPI poll and ndo_ll_poll, is highly device / configuration dependent, we do this inside the Ethernet driver.
For example, when packets for high priority connections are sent to separate rx queues, you might not need locking between napi poll and ndo_ll_poll at all.
For ixgbe we only lock the RX queue.ndo_ll_poll does not touch the interrupt state or the TX queues. (earlier versions of this patchset did touch them,
but this design is simpler and works better.)
If a queue is actively polled by a socket (on another CPU) napi poll will not service it, but will wait until the queue can be locked and cleaned before doing a napi_complete().
If a socket can't lock the queue because another CPU has it, either from napi or from another socket polling on the queue, the socket code can busy wait on the socket's skb queue.
Ndo_ll_poll does not have preferential treatment for the data from the calling socket vs. data from others, so if another CPU is polling, you will see your data on this socket's queue when it arrives.
Ndo_ll_poll is called with local BHs disabled, so it won't race on the same CPU with net_rx_action, which calls the napi poll method.
2. Napi_hash
The napi hash mechanism uses RCU.napi_by_id() must be called under rcu_read_lock().
After a call to napi_hash_del(), caller must take care to wait an rcu grace period before freeing the memory containing the napi struct. (Ixgbe already had this because the queue vector structure uses rcu to protect the statistics counters in it.)
how to test:
1. The patchset should apply cleanly to net-next.
(don't forget to configure INET_LL_RX_POLL).
2. The ethtool -c setting for rx-usecs should be on the order of 100.
3. Use ethtool -K to disable GRO and LRO
(You are encouraged to try it both ways. If you find that your workload does better with GRO on do tell us.)
4. Sysctl value net.core.low_latency_poll controls how long (in us) to busy-wait for more data, You are encouraged to play with this and see what works for you. The default is now 0 so you need to set it to turn the feature on. I recommend a value around 50.
4. benchmark thread and IRQ should be bound to separate cores. Both cores should be on the same CPU NUMA node as the NIC. When the app and the IRQ run on the same CPU you get a small penalty. If interrupt coalescing is set to a low value this penalty can be very large.
5. If you suspect that your machine is not configured properly, use numademo to make sure that the CPU to memory BW is OK. numademo 128m memcpy local copy numbers should be more than 8GB/s on a properly configured machine.
Credit:
Jesse Brandeburg, Arun Chekhov Ilango, Julie Cummings, Alexander Duyck, Eric Geisler, Jason Neighbors, Yadong Li, Mike Polehn, Anil Vasudevan, Don Wood
Special thanks for finding bugs in earlier versions:
Willem de Bruijn and Andi Kleen
---
David Miller
maintainerFrom: Eliezer Tamir <[email protected]>
Date: Tue, 11 Jun 2013 05:25:42 +0300
Quoted 3 lines
Here is the text from the RFC and v2 cover letters, updated and merged. If this is too long, please tell me what you think should be removed.
It's perfect, and since this went through so many iterations I included the changelog too.
Thanks!
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
E1000-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel® Ethernet, visit http://communities.intel.com/community/wired
Quoted 10 lines · David Miller
From: Eliezer Tamir <[email protected]>
Date: Tue, 11 Jun 2013 05:25:42 +0300Quoted 3 lines
Here is the text from the RFC and v2 cover letters, updated and merged. If this is too long, please tell me what you think should be removed.
It's perfect, and since this went through so many iterations I included the changelog too.
Thank you.
I would like to hear opinions on what needs to be added to make this feature complete.
The list I have so far is:
1. add a socket option
2. support for poll/select
3. support for epoll
Also, would you accept a trailing whitespace cleanup patch for fs/select.c?
-Eliezer
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
E1000-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel® Ethernet, visit http://communities.intel.com/community/wired
Quoted 5 lines · Eliezer Tamir
I would like to hear opinions on what needs to be added to make this feature complete.
The list I have so far is:
1. add a socket option
Yes, please. I do not believe all sockets on the machine are candidate for low latency. In fact very few of them should be, depending on the number of cpu and/or RX queues.
Quoted 1 line
2. support for poll/select
As long as the cost of llpoll is bounded per poll()/select() call it will be ok.
Quoted 1 line
3. support for epoll
For this one, I honestly do not know how to proceed.
epoll Edge Trigger model is driven by the wakeups events.
The wakeups come from frames being delivered by the NIC (for UDP/TCP sockets)
If epoll_wait() has to scan the list of epitem to be able to perform the llpoll callback, it will be too slow : We come back to poll() model, with O(N) execution time.
Ideally we would have to callback llpoll not from the tcp_poll(), but right before putting current thread in wait mode.
Quoted 3 lines
Also, would you accept a trailing whitespace cleanup patch for
fs/select.c?
This has to be submitted to lkml
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
E1000-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel® Ethernet, visit http://communities.intel.com/community/wired
Quoted 11 lines · Eric Dumazet
Quoted 5 lines · Eliezer Tamir
I would like to hear opinions on what needs to be added to make this feature complete.
The list I have so far is:
1. add a socket optionYes, please. I do not believe all sockets on the machine are candidate for low latency. In fact very few of them should be, depending on the number of cpu and/or RX queues.
I have a patch for that, along a patch for sockperf I will use for testing.
One I will test it some more, I will send it in.
Quoted 9 lines
Quoted 1 line
3. support for epoll
For this one, I honestly do not know how to proceed.
epoll Edge Trigger model is driven by the wakeups events.
The wakeups come from frames being delivered by the NIC (for UDP/TCP sockets)
Quoted 6 lines
If
epoll_wait()has to scan the list of epitem to be able to perform the llpoll callback, it will be too slow : We come back topoll()model, with O(N) execution time.Ideally we would have to callback llpoll not from the
tcp_poll(), but right before putting current thread in wait mode.
We have a few ideas, I will do a POC and see if any of them actually work.
One thing that would really help is information about use-cases that people care about:
Number and type of sockets, how active are they.
How many active Ethernet ports are there.
Can bulk and low latency traffic be steered to separate cores or separated in any other way.
Thanks,
Eliezer
David Miller
maintainerFrom: Eliezer Tamir <[email protected]>
Date: Tue, 11 Jun 2013 09:49:31 +0300
Quoted 7 lines
I would like to hear opinions on what needs to be added to make this feature complete.
The list I have so far is:
1. add a socket option
2. support for poll/select
3. support for epoll
I actually would like to see the Kconfig option go away, that's my only request.
Quoted 2 lines
Also, would you accept a trailing whitespace cleanup patch for
fs/select.c?
That's not really for my tree, sorry.
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
E1000-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel® Ethernet, visit http://communities.intel.com/community/wired
Quoted 8 lines · David Miller
From: Eliezer Tamir <[email protected]>
Date: Tue, 11 Jun 2013 09:49:31 +0300Quoted 2 lines
I would like to hear opinions on what needs to be added to make this feature complete.
I actually would like to see the
Kconfigoption go away, that's my only request.
OK,
I will send a patch for this when I submit the socket option patch.
-Eliezer