From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=140.77.167.80 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796316142; b=CcSyuRwxCPeIEpcfUgy0FqJh9mT6k+VOWjmBcaCDD8d9jfBhVAAD+KdFrhOpSFPVsrv/ Q4jVtr90Ms2un7PeVwLpzpbC5qcSXXXRMAs5L1TJZA20/CAmej6tSRDWHyYTvYmtu7GCJ QI9Pr5OYSnPOK7jTPllVy0nXO6dr6bG8pnOMJcYX4lUdnvqdLiO8FFGDlI/1lnX/XzQ8m XzvDr1zQe6HXx8VNPxzz5vU2M9LUlqHscRJB8kJMML1GFuoxp3S4aafajzY+oV8OaPLdD Yf7VltwTtzYK6FVInaJB5RaSHcuvVL38sxGuMH4SXRj7ES6UULihF+VL/c28SQwd/XQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796316142; h=DMARC-Filter:Received:X-Virus-Scanned:Received:DKIM-Signature: Received:Received:MIME-Version:Date:From:To:Cc:Subject:Message-ID: X-Sender:User-Agent:Content-Type:Content-Transfer-Encoding; bh=msQkbPp0V9C5LMsm9VsBlfWUbUbrywZj9ZaW5+C764Q=; b=hNqDN8+sTlyl48K8EgB7M8Gr3qXyi0Gwq8+RjE7Btqf9jqVjKZSe2uCyksP4BbLbvh34 nW9b18yb04IYjQfrjsbHc+kdCeW1OeUEHcJ7Aa2+Ee24voUlYzjwKcFAOC9NdkdxGg/0v VWKTLUSESgE0DJKN9LBdIprz/r00SMzJ7mTPcEsLjJvFF1W3yIQLc1JtAUZljW3vqc+j3 kDtNe0zdrCqjSdM43TDju0wen0TMD8Pv99guQEjJdsNWaO8yY13YWT2WXsDINBPmU5O6Z PdrLa3TMNlpL4It5s5Jz/OgLKaKf/eRESga1EZ4MUezRk+qr6G3GC8DP+Mapaf+FGTw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=ens-lyon.fr; spf=pass smtp.mailfrom=ens-lyon.fr; dkim=pass header.d=ens-lyon.fr header.i=@ens-lyon.fr header.a=rsa-sha256 header.s=2024 header.b=ly4xMdAZ; arc=none smtp.remote-ip=140.77.167.80 Received: from lxc-smtp1.ens-lyon.fr (lxc-smtp1.ens-lyon.fr [140.77.167.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E3A5606A322 for ; Thu, 3 Dec 2026 16:42:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5E3A5606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=ens-lyon.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ens-lyon.fr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=ens-lyon.fr header.i=@ens-lyon.fr header.a=rsa-sha256 header.s=2024 header.b=ly4xMdAZ Received: from localhost (localhost [127.0.0.1]) by lxc-smtp1.ens-lyon.fr (Postfix) with ESMTP id 380ED220F03; Thu, 3 Dec 2026 17:42:12 +0100 (CET) X-Virus-Scanned: by amavis-2.13.0 (20230106) (Debian) at ens-lyon.fr Received: from lxc-smtp1.ens-lyon.fr ([127.0.0.1]) by localhost (lxc-smtp1.ens-lyon.fr [127.0.0.1]) (amavis, port 10024) with ESMTP id JlqfaCZZ3bwM; Thu, 3 Dec 2026 17:42:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ens-lyon.fr; s=2024; t=1796316132; bh=msQkbPp0V9C5LMsm9VsBlfWUbUbrywZj9ZaW5+C764Q=; h=Date:From:To:Cc:Subject:From; b=ly4xMdAZvBK2egbudTdNctRJ9AlJK1wjlFZr4Umt2mJUV+uDDeiZAlOEioZMTsBYs xkH4V/jnW/ZIKehTFPAlTzl9F/bkh9Y59ZzX6yFdNlrMM7QTXbPbr+UB4Yw5jKKvdR t9kdFuPyvh5V+v8s/rfxx174PqGInGeXflp1Y02igKpNylYFrEsK3ry7PrcRP0BCm3 4uceT8KfjDxCwKo0WqVQw2fp47eSI2isGxdv1/CbvZnFxReXh9N3LjAYJ6sRZSx381 9CDb6yTcESL/ewdMrKH9V3vjiESP9d1Q/mYg/0dbXl9aDkUCV7nIDBFunO3dMP4Pcq WiyEyjqrlO1UQ== Received: from webmail.ens-lyon.fr (lxc-m2-webmail2.ens-lyon.fr [140.77.167.53]) by lxc-smtp1.ens-lyon.fr (Postfix) with ESMTP id 10ABA22120C; Thu, 3 Dec 2026 17:42:12 +0100 (CET) Received: from butineur (par []) by [140.77.167.50] X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Date: Thu, 03 Dec 2026 17:42:12 +0100 From: Andreea-Carina Deaconu To: netdev@vger.kernel.org Cc: Thomas Begin Subject: [PATCH] net/sched: fq_codel: choose random fat flow to drop from, if multiple are equal Message-ID: X-Sender: carina.deaconu@ens-lyon.fr User-Agent: Roundcube Webmail/1.3.17 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Original bias: When the FQ Codel queue capacity is reached and we proceed in fq_codel_drop() to drop packets from the "fat flow" (the flow with the biggest size), if there are two or more equal "fat flows", we always drop from the first flow found (the flow with the lowest index). Fix: When searching for the "fat flow", keep a candidate count and, if there is more than one candidate, choose a random one to drop from. Reported-by: Thomas Begin Reported-by: Andreea-Carina Deaconu Signed-off-by: Andreea-Carina Deaconu --- net/sched/sch_fq_codel.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/net/sched/sch_fq_codel.c b/net/sched/sch_fq_codel.c index e0fcda26f..b63d3a3de 100644 --- a/net/sched/sch_fq_codel.c +++ b/net/sched/sch_fq_codel.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -139,8 +140,9 @@ static unsigned int fq_codel_drop(struct Qdisc *sch, unsigned int max_packets, { struct fq_codel_sched_data *q = qdisc_priv(sch); struct sk_buff *skb; - unsigned int maxbacklog = 0, idx = 0, i, len; struct fq_codel_flow *flow; + unsigned int maxbacklog = 0, idx = 0, ties = 0; + unsigned int target = 0, match_idx = 0, i, len; unsigned int threshold; unsigned int mem = 0; @@ -154,7 +156,26 @@ static unsigned int fq_codel_drop(struct Qdisc *sch, unsigned int max_packets, for (i = 0; i < q->flows_cnt; i++) { if (q->backlogs[i] > maxbacklog) { maxbacklog = q->backlogs[i]; - idx = i; + ties = 1; + } else if (maxbacklog > 0 && q->backlogs[i] == maxbacklog) { + ties++; + } + } + + if (maxbacklog > 0 && ties > 0) { + if (ties == 1) + target = 0; + else + target = get_random_u32() % ties; + + for (i = 0; i < q->flows_cnt; i++) { + if (q->backlogs[i] == maxbacklog) { + if (match_idx == target) { + idx = i; + break; + } + match_idx++; + } } } -- 2.53.0