summaryrefslogtreecommitdiff
path: root/include/net/busy_poll.h
diff options
context:
space:
mode:
authorBjörn Töpel <bjorn.topel@intel.com>2020-11-30 19:51:57 +0100
committerDaniel Borkmann <daniel@iogearbox.net>2020-12-01 00:09:25 +0100
commit7c951cafc0cb2e575f1d58677b95ac387ac0a5bd (patch)
tree1d47f6c2fb6e3734d52c96a1f0abcf38e2c08cf5 /include/net/busy_poll.h
parent7fd3253a7de6a317a0683f83739479fb880bffc8 (diff)
downloadlinux-rpi-7c951cafc0cb2e575f1d58677b95ac387ac0a5bd.tar.gz
linux-rpi-7c951cafc0cb2e575f1d58677b95ac387ac0a5bd.tar.bz2
linux-rpi-7c951cafc0cb2e575f1d58677b95ac387ac0a5bd.zip
net: Add SO_BUSY_POLL_BUDGET socket option
This option lets a user set a per socket NAPI budget for busy-polling. If the options is not set, it will use the default of 8. Signed-off-by: Björn Töpel <bjorn.topel@intel.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Reviewed-by: Jakub Kicinski <kuba@kernel.org> Link: https://lore.kernel.org/bpf/20201130185205.196029-3-bjorn.topel@gmail.com
Diffstat (limited to 'include/net/busy_poll.h')
-rw-r--r--include/net/busy_poll.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/include/net/busy_poll.h b/include/net/busy_poll.h
index 0292b8353d7e..2f8f51807b83 100644
--- a/include/net/busy_poll.h
+++ b/include/net/busy_poll.h
@@ -23,6 +23,8 @@
*/
#define MIN_NAPI_ID ((unsigned int)(NR_CPUS + 1))
+#define BUSY_POLL_BUDGET 8
+
#ifdef CONFIG_NET_RX_BUSY_POLL
struct napi_struct;
@@ -43,7 +45,7 @@ bool sk_busy_loop_end(void *p, unsigned long start_time);
void napi_busy_loop(unsigned int napi_id,
bool (*loop_end)(void *, unsigned long),
- void *loop_end_arg, bool prefer_busy_poll);
+ void *loop_end_arg, bool prefer_busy_poll, u16 budget);
#else /* CONFIG_NET_RX_BUSY_POLL */
static inline unsigned long net_busy_loop_on(void)
@@ -106,7 +108,8 @@ static inline void sk_busy_loop(struct sock *sk, int nonblock)
if (napi_id >= MIN_NAPI_ID)
napi_busy_loop(napi_id, nonblock ? NULL : sk_busy_loop_end, sk,
- READ_ONCE(sk->sk_prefer_busy_poll));
+ READ_ONCE(sk->sk_prefer_busy_poll),
+ READ_ONCE(sk->sk_busy_poll_budget) ?: BUSY_POLL_BUDGET);
#endif
}