[PATCH] bpf: replace pop/push emptiness check with bpf_list_empty()

Suchit Karunakaran posted 1 patch 23 hours ago
There is a newer version of this series
tools/testing/selftests/bpf/progs/bpf_qdisc_fq.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
[PATCH] bpf: replace pop/push emptiness check with bpf_list_empty()
Posted by Suchit Karunakaran 23 hours ago
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>
---
 tools/testing/selftests/bpf/progs/bpf_qdisc_fq.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 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..3b05ac1d7c77 100644
--- a/tools/testing/selftests/bpf/progs/bpf_qdisc_fq.c
+++ b/tools/testing/selftests/bpf/progs/bpf_qdisc_fq.c
@@ -197,17 +197,13 @@ 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
Re: [PATCH] bpf: replace pop/push emptiness check with bpf_list_empty()
Posted by bot+bpf-ci@kernel.org 22 hours ago
> diff --git a/tools/testing/selftests/bpf/progs/bpf_qdisc_fq.c b/tools/testing/selftests/bpf/progs/bpf_qdisc_fq.c
> index 1a3233a275c7..3b05ac1d7c77 100644
> --- a/tools/testing/selftests/bpf/progs/bpf_qdisc_fq.c
> +++ b/tools/testing/selftests/bpf/progs/bpf_qdisc_fq.c
> @@ -197,17 +197,13 @@ static bool
>  fq_flows_is_empty(struct bpf_list_head *head, struct bpf_spin_lock *lock)
>  {
>  	struct bpf_list_node *node;
                              ^^^^

The variable 'node' is no longer used after removing the pop/push logic.
Will this trigger an unused-variable compiler warning and break the selftests
build?

>  +	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;
>  }


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/26340856238