Skip to content

Commit 2ba2506

Browse files
herbertxdavem330
authored andcommitted
[NET]: Add preemption point in qdisc_run
The qdisc_run loop is currently unbounded and runs entirely in a softirq. This is bad as it may create an unbounded softirq run. This patch fixes this by calling need_resched and breaking out if necessary. It also adds a break out if the jiffies value changes since that would indicate we've been transmitting for too long which starves other softirqs. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 32aced7 commit 2ba2506

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

‎net/sched/sch_generic.c‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,22 @@ static inline int qdisc_restart(struct net_device *dev)
184184

185185
void __qdisc_run(struct net_device *dev)
186186
{
187-
do {
188-
if (!qdisc_restart(dev))
187+
unsigned long start_time = jiffies;
188+
189+
while (qdisc_restart(dev)) {
190+
if (netif_queue_stopped(dev))
191+
break;
192+
193+
/*
194+
* Postpone processing if
195+
* 1. another process needs the CPU;
196+
* 2. we've been doing it for too long.
197+
*/
198+
if (need_resched() || jiffies != start_time) {
199+
netif_schedule(dev);
189200
break;
190-
} while (!netif_queue_stopped(dev));
201+
}
202+
}
191203

192204
clear_bit(__LINK_STATE_QDISC_RUNNING, &dev->state);
193205
}

0 commit comments

Comments
 (0)