Linux Kernel Selftest development
 help / color / mirror / Atom feed
* [PATCH v2] bpf: replace pop/push emptiness check with bpf_list_empty()
@ 2026-05-24  2:58 Suchit Karunakaran
  2026-05-25 18:14 ` Emil Tsalapatis
  2026-05-29  3:10 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Suchit Karunakaran @ 2026-05-24  2:58 UTC (permalink / raw)
  To: andrii, eddyz87, ast, daniel, martin.lau, memxor, song,
	yonghong.song, shuah, bpf, linux-kselftest
  Cc: linux-kernel, Suchit Karunakaran

Simplify fq_flows_is_empty() by replacing the pop/push based emptiness
check with a direct call to bpf_list_empty().
This avoids unnecessary list mutation and simplifies the code while
preserving correctness.

Signed-off-by: Suchit Karunakaran <suchitkarunakaran@gmail.com>

Changes since v1:
- Removed unused variable node
---
 tools/testing/selftests/bpf/progs/bpf_qdisc_fq.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/tools/testing/selftests/bpf/progs/bpf_qdisc_fq.c b/tools/testing/selftests/bpf/progs/bpf_qdisc_fq.c
index 1a3233a275c7..8107f5934d2d 100644
--- a/tools/testing/selftests/bpf/progs/bpf_qdisc_fq.c
+++ b/tools/testing/selftests/bpf/progs/bpf_qdisc_fq.c
@@ -196,18 +196,13 @@ fq_flows_remove_front(struct bpf_list_head *head, struct bpf_spin_lock *lock,
 static bool
 fq_flows_is_empty(struct bpf_list_head *head, struct bpf_spin_lock *lock)
 {
-	struct bpf_list_node *node;
+	bool empty;
 
 	bpf_spin_lock(lock);
-	node = bpf_list_pop_front(head);
-	if (node) {
-		bpf_list_push_front(head, node);
-		bpf_spin_unlock(lock);
-		return false;
-	}
+	empty = bpf_list_empty(head);
 	bpf_spin_unlock(lock);
 
-	return true;
+	return empty;
 }
 
 /* flow->age is used to denote the state of the flow (not-detached, detached, throttled)
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] bpf: replace pop/push emptiness check with bpf_list_empty()
  2026-05-24  2:58 [PATCH v2] bpf: replace pop/push emptiness check with bpf_list_empty() Suchit Karunakaran
@ 2026-05-25 18:14 ` Emil Tsalapatis
  2026-05-29  3:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Emil Tsalapatis @ 2026-05-25 18:14 UTC (permalink / raw)
  To: Suchit Karunakaran, andrii, eddyz87, ast, daniel, martin.lau,
	memxor, song, yonghong.song, shuah, bpf, linux-kselftest
  Cc: linux-kernel

On Sat May 23, 2026 at 10:58 PM EDT, Suchit Karunakaran wrote:
> Simplify fq_flows_is_empty() by replacing the pop/push based emptiness
> check with a direct call to bpf_list_empty().
> This avoids unnecessary list mutation and simplifies the code while
> preserving correctness.
>
> Signed-off-by: Suchit Karunakaran <suchitkarunakaran@gmail.com>
>
> Changes since v1:
> - Removed unused variable node

Saw v1 before v2:

Reviewed-by: Emil Tsalapatis <emil@etsalapatis.com>

> ---
>  tools/testing/selftests/bpf/progs/bpf_qdisc_fq.c | 11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/progs/bpf_qdisc_fq.c b/tools/testing/selftests/bpf/progs/bpf_qdisc_fq.c
> index 1a3233a275c7..8107f5934d2d 100644
> --- a/tools/testing/selftests/bpf/progs/bpf_qdisc_fq.c
> +++ b/tools/testing/selftests/bpf/progs/bpf_qdisc_fq.c
> @@ -196,18 +196,13 @@ fq_flows_remove_front(struct bpf_list_head *head, struct bpf_spin_lock *lock,
>  static bool
>  fq_flows_is_empty(struct bpf_list_head *head, struct bpf_spin_lock *lock)
>  {
> -	struct bpf_list_node *node;
> +	bool empty;
>  
>  	bpf_spin_lock(lock);
> -	node = bpf_list_pop_front(head);
> -	if (node) {
> -		bpf_list_push_front(head, node);
> -		bpf_spin_unlock(lock);
> -		return false;
> -	}
> +	empty = bpf_list_empty(head);
>  	bpf_spin_unlock(lock);
>  
> -	return true;
> +	return empty;
>  }
>  
>  /* flow->age is used to denote the state of the flow (not-detached, detached, throttled)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] bpf: replace pop/push emptiness check with bpf_list_empty()
  2026-05-24  2:58 [PATCH v2] bpf: replace pop/push emptiness check with bpf_list_empty() Suchit Karunakaran
  2026-05-25 18:14 ` Emil Tsalapatis
@ 2026-05-29  3:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-05-29  3:10 UTC (permalink / raw)
  To: Suchit Karunakaran
  Cc: andrii, eddyz87, ast, daniel, martin.lau, memxor, song,
	yonghong.song, shuah, bpf, linux-kselftest, linux-kernel

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:

On Sun, 24 May 2026 08:28:53 +0530 you wrote:
> Simplify fq_flows_is_empty() by replacing the pop/push based emptiness
> check with a direct call to bpf_list_empty().
> This avoids unnecessary list mutation and simplifies the code while
> preserving correctness.
> 
> Signed-off-by: Suchit Karunakaran <suchitkarunakaran@gmail.com>
> 
> [...]

Here is the summary with links:
  - [v2] bpf: replace pop/push emptiness check with bpf_list_empty()
    https://git.kernel.org/bpf/bpf-next/c/9a720e090eb5

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-05-29  3:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-24  2:58 [PATCH v2] bpf: replace pop/push emptiness check with bpf_list_empty() Suchit Karunakaran
2026-05-25 18:14 ` Emil Tsalapatis
2026-05-29  3:10 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox