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
This commit is contained in:
committed by
Daniel Borkmann
parent
7fd3253a7d
commit
7c951cafc0
@ -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
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user