Skip to contentSkip to conversation

sctp: add support for busy polling to sctp protocol

PATCH Applied Neil Horman 4 participants 5 messages Apr 17, 2014 – Apr 20, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sctp: add support for busy polling to sctp protocol

The busy polling socket option adds support for sockets to busy wait on data arriving on the napi queue from which they have most recently received a frame. Currently only tcp and udp support this feature, but theres no reason sctp can't do so as well. Add it in so appliations can take advantage of it

CC Vlad Yasevich <[email protected]>
CC "David S. Miller" <[email protected]>
CC Daniel Borkmann <[email protected]>
---
 net/sctp/socket.c   | 5 +++++
 net/sctp/ulpqueue.c | 4 ++++
 2 files changed, 9 insertions(+)
net/sctp/socket.c +5 -0
index 981aaf8..9788e07 100644
@@ -71,6 +71,7 @@
 #include <net/route.h>
 #include <net/ipv6.h>
 #include <net/inet_common.h>
+#include <net/busy_poll.h>
 
 #include <linux/socket.h> /* for sa_family_t */
 #include <linux/export.h>
@@ -6553,6 +6554,10 @@ static struct sk_buff *sctp_skb_recv_datagram(struct sock *sk, int flags,
 		if (sk->sk_shutdown & RCV_SHUTDOWN)
 			break;
 
+		if (sk_can_busy_loop(sk) &&
+		    sk_busy_loop(sk, noblock))
+			continue;
+
 		/* User doesn't want to wait.  */
 		error = -EAGAIN;
 		if (!timeo)
net/sctp/ulpqueue.c +4 -0
index 5dc9411..a4df012 100644
@@ -38,6 +38,7 @@
 #include <linux/types.h>
 #include <linux/skbuff.h>
 #include <net/sock.h>
+#include <net/busy_poll.h>
 #include <net/sctp/structs.h>
 #include <net/sctp/sctp.h>
 #include <net/sctp/sm.h>
@@ -204,6 +205,9 @@ int sctp_ulpq_tail_event(struct sctp_ulpq *ulpq, struct sctp_ulpevent *event)
 	if (sock_flag(sk, SOCK_DEAD) || (sk->sk_shutdown & RCV_SHUTDOWN))
 		goto out_free;
 
+	if (!sctp_ulpevent_is_notification(event))
+		sk_mark_napi_id(sk, skb);
+
 	/* Check if the user wishes to receive this event.  */
 	if (!sctp_ulpevent_is_enabled(event, &sctp_sk(sk)->subscribe))
 		goto out_free;
Signature · 1 line
1.8.3.1
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Neil Horman

The busy polling socket option adds support for sockets to busy wait on data arriving on the napi queue from which they have most recently received a frame. Currently only tcp and udp support this feature, but theres no reason sctp can't do so as well. Add it in so appliations can take advantage of it

CC Vlad Yasevich <[email protected]>
CC "David S. Miller" <[email protected]>
CC Daniel Borkmann <[email protected]>

Hi Neil

Do we gain anything by polling?
This is probably more appropriate for net-next...

Thanks
-vlad

Quoted 51 lines
---
 net/sctp/socket.c   | 5 +++++
 net/sctp/ulpqueue.c | 4 ++++
 2 files changed, 9 insertions(+)
net/sctp/socket.c +5 -0
index 981aaf8..9788e07 100644
@@ -71,6 +71,7 @@
 #include <net/route.h>
 #include <net/ipv6.h>
 #include <net/inet_common.h>
+#include <net/busy_poll.h>
 
 #include <linux/socket.h> /* for sa_family_t */
 #include <linux/export.h>
@@ -6553,6 +6554,10 @@ static struct sk_buff *sctp_skb_recv_datagram(struct sock *sk, int flags,
 		if (sk->sk_shutdown & RCV_SHUTDOWN)
 			break;
 
+		if (sk_can_busy_loop(sk) &&
+		    sk_busy_loop(sk, noblock))
+			continue;
+
 		/* User doesn't want to wait.  */
 		error = -EAGAIN;
 		if (!timeo)
net/sctp/ulpqueue.c +4 -0
index 5dc9411..a4df012 100644
@@ -38,6 +38,7 @@
 #include <linux/types.h>
 #include <linux/skbuff.h>
 #include <net/sock.h>
+#include <net/busy_poll.h>
 #include <net/sctp/structs.h>
 #include <net/sctp/sctp.h>
 #include <net/sctp/sm.h>
@@ -204,6 +205,9 @@ int sctp_ulpq_tail_event(struct sctp_ulpq *ulpq, struct sctp_ulpevent *event)
 	if (sock_flag(sk, SOCK_DEAD) || (sk->sk_shutdown & RCV_SHUTDOWN))
 		goto out_free;
 
+	if (!sctp_ulpevent_is_notification(event))
+		sk_mark_napi_id(sk, skb);
+
 	/* Check if the user wishes to receive this event.  */
 	if (!sctp_ulpevent_is_enabled(event, &sctp_sk(sk)->subscribe))
 		goto out_free;
Acked-by on v1 1/1
#3 lore raw
In reply to Neil Horman
Quoted 10 lines · Neil Horman

The busy polling socket option adds support for sockets to busy wait on data arriving on the napi queue from which they have most recently received a frame. Currently only tcp and udp support this feature, but theres no reason sctp can't do so as well. Add it in so appliations can take advantage of it

CC Vlad Yasevich <[email protected]>
CC "David S. Miller" <[email protected]>
CC Daniel Borkmann <[email protected]>
#2 lore raw
In reply to Vlad Yasevich
Quoted 12 lines · Vlad Yasevich
Quoted 10 lines · Neil Horman

The busy polling socket option adds support for sockets to busy wait on data arriving on the napi queue from which they have most recently received a frame. Currently only tcp and udp support this feature, but theres no reason sctp can't do so as well. Add it in so appliations can take advantage of it

CC Vlad Yasevich <[email protected]>
CC "David S. Miller" <[email protected]>
CC Daniel Borkmann <[email protected]>
Quoted 3 lines

Hi Neil

Do we gain anything by polling?

Yes, for high througput applications, we save the latency introduced by processing the interrupt and waiting for the scheduled napi poll to run. See the initial busy poll patch series for intel performance numbers.

Neil

Quoted 60 lines

This is probably more appropriate for net-next...

Thanks
-vlad

Quoted 51 lines
---
 net/sctp/socket.c   | 5 +++++
 net/sctp/ulpqueue.c | 4 ++++
 2 files changed, 9 insertions(+)
net/sctp/socket.c +5 -0
index 981aaf8..9788e07 100644
@@ -71,6 +71,7 @@
 #include <net/route.h>
 #include <net/ipv6.h>
 #include <net/inet_common.h>
+#include <net/busy_poll.h>
 
 #include <linux/socket.h> /* for sa_family_t */
 #include <linux/export.h>
@@ -6553,6 +6554,10 @@ static struct sk_buff *sctp_skb_recv_datagram(struct sock *sk, int flags,
 		if (sk->sk_shutdown & RCV_SHUTDOWN)
 			break;
 
+		if (sk_can_busy_loop(sk) &&
+		    sk_busy_loop(sk, noblock))
+			continue;
+
 		/* User doesn't want to wait.  */
 		error = -EAGAIN;
 		if (!timeo)
net/sctp/ulpqueue.c +4 -0
index 5dc9411..a4df012 100644
@@ -38,6 +38,7 @@
 #include <linux/types.h>
 #include <linux/skbuff.h>
 #include <net/sock.h>
+#include <net/busy_poll.h>
 #include <net/sctp/structs.h>
 #include <net/sctp/sctp.h>
 #include <net/sctp/sm.h>
@@ -204,6 +205,9 @@ int sctp_ulpq_tail_event(struct sctp_ulpq *ulpq, struct sctp_ulpevent *event)
 	if (sock_flag(sk, SOCK_DEAD) || (sk->sk_shutdown & RCV_SHUTDOWN))
 		goto out_free;
 
+	if (!sctp_ulpevent_is_notification(event))
+		sk_mark_napi_id(sk, skb);
+
 	/* Check if the user wishes to receive this event.  */
 	if (!sctp_ulpevent_is_enabled(event, &sctp_sk(sk)->subscribe))
 		goto out_free;
maintainer Applied
#4 lore raw
In reply to Neil Horman

From: Neil Horman <[email protected]>
Date: Thu, 17 Apr 2014 15:26:51 -0400

Quoted 6 lines

The busy polling socket option adds support for sockets to busy wait on data arriving on the napi queue from which they have most recently received a frame. Currently only tcp and udp support this feature, but theres no reason sctp can't do so as well. Add it in so appliations can take advantage of it

Applied.