diff mbox series

[net-next] xdp: document xdp_do_flush() before napi_complete_done()

Message ID 20230117094305.6141-1-magnus.karlsson@gmail.com (mailing list archive)
State Accepted
Commit 68e5b6aa2795fd05c6ff58616cb16f2f216e4123
Delegated to: Netdev Maintainers
Headers show
Series [net-next] xdp: document xdp_do_flush() before napi_complete_done() | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 23 this patch: 23
netdev/cc_maintainers warning 11 maintainers not CCed: edumazet@google.com kpsingh@kernel.org haoluo@google.com song@kernel.org yhs@fb.com andrii@kernel.org martin.lau@linux.dev sdf@google.com john.fastabend@gmail.com jolsa@kernel.org hawk@kernel.org
netdev/build_clang success Errors and warnings before: 1 this patch: 1
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 23 this patch: 23
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 16 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Magnus Karlsson Jan. 17, 2023, 9:43 a.m. UTC
From: Magnus Karlsson <magnus.karlsson@intel.com>

Document in the XDP_REDIRECT manual section that drivers must call
xdp_do_flush() before napi_complete_done(). The two reasons behind
this can be found following the links below.

Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
Link: https://lore.kernel.org/r/20221220185903.1105011-1-sbohrer@cloudflare.com
Link: https://lore.kernel.org/all/20210624160609.292325-1-toke@redhat.com/
---
 net/core/filter.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)


base-commit: 501543b4fff0ff70bde28a829eb8835081ccef2f

Comments

Toke Høiland-Jørgensen Jan. 17, 2023, 10:33 a.m. UTC | #1
Magnus Karlsson <magnus.karlsson@gmail.com> writes:

> From: Magnus Karlsson <magnus.karlsson@intel.com>
>
> Document in the XDP_REDIRECT manual section that drivers must call
> xdp_do_flush() before napi_complete_done(). The two reasons behind
> this can be found following the links below.
>
> Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
> Link: https://lore.kernel.org/r/20221220185903.1105011-1-sbohrer@cloudflare.com
> Link: https://lore.kernel.org/all/20210624160609.292325-1-toke@redhat.com/

Thanks for fixing this!

Acked-by: Toke Høiland-Jørgensen <toke@redhat.com>
patchwork-bot+netdevbpf@kernel.org Jan. 18, 2023, 2:40 p.m. UTC | #2
Hello:

This patch was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:

On Tue, 17 Jan 2023 10:43:05 +0100 you wrote:
> From: Magnus Karlsson <magnus.karlsson@intel.com>
> 
> Document in the XDP_REDIRECT manual section that drivers must call
> xdp_do_flush() before napi_complete_done(). The two reasons behind
> this can be found following the links below.
> 
> Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
> Link: https://lore.kernel.org/r/20221220185903.1105011-1-sbohrer@cloudflare.com
> Link: https://lore.kernel.org/all/20210624160609.292325-1-toke@redhat.com/
> 
> [...]

Here is the summary with links:
  - [net-next] xdp: document xdp_do_flush() before napi_complete_done()
    https://git.kernel.org/netdev/net-next/c/68e5b6aa2795

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/core/filter.c b/net/core/filter.c
index ab811293ae5d..7a2b67893afd 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -4128,9 +4128,13 @@  static const struct bpf_func_proto bpf_xdp_adjust_meta_proto = {
  *    bpf_redirect_info to actually enqueue the frame into a map type-specific
  *    bulk queue structure.
  *
- * 3. Before exiting its NAPI poll loop, the driver will call xdp_do_flush(),
- *    which will flush all the different bulk queues, thus completing the
- *    redirect.
+ * 3. Before exiting its NAPI poll loop, the driver will call
+ *    xdp_do_flush(), which will flush all the different bulk queues,
+ *    thus completing the redirect. Note that xdp_do_flush() must be
+ *    called before napi_complete_done() in the driver, as the
+ *    XDP_REDIRECT logic relies on being inside a single NAPI instance
+ *    through to the xdp_do_flush() call for RCU protection of all
+ *    in-kernel data structures.
  */
 /*
  * Pointers to the map entries will be kept around for this whole sequence of