From: Yonghong Song <yonghong.song@linux.dev>
To: bpf@vger.kernel.org
Cc: 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>,
Alan Maguire <alan.maguire@oracle.com>,
Amery Hung <ameryhung@gmail.com>
Subject: [PATCH bpf-next v2 1/2] selftests/bpf: Fix task_local_data failure with 64K page
Date: Thu, 22 Jan 2026 08:26:16 -0800 [thread overview]
Message-ID: <20260122162616.3578898-1-yonghong.song@linux.dev> (raw)
On arm64 systems with 64K pages, the selftest task_local_data has the following
failures:
...
test_task_local_data_basic:PASS:tld_create_key 0 nsec
test_task_local_data_basic:FAIL:tld_create_key unexpected tld_create_key: actual 0 != expected -28
...
test_task_local_data_basic_thread:PASS:run task_main 0 nsec
test_task_local_data_basic_thread:FAIL:task_main retval unexpected error: 2 (errno 0)
test_task_local_data_basic_thread:FAIL:tld_get_data value0 unexpected tld_get_data value0: actual 0 != expected 6268
...
#447/1 task_local_data/task_local_data_basic:FAIL
...
#447/2 task_local_data/task_local_data_race:FAIL
#447 task_local_data:FAIL
When TLD_DYN_DATA_SIZE is 64K page size, for
struct tld_meta_u {
_Atomic __u8 cnt;
__u16 size;
struct tld_metadata metadata[];
};
fields 'cnt' and 'size' would overflow. For example,
for 4K page, 'cnt' will be 4096/64 = 64. But for 64K page,
'cnt' will be 65536/64 = 1024 and 'cnt' is not enough for 1024.
For field 'size', it is okay for value 4K, but it is not enough
for 64K as maximum 'size' value is '64K - 1'.
To accommodate 64K page, '_Atomic __u8 cnt' becomes '_Atomic __u16 cnt'
and '__u16 size' becomes '__u32 size'. A few other places are adjusted
accordingly.
Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
Tested-by: Alan Maguire <alan.maguire@oracle.com>
Cc: Amery Hung <ameryhung@gmail.com>
Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
---
tools/testing/selftests/bpf/prog_tests/task_local_data.h | 6 +++---
.../testing/selftests/bpf/prog_tests/test_task_local_data.c | 2 +-
tools/testing/selftests/bpf/progs/task_local_data.bpf.h | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/task_local_data.h b/tools/testing/selftests/bpf/prog_tests/task_local_data.h
index 2de38776a2d4..4c38f9a7bc90 100644
--- a/tools/testing/selftests/bpf/prog_tests/task_local_data.h
+++ b/tools/testing/selftests/bpf/prog_tests/task_local_data.h
@@ -94,8 +94,8 @@ struct tld_metadata {
};
struct tld_meta_u {
- _Atomic __u8 cnt;
- __u16 size;
+ _Atomic __u16 cnt;
+ __u32 size;
struct tld_metadata metadata[];
};
@@ -217,7 +217,7 @@ static int __tld_init_data_p(int map_fd)
static tld_key_t __tld_create_key(const char *name, size_t size, bool dyn_data)
{
int err, i, sz, off = 0;
- __u8 cnt;
+ __u16 cnt;
if (!TLD_READ_ONCE(tld_meta_p)) {
err = __tld_init_meta_p();
diff --git a/tools/testing/selftests/bpf/prog_tests/test_task_local_data.c b/tools/testing/selftests/bpf/prog_tests/test_task_local_data.c
index 9fd6306b455c..cc4d49222d9d 100644
--- a/tools/testing/selftests/bpf/prog_tests/test_task_local_data.c
+++ b/tools/testing/selftests/bpf/prog_tests/test_task_local_data.c
@@ -4,7 +4,7 @@
#include <test_progs.h>
#define TLD_FREE_DATA_ON_THREAD_EXIT
-#define TLD_DYN_DATA_SIZE 4096
+#define TLD_DYN_DATA_SIZE getpagesize()
#include "task_local_data.h"
struct test_tld_struct {
diff --git a/tools/testing/selftests/bpf/progs/task_local_data.bpf.h b/tools/testing/selftests/bpf/progs/task_local_data.bpf.h
index 432fff2af844..e13f239b46b0 100644
--- a/tools/testing/selftests/bpf/progs/task_local_data.bpf.h
+++ b/tools/testing/selftests/bpf/progs/task_local_data.bpf.h
@@ -80,8 +80,8 @@ struct tld_metadata {
};
struct tld_meta_u {
- __u8 cnt;
- __u16 size;
+ __u16 cnt;
+ __u32 size;
struct tld_metadata metadata[TLD_MAX_DATA_CNT];
};
--
2.47.3
next reply other threads:[~2026-01-22 16:26 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-22 16:26 Yonghong Song [this message]
2026-01-22 16:26 ` [PATCH bpf-next v2 2/2] selftests/bpf: Fix xdp_pull_data failure with 64K page Yonghong Song
2026-01-22 21:18 ` Amery Hung
2026-01-22 21:28 ` Yonghong Song
2026-01-22 21:38 ` Yonghong Song
2026-01-22 21:53 ` Amery Hung
2026-01-22 21:49 ` [PATCH bpf-next v2 1/2] selftests/bpf: Fix task_local_data " Amery Hung
2026-01-22 22:58 ` Yonghong Song
2026-01-22 23:34 ` Alexei Starovoitov
2026-01-22 23:47 ` Amery Hung
2026-01-23 0:23 ` Yonghong Song
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=20260122162616.3578898-1-yonghong.song@linux.dev \
--to=yonghong.song@linux.dev \
--cc=alan.maguire@oracle.com \
--cc=ameryhung@gmail.com \
--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 \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox