public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: "Emil Tsalapatis" <emil@etsalapatis.com>
To: "Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
	"Emil Tsalapatis" <emil@etsalapatis.com>
Cc: <bpf@vger.kernel.org>, <ast@kernel.org>, <andrii@kernel.org>,
	<daniel@iogearbox.net>, <eddyz87@gmail.com>, <song@kernel.org>
Subject: Re: [PATCH bpf-next v7 3/9] selftests/bpf: Move bpf_arena_spin_lock.h to the top level
Date: Fri, 17 Apr 2026 12:07:47 -0400	[thread overview]
Message-ID: <DHVK5NSN5J8Y.3C7JM4JRTAPND@etsalapatis.com> (raw)
In-Reply-To: <CAP01T77VRccr1feG4uiyWu0zAPf4oDFMJTVBdyBLfpKTf87GZQ@mail.gmail.com>

On Sun Apr 12, 2026 at 3:31 PM EDT, Kumar Kartikeya Dwivedi wrote:
> On Sun, 12 Apr 2026 at 19:45, Emil Tsalapatis <emil@etsalapatis.com> wrote:
>>
>> The bpf_arena_spin_lock.h header is useful for all programs and not
>> just the selftests. Move it to the top level of the BPF selftests
>> to make it more readily accessible.
>>
>
> Please add something to the log to explain why __weak is needed, as
> indicated in https://lore.kernel.org/bpf/CAP01T77GwHgS04TM8yTODyiXh2VJq-=L0FPoRvjpfF4dc6T9zw@mail.gmail.com.

Will do.

>
> Also, since we discussed already, why not move this to libarena?
>

I left it as (imminent) followup work to make libarena completely 
self-contained but it makes sense to add it from the very beginning.
I'll add move the headers in these patches.

