From: Eliezer Tamir <eliezer.tamir@linux.intel.com>
To: David Miller <davem@davemloft.net>
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
Jesse Brandeburg <jesse.brandeburg@intel.com>,
Don Skidmore <donald.c.skidmore@intel.com>,
e1000-devel@lists.sourceforge.net,
Willem de Bruijn <willemb@google.com>,
Eric Dumazet <erdnetdev@gmail.com>,
Ben Hutchings <bhutchings@solarflare.com>,
Andi Kleen <andi@firstfloor.org>, HPA <hpa@zytor.com>,
Eilon Greenstien <eilong@broadcom.com>,
Or Gerlitz <or.gerlitz@gmail.com>,
Alex Rosenbaum <alexr@mellanox.com>,
Eliezer Tamir <eliezer@tamir.org.il>
Subject: [PATCH v8 net-next 5/7] net: simple poll/select low latency socket poll
Date: Mon, 03 Jun 2013 11:02:00 +0300 [thread overview]
Message-ID: <20130603080200.18273.52073.stgit@ladj378.jer.intel.com> (raw)
In-Reply-To: <20130603080107.18273.34279.stgit@ladj378.jer.intel.com>
A very naive select/poll busy-poll support.
Add busy-polling to sock_poll().
When poll/select have nothing to report, call the low-level
sock_poll() again untill we are out of time or we find something.
Rigth now we poll every socket once, this is subpotimal
but impoves latency when the number of sockets polled is not large.
Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Tested-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Eliezer Tamir <eliezer.tamir@linux.intel.com>
---
fs/select.c | 7 +++++++
net/socket.c | 10 +++++++++-
2 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/fs/select.c b/fs/select.c
index 8c1c96c..f116bf0 100644
--- a/fs/select.c
+++ b/fs/select.c
@@ -27,6 +27,7 @@
#include <linux/rcupdate.h>
#include <linux/hrtimer.h>
#include <linux/sched/rt.h>
+#include <net/ll_poll.h>
#include <asm/uaccess.h>
@@ -400,6 +401,7 @@ int do_select(int n, fd_set_bits *fds, struct timespec *end_time)
poll_table *wait;
int retval, i, timed_out = 0;
unsigned long slack = 0;
+ cycles_t ll_time = ll_end_time();
rcu_read_lock();
retval = max_select_fd(n, fds);
@@ -486,6 +488,8 @@ int do_select(int n, fd_set_bits *fds, struct timespec *end_time)
break;
}
+ if (can_poll_ll(ll_time))
+ continue;
/*
* If this is the first loop and we have a timeout
* given, then we convert to ktime_t and set the to
@@ -750,6 +754,7 @@ static int do_poll(unsigned int nfds, struct poll_list *list,
ktime_t expire, *to = NULL;
int timed_out = 0, count = 0;
unsigned long slack = 0;
+ cycles_t ll_time = ll_end_time();
/* Optimise the no-wait case */
if (end_time && !end_time->tv_sec && !end_time->tv_nsec) {
@@ -795,6 +800,8 @@ static int do_poll(unsigned int nfds, struct poll_list *list,
if (count || timed_out)
break;
+ if (can_poll_ll(ll_time))
+ continue;
/*
* If this is the first loop and we have a timeout
* given, then we convert to ktime_t and set the to
diff --git a/net/socket.c b/net/socket.c
index 721f4e7..02d0e15 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1148,13 +1148,21 @@ EXPORT_SYMBOL(sock_create_lite);
/* No kernel lock held - perfect */
static unsigned int sock_poll(struct file *file, poll_table *wait)
{
+ unsigned int poll_result;
struct socket *sock;
/*
* We can't return errors to poll, so it's either yes or no.
*/
sock = file->private_data;
- return sock->ops->poll(file, sock, wait);
+
+ poll_result = sock->ops->poll(file, sock, wait);
+
+ if (!(poll_result & (POLLRDNORM | POLLERR | POLLRDHUP | POLLHUP)) &&
+ sk_valid_ll(sock->sk) && sk_poll_ll(sock->sk, 1))
+ poll_result = sock->ops->poll(file, sock, NULL);
+
+ return poll_result;
}
static int sock_mmap(struct file *file, struct vm_area_struct *vma)
next prev parent reply other threads:[~2013-06-03 8:02 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-03 8:01 [PATCH v8 net-next 0/7] net: low latency Ethernet device polling Eliezer Tamir
2013-06-03 8:01 ` [PATCH v8 net-next 1/7] net: add napi_id and hash Eliezer Tamir
2013-06-03 12:58 ` Eric Dumazet
2013-06-03 8:01 ` [PATCH v8 net-next 2/7] net: add low latency socket poll Eliezer Tamir
2013-06-03 12:22 ` Amir Vadai
2013-06-03 13:05 ` Eric Dumazet
2013-06-03 13:53 ` Eliezer Tamir
2013-06-03 8:01 ` [PATCH v8 net-next 3/7] udp: add low latency socket poll support Eliezer Tamir
2013-06-03 13:08 ` Eric Dumazet
2013-06-03 8:01 ` [PATCH v8 net-next 4/7] tcp: " Eliezer Tamir
2013-06-03 13:09 ` Eric Dumazet
2013-06-03 8:02 ` Eliezer Tamir [this message]
2013-06-03 13:15 ` [PATCH v8 net-next 5/7] net: simple poll/select low latency socket poll Eric Dumazet
2013-06-03 13:59 ` Eliezer Tamir
2013-06-04 8:52 ` Eliezer Tamir
2013-06-03 8:02 ` [PATCH v8 net-next 6/7] ixgbe: add support for ndo_ll_poll Eliezer Tamir
2013-06-03 8:02 ` [PATCH v8 net-next 7/7] ixgbe: add extra stats " Eliezer Tamir
2013-06-03 11:23 ` [PATCH v8 net-next 0/7] net: low latency Ethernet device polling Amir Vadai
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=20130603080200.18273.52073.stgit@ladj378.jer.intel.com \
--to=eliezer.tamir@linux.intel.com \
--cc=alexr@mellanox.com \
--cc=andi@firstfloor.org \
--cc=bhutchings@solarflare.com \
--cc=davem@davemloft.net \
--cc=donald.c.skidmore@intel.com \
--cc=e1000-devel@lists.sourceforge.net \
--cc=eilong@broadcom.com \
--cc=eliezer@tamir.org.il \
--cc=erdnetdev@gmail.com \
--cc=hpa@zytor.com \
--cc=jesse.brandeburg@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=or.gerlitz@gmail.com \
--cc=willemb@google.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