diff mbox series

[bpf] samples/bpf: consider frame size in tx_only of xdpsock sample

Message ID 20210506124349.6666-1-magnus.karlsson@gmail.com (mailing list archive)
State Accepted
Commit 3b80d106e110d39d3f678954d3b55078669cf07e
Delegated to: BPF
Headers show
Series [bpf] samples/bpf: consider frame size in tx_only of xdpsock sample | expand

Checks

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
netdev/subject_prefix success Link
netdev/cc_maintainers warning 9 maintainers not CCed: yhs@fb.com kpsingh@kernel.org hawk@kernel.org andrii@kernel.org kafai@fb.com john.fastabend@gmail.com songliubraving@fb.com davem@davemloft.net kuba@kernel.org
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: 0 this patch: 0
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, 8 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

Magnus Karlsson May 6, 2021, 12:43 p.m. UTC
From: Magnus Karlsson <magnus.karlsson@intel.com>

Fix the tx_only micro-benchmark in xdpsock to take frame size into
consideration. It was hardcoded to the default value of frame_size
which is 4K. Changing this on the command line to 2K made half of the
packets illegal as they were outside the umem and were therefore
discarded by the kernel.

Fixes: 46738f73ea4f ("samples/bpf: add use of need_wakeup flag in xdpsock")
Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
---
 samples/bpf/xdpsock_user.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


base-commit: 9683e5775c75097c46bd24e65411b16ac6c6cbb3

Comments

Fijalkowski, Maciej May 6, 2021, 1:09 p.m. UTC | #1
On Thu, May 06, 2021 at 02:43:49PM +0200, Magnus Karlsson wrote:
> From: Magnus Karlsson <magnus.karlsson@intel.com>
> 
> Fix the tx_only micro-benchmark in xdpsock to take frame size into
> consideration. It was hardcoded to the default value of frame_size
> which is 4K. Changing this on the command line to 2K made half of the
> packets illegal as they were outside the umem and were therefore
> discarded by the kernel.
> 
> Fixes: 46738f73ea4f ("samples/bpf: add use of need_wakeup flag in xdpsock")
> Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>

Acked-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>

> ---
>  samples/bpf/xdpsock_user.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/samples/bpf/xdpsock_user.c b/samples/bpf/xdpsock_user.c
> index aa696854be78..53e300f860bb 100644
> --- a/samples/bpf/xdpsock_user.c
> +++ b/samples/bpf/xdpsock_user.c
> @@ -1255,7 +1255,7 @@ static void tx_only(struct xsk_socket_info *xsk, u32 *frame_nb, int batch_size)
>  	for (i = 0; i < batch_size; i++) {
>  		struct xdp_desc *tx_desc = xsk_ring_prod__tx_desc(&xsk->tx,
>  								  idx + i);
> -		tx_desc->addr = (*frame_nb + i) << XSK_UMEM__DEFAULT_FRAME_SHIFT;
> +		tx_desc->addr = (*frame_nb + i) * opt_xsk_frame_size;
>  		tx_desc->len = PKT_SIZE;
>  	}
>  
> 
> base-commit: 9683e5775c75097c46bd24e65411b16ac6c6cbb3
> -- 
> 2.29.0
>
Daniel Borkmann May 6, 2021, 11:29 p.m. UTC | #2
On 5/6/21 2:43 PM, Magnus Karlsson wrote:
> From: Magnus Karlsson <magnus.karlsson@intel.com>
> 
> Fix the tx_only micro-benchmark in xdpsock to take frame size into
> consideration. It was hardcoded to the default value of frame_size
> which is 4K. Changing this on the command line to 2K made half of the
> packets illegal as they were outside the umem and were therefore
> discarded by the kernel.
> 
> Fixes: 46738f73ea4f ("samples/bpf: add use of need_wakeup flag in xdpsock")
> Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>

Applied, thanks!
patchwork-bot+netdevbpf@kernel.org May 6, 2021, 11:30 p.m. UTC | #3
Hello:

This patch was applied to bpf/bpf.git (refs/heads/master):

On Thu,  6 May 2021 14:43:49 +0200 you wrote:
> From: Magnus Karlsson <magnus.karlsson@intel.com>
> 
> Fix the tx_only micro-benchmark in xdpsock to take frame size into
> consideration. It was hardcoded to the default value of frame_size
> which is 4K. Changing this on the command line to 2K made half of the
> packets illegal as they were outside the umem and were therefore
> discarded by the kernel.
> 
> [...]

Here is the summary with links:
  - [bpf] samples/bpf: consider frame size in tx_only of xdpsock sample
    https://git.kernel.org/bpf/bpf/c/3b80d106e110

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
diff mbox series

Patch

diff --git a/samples/bpf/xdpsock_user.c b/samples/bpf/xdpsock_user.c
index aa696854be78..53e300f860bb 100644
--- a/samples/bpf/xdpsock_user.c
+++ b/samples/bpf/xdpsock_user.c
@@ -1255,7 +1255,7 @@  static void tx_only(struct xsk_socket_info *xsk, u32 *frame_nb, int batch_size)
 	for (i = 0; i < batch_size; i++) {
 		struct xdp_desc *tx_desc = xsk_ring_prod__tx_desc(&xsk->tx,
 								  idx + i);
-		tx_desc->addr = (*frame_nb + i) << XSK_UMEM__DEFAULT_FRAME_SHIFT;
+		tx_desc->addr = (*frame_nb + i) * opt_xsk_frame_size;
 		tx_desc->len = PKT_SIZE;
 	}