All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yonghong Song <yonghong.song@linux.dev>
To: Stanislav Fomichev <stfomichev@gmail.com>
Cc: bpf@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	kernel-team@fb.com, Martin KaFai Lau <martin.lau@kernel.org>
Subject: Re: [PATCH bpf-next 1/2] bpf: Fix an issue in bpf_prog_test_run_xdp when page size greater than 4K
Date: Mon, 9 Jun 2025 18:31:50 -0700	[thread overview]
Message-ID: <4d9db233-05de-4cbd-bd80-e61cb7151f0e@linux.dev> (raw)
In-Reply-To: <aEdj7n6e1Pb0WSBP@mini-arch>



On 6/9/25 3:45 PM, Stanislav Fomichev wrote:
> On 06/08, Yonghong Song wrote:
>> The bpf selftest xdp_adjust_tail/xdp_adjust_frags_tail_grow failed on
>> arm64 with 64KB page:
>>     xdp_adjust_tail/xdp_adjust_frags_tail_grow:FAIL
>>
>> In bpf_prog_test_run_xdp(), the xdp->frame_sz is set to 4K, but later on
>> when constructing frags, with 64K page size, the frag data_len could
>> be more than 4K. This will cause problems in bpf_xdp_frags_increase_tail().
>>
>> Limiting the data_len to be 4K for each frag fixed the above test failure.
>>
>> Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
>> ---
>>   net/bpf/test_run.c | 5 +++--
>>   1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
>> index aaf13a7d58ed..5529ec007954 100644
>> --- a/net/bpf/test_run.c
>> +++ b/net/bpf/test_run.c
>> @@ -1214,6 +1214,7 @@ int bpf_prog_test_run_xdp(struct bpf_prog *prog, const union bpf_attr *kattr,
>>   	u32 repeat = kattr->test.repeat;
>>   	struct netdev_rx_queue *rxqueue;
>>   	struct skb_shared_info *sinfo;
>> +	const u32 frame_sz = 4096;
>>   	struct xdp_buff xdp = {};
>>   	int i, ret = -EINVAL;
>>   	struct xdp_md *ctx;
>> @@ -1255,7 +1256,7 @@ int bpf_prog_test_run_xdp(struct bpf_prog *prog, const union bpf_attr *kattr,
>>   		headroom -= ctx->data;
>>   	}
>>   
> [..]
>
>> -	max_data_sz = 4096 - headroom - tailroom;
>> +	max_data_sz = frame_sz - headroom - tailroom;
> I wonder whether we should do s/4096/PAGE_SIZE/ here instead. Have you
> tried that? If we are on a 64K page arch, we should not try to preserve
> 4K page limits.

The user space test_run input looks like below (in prog_tests/xdp_adjust_tail.c):

	buf = malloc(16384);
	...
	topts.data_in = buf;
	topts.data_out = buf;
	topts.data_size_in = 9000;
	topts.data_size_out = 16384;
	err = bpf_prog_test_run_opts(prog_fd, &topts);

Allowing s/4096/PAGE_SIZE (64K) will have the test failure for the above
user space input. I think I can increse buf size data_size_in/data_size_out
properly so in the kernel we can do s/4096/PAGE_SIZE.


      reply	other threads:[~2025-06-10  1:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-08 16:55 [PATCH bpf-next 1/2] bpf: Fix an issue in bpf_prog_test_run_xdp when page size greater than 4K Yonghong Song
2025-06-08 16:55 ` [PATCH bpf-next 2/2] selftests/bpf: Fix two net related test failures with 64K page size Yonghong Song
2025-06-09 22:55   ` Stanislav Fomichev
2025-06-10  1:24     ` Yonghong Song
2025-06-09 22:45 ` [PATCH bpf-next 1/2] bpf: Fix an issue in bpf_prog_test_run_xdp when page size greater than 4K Stanislav Fomichev
2025-06-10  1:31   ` Yonghong Song [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4d9db233-05de-4cbd-bd80-e61cb7151f0e@linux.dev \
    --to=yonghong.song@linux.dev \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.com \
    --cc=martin.lau@kernel.org \
    --cc=stfomichev@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.