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

From: Emil Tsalapatis

Date: Mon May 25 2026 - 14:14:35 EST


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@xxxxxxxxx>
>
> Changes since v1:
> - Removed unused variable node

Saw v1 before v2:

Reviewed-by: Emil Tsalapatis <emil@xxxxxxxxxxxxxxx>

> ---
> 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)