All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Emil Tsalapatis" <emil@etsalapatis.com>, bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v4 3/9] selftests/bpf: libarena: Make spinlock trylock match arena_spin_unlock
Date: Mon, 09 Nov 2026 18:29:58 +0000	[thread overview]
Message-ID: <sashiko-outbox-205415@kernel.org> (raw)
In-Reply-To: <20261109182055.7581-4-emil@etsalapatis.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] selftests/bpf: inconsistent return values in
  arena_spin_trylock() variants
--

commit 3875fb781c61e9ab8efcf22a434ad87a4732478e
Author: Emil Tsalapatis <emil@etsalapatis.com>

selftests/bpf: libarena: Make spinlock trylock match arena_spin_unlock

This commit updates arena_spin_trylock() to disable preemption on lock
acquisition, splits out arena_spin_trylock_raw() for the lock slowpath,
and adds arena_spin_trylock_irqsave().

> diff --git a/tools/testing/selftests/bpf/libarena/include/bpf_arena_spin_lock.h b/tools/testing/selftests/bpf/libarena/include/bpf_arena_spin_lock.h
> index 055b5892cb636..560ee18fd287f 100644
> --- a/tools/testing/selftests/bpf/libarena/include/bpf_arena_spin_lock.h
> +++ b/tools/testing/selftests/bpf/libarena/include/bpf_arena_spin_lock.h
> @@ -233,7 +233,26 @@ static __always_inline int arena_spin_trylock(arena_spinlock_t __arena *lock)
>  	if (unlikely(val))
>  		return 0;
>  
> -	return likely(atomic_try_cmpxchg_acquire(&lock->val, &val, _Q_LOCKED_VAL));
> +	bpf_preempt_disable();
> +	val = atomic_try_cmpxchg_acquire(&lock->val, &val, _Q_LOCKED_VAL);
> +	if (unlikely(!val))
> +		bpf_preempt_enable();
> +
> +	return val;
> +}

[ ... ]

> @@ -527,6 +546,17 @@ static __always_inline void arena_spin_unlock(arena_spinlock_t __arena *lock)
>  		(__ret);                                 \
>  	})
>  
> +#define arena_spin_trylock_irqsave(lock, flags)			\
> +	({							\
> +		int __ret;					\
> +		bpf_local_irq_save(&(flags));			\
> +		__ret = arena_spin_trylock((lock)) ? 0 : -EBUSY;\
> +		if (__ret)					\
> +			bpf_local_irq_restore(&(flags)); 	\
> +		(__ret);                                 	\
> +	})

[Severity: Low]
Should arena_spin_trylock() and arena_spin_trylock_irqsave() use the same
return value convention?

arena_spin_trylock() returns 1 on success and 0 on failure, whereas
arena_spin_trylock_irqsave() (like arena_spin_lock() and
arena_spin_lock_irqsave()) returns 0 on success and -EBUSY on failure, so
callers switching between the two trylock variants have to invert the
check.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261109182055.7581-1-emil@etsalapatis.com?part=3

  reply	other threads:[~2026-11-09 18:29 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-09 18:20 [PATCH bpf-next v4 0/9] bpf libarena allocator improvements Emil Tsalapatis
2026-11-09 18:20 ` [PATCH bpf-next v4 1/9] selftests/bpf: libarena: Add bulk buddy allocation helpers Emil Tsalapatis
2026-11-09 18:20 ` [PATCH bpf-next v4 2/9] selftests/bpf: Add a parallel buddy allocator benchmark Emil Tsalapatis
2026-11-09 18:20 ` [PATCH bpf-next v4 3/9] selftests/bpf: libarena: Make spinlock trylock match arena_spin_unlock Emil Tsalapatis
2026-11-09 18:29   ` sashiko-bot [this message]
2026-11-09 18:20 ` [PATCH bpf-next v4 4/9] selftests/bpf: libarena: Raise arena spinlock CPU limits Emil Tsalapatis
2026-11-09 18:32   ` sashiko-bot
2026-11-09 18:20 ` [PATCH bpf-next v4 5/9] selftests/bpf: libarena: Add buddy per-CPU caches Emil Tsalapatis
2026-11-09 18:38   ` sashiko-bot
2026-11-09 18:20 ` [PATCH bpf-next v4 6/9] selftests/bpf: libarena: Handle NMI reentrancy Emil Tsalapatis
2026-11-09 18:42   ` sashiko-bot
2026-11-09 19:05   ` bot+bpf-ci
2026-11-09 19:08     ` Emil Tsalapatis
2026-11-09 18:20 ` [PATCH bpf-next v4 7/9] selftests/bpf: libarena: Refill local caches in batches Emil Tsalapatis
2026-11-09 18:20 ` [PATCH bpf-next v4 8/9] selftests/bpf: libarena: Add a transfer cache Emil Tsalapatis
2026-11-09 18:20 ` [PATCH bpf-next v4 9/9] selftests/bpf: libarena: Cover buddy cache fast paths Emil Tsalapatis
2026-11-09 19:05   ` bot+bpf-ci

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=sashiko-outbox-205415@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=emil@etsalapatis.com \
    --cc=sashiko-reviews@lists.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 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.