Commit 51eb3b65 authored by Cong Wang's avatar Cong Wang Committed by Paolo Abeni
Browse files

sch_hfsc: make hfsc_qlen_notify() idempotent



hfsc_qlen_notify() is not idempotent either and not friendly
to its callers, like fq_codel_dequeue(). Let's make it idempotent
to ease qdisc_tree_reduce_backlog() callers' life:

1. update_vf() decreases cl->cl_nactive, so we can check whether it is
non-zero before calling it.

2. eltree_remove() always removes RB node cl->el_node, but we can use
   RB_EMPTY_NODE() + RB_CLEAR_NODE() to make it safe.

Reported-by: default avatarGerrard Tai <gerrard.tai@starlabs.sg>
Signed-off-by: default avatarCong Wang <xiyou.wangcong@gmail.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20250403211033.166059-4-xiyou.wangcong@gmail.com


Acked-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent df008598
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -203,7 +203,10 @@ eltree_insert(struct hfsc_class *cl)
static inline void
eltree_remove(struct hfsc_class *cl)
{
	if (!RB_EMPTY_NODE(&cl->el_node)) {
		rb_erase(&cl->el_node, &cl->sched->eligible);
		RB_CLEAR_NODE(&cl->el_node);
	}
}

static inline void
@@ -1220,6 +1223,7 @@ hfsc_qlen_notify(struct Qdisc *sch, unsigned long arg)
	/* vttree is now handled in update_vf() so that update_vf(cl, 0, 0)
	 * needs to be called explicitly to remove a class from vttree.
	 */
	if (cl->cl_nactive)
		update_vf(cl, 0, 0);
	if (cl->cl_flags & HFSC_RSC)
		eltree_remove(cl);