Skip to content

Commit ffe4ccd

Browse files
edumazetPaolo Abeni
authored andcommitted
net: add net.core.qdisc_max_burst
In blamed commit, I added a check against the temporary queue built in __dev_xmit_skb(). Idea was to drop packets early, before any spinlock was acquired. if (unlikely(defer_count > READ_ONCE(q->limit))) { kfree_skb_reason(skb, SKB_DROP_REASON_QDISC_DROP); return NET_XMIT_DROP; } It turned out that HTB Qdisc has a zero q->limit. HTB limits packets on a per-class basis. Some of our tests became flaky. Add a new sysctl : net.core.qdisc_max_burst to control how many packets can be stored in the temporary lockless queue. Also add a new QDISC_BURST_DROP drop reason to better diagnose future issues. Thanks Neal ! Fixes: 100dfa7 ("net: dev_queue_xmit() llist adoption") Reported-and-bisected-by: Neal Cardwell <ncardwell@google.com> Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Neal Cardwell <ncardwell@google.com> Link: https://patch.msgid.link/20260107104159.3669285-1-edumazet@google.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent dfdf774 commit ffe4ccd

6 files changed

Lines changed: 26 additions & 3 deletions

File tree

Documentation/admin-guide/sysctl/net.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,14 @@ netdev_max_backlog
303303
Maximum number of packets, queued on the INPUT side, when the interface
304304
receives packets faster than kernel can process them.
305305

306+
qdisc_max_burst
307+
------------------
308+
309+
Maximum number of packets that can be temporarily stored before
310+
reaching qdisc.
311+
312+
Default: 1000
313+
306314
netdev_rss_key
307315
--------------
308316

include/net/dropreason-core.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
FN(TC_EGRESS) \
6868
FN(SECURITY_HOOK) \
6969
FN(QDISC_DROP) \
70+
FN(QDISC_BURST_DROP) \
7071
FN(QDISC_OVERLIMIT) \
7172
FN(QDISC_CONGESTED) \
7273
FN(CAKE_FLOOD) \
@@ -374,6 +375,11 @@ enum skb_drop_reason {
374375
* failed to enqueue to current qdisc)
375376
*/
376377
SKB_DROP_REASON_QDISC_DROP,
378+
/**
379+
* @SKB_DROP_REASON_QDISC_BURST_DROP: dropped when net.core.qdisc_max_burst
380+
* limit is hit.
381+
*/
382+
SKB_DROP_REASON_QDISC_BURST_DROP,
377383
/**
378384
* @SKB_DROP_REASON_QDISC_OVERLIMIT: dropped by qdisc when a qdisc
379385
* instance exceeds its total buffer size limit.

include/net/hotdata.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ struct net_hotdata {
4242
int netdev_budget_usecs;
4343
int tstamp_prequeue;
4444
int max_backlog;
45+
int qdisc_max_burst;
4546
int dev_tx_weight;
4647
int dev_rx_weight;
4748
int sysctl_max_skb_frags;

net/core/dev.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4203,8 +4203,8 @@ static inline int __dev_xmit_skb(struct sk_buff *skb, struct Qdisc *q,
42034203
do {
42044204
if (first_n && !defer_count) {
42054205
defer_count = atomic_long_inc_return(&q->defer_count);
4206-
if (unlikely(defer_count > READ_ONCE(q->limit))) {
4207-
kfree_skb_reason(skb, SKB_DROP_REASON_QDISC_DROP);
4206+
if (unlikely(defer_count > READ_ONCE(net_hotdata.qdisc_max_burst))) {
4207+
kfree_skb_reason(skb, SKB_DROP_REASON_QDISC_BURST_DROP);
42084208
return NET_XMIT_DROP;
42094209
}
42104210
}
@@ -4222,7 +4222,7 @@ static inline int __dev_xmit_skb(struct sk_buff *skb, struct Qdisc *q,
42224222
ll_list = llist_del_all(&q->defer_list);
42234223
/* There is a small race because we clear defer_count not atomically
42244224
* with the prior llist_del_all(). This means defer_list could grow
4225-
* over q->limit.
4225+
* over qdisc_max_burst.
42264226
*/
42274227
atomic_long_set(&q->defer_count, 0);
42284228

net/core/hotdata.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ struct net_hotdata net_hotdata __cacheline_aligned = {
1717

1818
.tstamp_prequeue = 1,
1919
.max_backlog = 1000,
20+
.qdisc_max_burst = 1000,
2021
.dev_tx_weight = 64,
2122
.dev_rx_weight = 64,
2223
.sysctl_max_skb_frags = MAX_SKB_FRAGS,

net/core/sysctl_net_core.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,13 @@ static struct ctl_table net_core_table[] = {
429429
.mode = 0644,
430430
.proc_handler = proc_dointvec
431431
},
432+
{
433+
.procname = "qdisc_max_burst",
434+
.data = &net_hotdata.qdisc_max_burst,
435+
.maxlen = sizeof(int),
436+
.mode = 0644,
437+
.proc_handler = proc_dointvec
438+
},
432439
{
433440
.procname = "netdev_rss_key",
434441
.data = &netdev_rss_key,

0 commit comments

Comments
 (0)