From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EACBD35AABE; Tue, 26 Aug 2025 14:43:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756219425; cv=none; b=XQv06KDxBFjsqFq02595Jc6RVDPmOqhVS0D2xM7aYhQg8zHl4xP8kUuUXx+X8yRj+aWHeYumibyfu5GPcs7BxfBnJR5QFEd/lETuY3Ds3DrQNwFbgreovSHLHjGiw30dnYsXzfpp4VUnY6HORTZgxzA8XF+1o9bqrsomaM3Rit8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756219425; c=relaxed/simple; bh=TAp6Dv73Cur3L3+eEpf/cle4fkVZOjZmxbj8VJFQv54=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RkuAHK+TY1DdUapcUwya2vVWEPwgBaGQ+VU/1RHYqq1/XRykbLEXldPSE1HUHUZ4dtBIQvbxrCLyNnjJEOSqj5uWvTFlYACwfuUrksKn84sZewWpDEl1yUwPUa4Oall85+3gdQFoMwKgzwlUHl5FBFImuTzf6d8957wOCim7D18= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=QBNQxoy1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="QBNQxoy1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67A47C4CEF1; Tue, 26 Aug 2025 14:43:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1756219424; bh=TAp6Dv73Cur3L3+eEpf/cle4fkVZOjZmxbj8VJFQv54=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QBNQxoy1bOzuq/S36i2KadlyoSYlJYg4UDVb1ZJ3RzPRNo+oPGx/s223FPFqBBCID vKkFrcklZqNseTXqTTYbnVTi7W10RxFi5ZTQULykGUHLCwOp1OOhpPBD7VffS0LsFV P0/692Ya/vaCQnx1ca2T0o0S2xZt33w2w6ZRrOOg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Gerrard Tai , Cong Wang , Simon Horman , Jamal Hadi Salim , Paolo Abeni , Siddh Raman Pant Subject: [PATCH 5.4 376/403] sch_hfsc: make hfsc_qlen_notify() idempotent Date: Tue, 26 Aug 2025 13:11:42 +0200 Message-ID: <20250826110917.402054764@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250826110905.607690791@linuxfoundation.org> References: <20250826110905.607690791@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Cong Wang commit 51eb3b65544c9efd6a1026889ee5fb5aa62da3bb upstream. 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: Gerrard Tai Signed-off-by: Cong Wang Reviewed-by: Simon Horman Link: https://patch.msgid.link/20250403211033.166059-4-xiyou.wangcong@gmail.com Acked-by: Jamal Hadi Salim Signed-off-by: Paolo Abeni Signed-off-by: Siddh Raman Pant Signed-off-by: Greg Kroah-Hartman --- net/sched/sch_hfsc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/net/sched/sch_hfsc.c +++ b/net/sched/sch_hfsc.c @@ -209,7 +209,10 @@ eltree_insert(struct hfsc_class *cl) static inline void eltree_remove(struct hfsc_class *cl) { - rb_erase(&cl->el_node, &cl->sched->eligible); + if (!RB_EMPTY_NODE(&cl->el_node)) { + rb_erase(&cl->el_node, &cl->sched->eligible); + RB_CLEAR_NODE(&cl->el_node); + } } static inline void @@ -1230,7 +1233,8 @@ hfsc_qlen_notify(struct Qdisc *sch, unsi /* 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. */ - update_vf(cl, 0, 0); + if (cl->cl_nactive) + update_vf(cl, 0, 0); if (cl->cl_flags & HFSC_RSC) eltree_remove(cl); }