]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bpf: replace pop/push emptiness check with bpf_list_empty()
authorSuchit Karunakaran <suchitkarunakaran@gmail.com>
Sun, 24 May 2026 02:58:53 +0000 (08:28 +0530)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 29 May 2026 03:02:57 +0000 (20:02 -0700)
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
Reviewed-by: Emil Tsalapatis <emil@etsalapatis.com>
Link: https://lore.kernel.org/r/20260524025853.13786-1-suchitkarunakaran@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/progs/bpf_qdisc_fq.c

index 1a3233a275c7ea029ee0c8dcd2550819f640bcfc..8107f5934d2d77394eb39441733a92443484b205 100644 (file)
@@ -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)