From: Amery Hung <ameryhung@gmail.com>
To: bpf@vger.kernel.org
Cc: netdev@vger.kernel.org, alexei.starovoitov@gmail.com,
andrii@kernel.org, daniel@iogearbox.net, memxor@gmail.com,
martin.lau@kernel.org, kpsingh@kernel.org,
yonghong.song@linux.dev, song@kernel.org, haoluo@google.com,
ameryhung@gmail.com, kernel-team@meta.com
Subject: [PATCH bpf-next v6 12/17] selftests/bpf: Update sk_storage_omem_uncharge test
Date: Wed, 4 Feb 2026 23:02:01 -0800 [thread overview]
Message-ID: <20260205070208.186382-13-ameryhung@gmail.com> (raw)
In-Reply-To: <20260205070208.186382-1-ameryhung@gmail.com>
Check sk_omem_alloc when the caller of bpf_local_storage_destroy()
returns. bpf_local_storage_destroy() now returns the memory to uncharge
to the caller instead of directly uncharge. Therefore, in the
sk_storage_omem_uncharge, check sk_omem_alloc when bpf_sk_storage_free()
returns instead of bpf_local_storage_destroy().
Signed-off-by: Amery Hung <ameryhung@gmail.com>
---
.../selftests/bpf/progs/sk_storage_omem_uncharge.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/tools/testing/selftests/bpf/progs/sk_storage_omem_uncharge.c b/tools/testing/selftests/bpf/progs/sk_storage_omem_uncharge.c
index 46d6eb2a3b17..c8f4815c8dfb 100644
--- a/tools/testing/selftests/bpf/progs/sk_storage_omem_uncharge.c
+++ b/tools/testing/selftests/bpf/progs/sk_storage_omem_uncharge.c
@@ -6,7 +6,6 @@
#include <bpf/bpf_tracing.h>
#include <bpf/bpf_core_read.h>
-void *local_storage_ptr = NULL;
void *sk_ptr = NULL;
int cookie_found = 0;
__u64 cookie = 0;
@@ -19,21 +18,17 @@ struct {
__type(value, int);
} sk_storage SEC(".maps");
-SEC("fexit/bpf_local_storage_destroy")
-int BPF_PROG(bpf_local_storage_destroy, struct bpf_local_storage *local_storage)
+SEC("fexit/bpf_sk_storage_free")
+int BPF_PROG(bpf_sk_storage_free, struct sock *sk)
{
- struct sock *sk;
-
- if (local_storage_ptr != local_storage)
+ if (sk_ptr != sk)
return 0;
- sk = bpf_core_cast(sk_ptr, struct sock);
if (sk->sk_cookie.counter != cookie)
return 0;
cookie_found++;
omem = sk->sk_omem_alloc.counter;
- local_storage_ptr = NULL;
return 0;
}
@@ -50,7 +45,6 @@ int BPF_PROG(inet6_sock_destruct, struct sock *sk)
if (value && *value == 0xdeadbeef) {
cookie_found++;
sk_ptr = sk;
- local_storage_ptr = sk->sk_bpf_storage;
}
return 0;
--
2.47.3
next prev parent reply other threads:[~2026-02-05 7:02 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-05 7:01 [PATCH bpf-next v6 00/17] Remove task and cgroup local storage percpu counters Amery Hung
2026-02-05 7:01 ` [PATCH bpf-next v6 01/17] bpf: Select bpf_local_storage_map_bucket based on bpf_local_storage Amery Hung
2026-02-05 7:01 ` [PATCH bpf-next v6 02/17] bpf: Convert bpf_selem_unlink_map to failable Amery Hung
2026-02-05 7:37 ` bot+bpf-ci
2026-02-05 7:01 ` [PATCH bpf-next v6 03/17] bpf: Convert bpf_selem_link_map " Amery Hung
2026-02-05 7:01 ` [PATCH bpf-next v6 04/17] bpf: Convert bpf_selem_unlink " Amery Hung
2026-02-05 7:01 ` [PATCH bpf-next v6 05/17] bpf: Change local_storage->lock and b->lock to rqspinlock Amery Hung
2026-02-05 7:37 ` bot+bpf-ci
2026-02-05 7:01 ` [PATCH bpf-next v6 06/17] bpf: Remove task local storage percpu counter Amery Hung
2026-02-05 7:01 ` [PATCH bpf-next v6 07/17] bpf: Remove cgroup " Amery Hung
2026-02-05 7:01 ` [PATCH bpf-next v6 08/17] bpf: Remove unused percpu counter from bpf_local_storage_map_free Amery Hung
2026-02-05 7:01 ` [PATCH bpf-next v6 09/17] bpf: Prepare for bpf_selem_unlink_nofail() Amery Hung
2026-02-05 13:43 ` kernel test robot
2026-02-05 13:48 ` kernel test robot
2026-02-05 7:01 ` [PATCH bpf-next v6 10/17] bpf: Support lockless unlink when freeing map or local storage Amery Hung
2026-02-05 7:02 ` [PATCH bpf-next v6 11/17] bpf: Switch to bpf_selem_unlink_nofail in bpf_local_storage_{map_free, destroy} Amery Hung
2026-02-05 7:02 ` Amery Hung [this message]
2026-02-05 7:02 ` [PATCH bpf-next v6 13/17] selftests/bpf: Update task_local_storage/recursion test Amery Hung
2026-02-05 7:37 ` bot+bpf-ci
2026-02-05 7:02 ` [PATCH bpf-next v6 14/17] selftests/bpf: Update task_local_storage/task_storage_nodeadlock test Amery Hung
2026-02-05 7:02 ` [PATCH bpf-next v6 15/17] selftests/bpf: Remove test_task_storage_map_stress_lookup Amery Hung
2026-02-05 7:02 ` [PATCH bpf-next v6 16/17] selftests/bpf: Choose another percpu variable in bpf for btf_dump test Amery Hung
2026-02-05 7:02 ` [PATCH bpf-next v6 17/17] selftests/bpf: Fix outdated test on storage->smap Amery Hung
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=20260205070208.186382-13-ameryhung@gmail.com \
--to=ameryhung@gmail.com \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=haoluo@google.com \
--cc=kernel-team@meta.com \
--cc=kpsingh@kernel.org \
--cc=martin.lau@kernel.org \
--cc=memxor@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/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