Message ID | 20201119083024.119566-5-bjorn.topel@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Delegated to: | BPF |
Headers | show |
Series | Introduce preferred busy-polling | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for bpf-next |
netdev/subject_prefix | success | Link |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 1 this patch: 1 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 38 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 1 this patch: 1 |
netdev/header_inline | success | Link |
netdev/stable | success | Stable not CCed |
On Thu, Nov 19, 2020 at 9:33 AM Björn Töpel <bjorn.topel@gmail.com> wrote: > > From: Björn Töpel <bjorn.topel@intel.com> > > Add a check for need wake up in sendmsg(), so that if a user calls > sendmsg() when no wakeup is needed, do not trigger a wakeup. > > To simplify the need wakeup check in the syscall, unconditionally > enable the need wakeup flag for Tx. This has a side-effect for poll(); > If poll() is called for a socket without enabled need wakeup, a Tx > wakeup is unconditionally performed. > > The wakeup matrix for AF_XDP now looks like: > > need wakeup | poll() | sendmsg() | recvmsg() > ------------+--------------+-------------+------------ > disabled | wake Tx | wake Tx | nop > enabled | check flag; | check flag; | check flag; > | wake Tx/Rx | wake Tx | wake Rx > > Signed-off-by: Björn Töpel <bjorn.topel@intel.com> > --- > net/xdp/xsk.c | 6 +++++- > net/xdp/xsk_buff_pool.c | 13 ++++++------- > 2 files changed, 11 insertions(+), 8 deletions(-) Acked-by: Magnus Karlsson <magnus.karlsson@intel.com> > diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c > index 56a52ec75696..bf0f5c34af6c 100644 > --- a/net/xdp/xsk.c > +++ b/net/xdp/xsk.c > @@ -522,13 +522,17 @@ static int xsk_sendmsg(struct socket *sock, struct msghdr *m, size_t total_len) > bool need_wait = !(m->msg_flags & MSG_DONTWAIT); > struct sock *sk = sock->sk; > struct xdp_sock *xs = xdp_sk(sk); > + struct xsk_buff_pool *pool; > > if (unlikely(!xsk_is_bound(xs))) > return -ENXIO; > if (unlikely(need_wait)) > return -EOPNOTSUPP; > > - return __xsk_sendmsg(sk); > + pool = xs->pool; > + if (pool->cached_need_wakeup & XDP_WAKEUP_TX) > + return __xsk_sendmsg(sk); > + return 0; > } > > static int xsk_recvmsg(struct socket *sock, struct msghdr *m, size_t len, int flags) > diff --git a/net/xdp/xsk_buff_pool.c b/net/xdp/xsk_buff_pool.c > index 8a3bf4e1318e..96bb607853ad 100644 > --- a/net/xdp/xsk_buff_pool.c > +++ b/net/xdp/xsk_buff_pool.c > @@ -144,14 +144,13 @@ static int __xp_assign_dev(struct xsk_buff_pool *pool, > if (err) > return err; > > - if (flags & XDP_USE_NEED_WAKEUP) { > + if (flags & XDP_USE_NEED_WAKEUP) > pool->uses_need_wakeup = true; > - /* Tx needs to be explicitly woken up the first time. > - * Also for supporting drivers that do not implement this > - * feature. They will always have to call sendto(). > - */ > - pool->cached_need_wakeup = XDP_WAKEUP_TX; > - } > + /* Tx needs to be explicitly woken up the first time. Also > + * for supporting drivers that do not implement this > + * feature. They will always have to call sendto() or poll(). > + */ > + pool->cached_need_wakeup = XDP_WAKEUP_TX; > > dev_hold(netdev); > > -- > 2.27.0 >
diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c index 56a52ec75696..bf0f5c34af6c 100644 --- a/net/xdp/xsk.c +++ b/net/xdp/xsk.c @@ -522,13 +522,17 @@ static int xsk_sendmsg(struct socket *sock, struct msghdr *m, size_t total_len) bool need_wait = !(m->msg_flags & MSG_DONTWAIT); struct sock *sk = sock->sk; struct xdp_sock *xs = xdp_sk(sk); + struct xsk_buff_pool *pool; if (unlikely(!xsk_is_bound(xs))) return -ENXIO; if (unlikely(need_wait)) return -EOPNOTSUPP; - return __xsk_sendmsg(sk); + pool = xs->pool; + if (pool->cached_need_wakeup & XDP_WAKEUP_TX) + return __xsk_sendmsg(sk); + return 0; } static int xsk_recvmsg(struct socket *sock, struct msghdr *m, size_t len, int flags) diff --git a/net/xdp/xsk_buff_pool.c b/net/xdp/xsk_buff_pool.c index 8a3bf4e1318e..96bb607853ad 100644 --- a/net/xdp/xsk_buff_pool.c +++ b/net/xdp/xsk_buff_pool.c @@ -144,14 +144,13 @@ static int __xp_assign_dev(struct xsk_buff_pool *pool, if (err) return err; - if (flags & XDP_USE_NEED_WAKEUP) { + if (flags & XDP_USE_NEED_WAKEUP) pool->uses_need_wakeup = true; - /* Tx needs to be explicitly woken up the first time. - * Also for supporting drivers that do not implement this - * feature. They will always have to call sendto(). - */ - pool->cached_need_wakeup = XDP_WAKEUP_TX; - } + /* Tx needs to be explicitly woken up the first time. Also + * for supporting drivers that do not implement this + * feature. They will always have to call sendto() or poll(). + */ + pool->cached_need_wakeup = XDP_WAKEUP_TX; dev_hold(netdev);