>> Signed-off-by: Emil Tsalapatis <emil@etsalapatis.com>
>> Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
>> Acked-by: Song Liu <song@kernel.org>
>> ---
>>  .../selftests/bpf/{progs => }/bpf_arena_spin_lock.h        | 4 ++--
>>  tools/testing/selftests/bpf/prog_tests/arena_spin_lock.c   | 7 -------
>>  tools/testing/selftests/bpf/progs/arena_spin_lock.c        | 2 +-
>>  3 files changed, 3 insertions(+), 10 deletions(-)
>>  rename tools/testing/selftests/bpf/{progs => }/bpf_arena_spin_lock.h (99%)
>>
>> diff --git a/tools/testing/selftests/bpf/progs/bpf_arena_spin_lock.h b/tools/testing/selftests/bpf/bpf_arena_spin_lock.h
>> similarity index 99%
>> rename from tools/testing/selftests/bpf/progs/bpf_arena_spin_lock.h
>> rename to tools/testing/selftests/bpf/bpf_arena_spin_lock.h
>> index f90531cf3ee5..680c9e6cb35d 100644
>> --- a/tools/testing/selftests/bpf/progs/bpf_arena_spin_lock.h
>> +++ b/tools/testing/selftests/bpf/bpf_arena_spin_lock.h
>> @@ -107,7 +107,7 @@ struct arena_qnode {
>>  #define _Q_LOCKED_VAL          (1U << _Q_LOCKED_OFFSET)
>>  #define _Q_PENDING_VAL         (1U << _Q_PENDING_OFFSET)
>>
>> -struct arena_qnode __arena qnodes[_Q_MAX_CPUS][_Q_MAX_NODES];
>> +struct arena_qnode __weak __arena __hidden qnodes[_Q_MAX_CPUS][_Q_MAX_NODES];
>>
>>  static inline u32 encode_tail(int cpu, int idx)
>>  {
>> @@ -240,7 +240,7 @@ static __always_inline int arena_spin_trylock(arena_spinlock_t __arena *lock)
>>         return likely(atomic_try_cmpxchg_acquire(&lock->val, &val, _Q_LOCKED_VAL));
>>  }
>>
>> -__noinline
>> +__noinline __weak
>>  int arena_spin_lock_slowpath(arena_spinlock_t __arena __arg_arena *lock, u32 val)
>>  {
>>         struct arena_mcs_spinlock __arena *prev, *next, *node0, *node;
>> diff --git a/tools/testing/selftests/bpf/prog_tests/arena_spin_lock.c b/tools/testing/selftests/bpf/prog_tests/arena_spin_lock.c
>> index 693fd86fbde6..acb9d53b5973 100644
>> --- a/tools/testing/selftests/bpf/prog_tests/arena_spin_lock.c
>> +++ b/tools/testing/selftests/bpf/prog_tests/arena_spin_lock.c
>> @@ -5,13 +5,6 @@
>>  #include <sys/sysinfo.h>
>>
>>  struct __qspinlock { int val; };
>> -typedef struct __qspinlock arena_spinlock_t;
>> -
>> -struct arena_qnode {
>> -       unsigned long next;
>> -       int count;
>> -       int locked;
>> -};
>>
>>  #include "arena_spin_lock.skel.h"
>>
>> diff --git a/tools/testing/selftests/bpf/progs/arena_spin_lock.c b/tools/testing/selftests/bpf/progs/arena_spin_lock.c
>> index 086b57a426cf..6c04e7707644 100644
>> --- a/tools/testing/selftests/bpf/progs/arena_spin_lock.c
>> +++ b/tools/testing/selftests/bpf/progs/arena_spin_lock.c
>> @@ -4,7 +4,7 @@
>>  #include <bpf/bpf_tracing.h>
>>  #include <bpf/bpf_helpers.h>
>>  #include "bpf_misc.h"
>> -#include "bpf_arena_spin_lock.h"
>> +#include "../bpf_arena_spin_lock.h"
>>
>>  struct {
>>         __uint(type, BPF_MAP_TYPE_ARENA);
>> --
>> 2.53.0
>>


  reply	other threads:[~2026-04-17 16:07 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-12 17:45 [PATCH bpf-next v7 0/9] Introduce arena library and runtime Emil Tsalapatis
2026-04-12 17:45 ` [PATCH bpf-next v7 1/9] bpf: Allow instructions with arena source and non-arena dest registers Emil Tsalapatis
2026-04-12 19:54   ` Alexei Starovoitov
2026-04-12 17:45 ` [PATCH bpf-next v7 2/9] selftests/bpf: Add tests for non-arena/arena operations Emil Tsalapatis
2026-04-12 17:45 ` [PATCH bpf-next v7 3/9] selftests/bpf: Move bpf_arena_spin_lock.h to the top level Emil Tsalapatis
2026-04-12 19:31   ` Kumar Kartikeya Dwivedi
2026-04-17 16:07     ` Emil Tsalapatis [this message]
2026-04-12 17:45 ` [PATCH bpf-next v7 4/9] selftests/bpf: Move READ_ONCE/WRITE_ONCE macros to bpf_experimental.h Emil Tsalapatis
2026-04-12 19:33   ` Kumar Kartikeya Dwivedi
2026-04-17 16:06     ` Emil Tsalapatis
2026-04-17 16:21       ` Kumar Kartikeya Dwivedi
2026-04-17 16:38         ` Emil Tsalapatis
2026-04-12 17:45 ` [PATCH bpf-next v7 5/9] selftests/bpf: Add basic libarena scaffolding Emil Tsalapatis
2026-04-12 18:28   ` bot+bpf-ci
2026-04-12 18:31     ` Emil Tsalapatis
2026-04-12 17:45 ` [PATCH bpf-next v7 6/9] selftests/bpf: Add arena ASAN runtime to libarena Emil Tsalapatis
2026-04-12 18:28   ` bot+bpf-ci
2026-04-12 18:34     ` Emil Tsalapatis
2026-04-12 17:45 ` [PATCH bpf-next v7 7/9] selftests/bpf: Add ASAN support for libarena selftests Emil Tsalapatis
2026-04-12 17:45 ` [PATCH bpf-next v7 8/9] selftests/bpf: Add buddy allocator for libarena Emil Tsalapatis
2026-04-12 17:45 ` [PATCH bpf-next v7 9/9] selftests/bpf: Add selftests for libarena buddy allocator Emil Tsalapatis
2026-04-12 19:22 ` [PATCH bpf-next v7 0/9] Introduce arena library and runtime Kumar Kartikeya Dwivedi
2026-04-17 14:43   ` Emil Tsalapatis
2026-04-17 16:15     ` Kumar Kartikeya Dwivedi
2026-04-17 16:33       ` Emil Tsalapatis
2026-04-17 17:06         ` Alexei Starovoitov
2026-04-17 18:03           ` Emil Tsalapatis
2026-04-17 18:21             ` Alexei Starovoitov
2026-04-12 20:00 ` patchwork-bot+netdevbpf
2026-04-16 20:23 ` Matt Bobrowski
2026-04-16 20:31   ` Matt Bobrowski
2026-04-16 20:43     ` Song Liu
2026-04-17  5:59       ` Matt Bobrowski
2026-04-17 14:36         ` Emil Tsalapatis

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=DHVK5NSN5J8Y.3C7JM4JRTAPND@etsalapatis.com \
    --to=emil@etsalapatis.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=memxor@gmail.com \
    --cc=song@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