Skip to content

Commit 1e080f1

Browse files
kuba-moodavem330
authored andcommitted
net: sched: update default qdisc visibility after Tx queue cnt changes
mq / mqprio make the default child qdiscs visible. They only do so for the qdiscs which are within real_num_tx_queues when the device is registered. Depending on order of calls in the driver, or if user space changes config via ethtool -L the number of qdiscs visible under tc qdisc show will differ from the number of queues. This is confusing to users and potentially to system configuration scripts which try to make sure qdiscs have the right parameters. Add a new Qdisc_ops callback and make relevant qdiscs TTRT. Note that this uncovers the "shortcut" created by commit 1f27cde ("net: sched: use pfifo_fast for non real queues") The default child qdiscs beyond initial real_num_tx are always pfifo_fast, no matter what the sysfs setting is. Fixing this gets a little tricky because we'd need to keep a reference on whatever the default qdisc was at the time of creation. In practice this is likely an non-issue the qdiscs likely have to be configured to non-default settings, so whatever user space is doing such configuration can replace the pfifos... now that it will see them. Reported-by: Matthew Massey <matthewmassey@fb.com> Reviewed-by: Dave Taht <dave.taht@gmail.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent c506cc5 commit 1e080f1

5 files changed

Lines changed: 62 additions & 0 deletions

File tree

‎include/net/sch_generic.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,8 @@ struct Qdisc_ops {
308308
struct netlink_ext_ack *extack);
309309
void (*attach)(struct Qdisc *sch);
310310
int (*change_tx_queue_len)(struct Qdisc *, unsigned int);
311+
void (*change_real_num_tx)(struct Qdisc *sch,
312+
unsigned int new_real_tx);
311313

312314
int (*dump)(struct Qdisc *, struct sk_buff *);
313315
int (*dump_stats)(struct Qdisc *, struct gnet_dump *);
@@ -684,6 +686,8 @@ void qdisc_class_hash_grow(struct Qdisc *, struct Qdisc_class_hash *);
684686
void qdisc_class_hash_destroy(struct Qdisc_class_hash *);
685687

686688
int dev_qdisc_change_tx_queue_len(struct net_device *dev);
689+
void dev_qdisc_change_real_num_tx(struct net_device *dev,
690+
unsigned int new_real_tx);
687691
void dev_init_scheduler(struct net_device *dev);
688692
void dev_shutdown(struct net_device *dev);
689693
void dev_activate(struct net_device *dev);

‎net/core/dev.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2921,6 +2921,8 @@ int netif_set_real_num_tx_queues(struct net_device *dev, unsigned int txq)
29212921
if (dev->num_tc)
29222922
netif_setup_tc(dev, txq);
29232923

2924+
dev_qdisc_change_real_num_tx(dev, txq);
2925+
29242926
dev->real_num_tx_queues = txq;
29252927

29262928
if (disabling) {

‎net/sched/sch_generic.c‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,6 +1330,15 @@ static int qdisc_change_tx_queue_len(struct net_device *dev,
13301330
return 0;
13311331
}
13321332

1333+
void dev_qdisc_change_real_num_tx(struct net_device *dev,
1334+
unsigned int new_real_tx)
1335+
{
1336+
struct Qdisc *qdisc = dev->qdisc;
1337+
1338+
if (qdisc->ops->change_real_num_tx)
1339+
qdisc->ops->change_real_num_tx(qdisc, new_real_tx);
1340+
}
1341+
13331342
int dev_qdisc_change_tx_queue_len(struct net_device *dev)
13341343
{
13351344
bool up = dev->flags & IFF_UP;

‎net/sched/sch_mq.c‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,29 @@ static void mq_attach(struct Qdisc *sch)
125125
priv->qdiscs = NULL;
126126
}
127127

128+
static void mq_change_real_num_tx(struct Qdisc *sch, unsigned int new_real_tx)
129+
{
130+
#ifdef CONFIG_NET_SCHED
131+
struct net_device *dev = qdisc_dev(sch);
132+
struct Qdisc *qdisc;
133+
unsigned int i;
134+
135+
for (i = new_real_tx; i < dev->real_num_tx_queues; i++) {
136+
qdisc = netdev_get_tx_queue(dev, i)->qdisc_sleeping;
137+
/* Only update the default qdiscs we created,
138+
* qdiscs with handles are always hashed.
139+
*/
140+
if (qdisc != &noop_qdisc && !qdisc->handle)
141+
qdisc_hash_del(qdisc);
142+
}
143+
for (i = dev->real_num_tx_queues; i < new_real_tx; i++) {
144+
qdisc = netdev_get_tx_queue(dev, i)->qdisc_sleeping;
145+
if (qdisc != &noop_qdisc && !qdisc->handle)
146+
qdisc_hash_add(qdisc, false);
147+
}
148+
#endif
149+
}
150+
128151
static int mq_dump(struct Qdisc *sch, struct sk_buff *skb)
129152
{
130153
struct net_device *dev = qdisc_dev(sch);
@@ -288,6 +311,7 @@ struct Qdisc_ops mq_qdisc_ops __read_mostly = {
288311
.init = mq_init,
289312
.destroy = mq_destroy,
290313
.attach = mq_attach,
314+
.change_real_num_tx = mq_change_real_num_tx,
291315
.dump = mq_dump,
292316
.owner = THIS_MODULE,
293317
};

‎net/sched/sch_mqprio.c‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,28 @@ static void mqprio_attach(struct Qdisc *sch)
306306
priv->qdiscs = NULL;
307307
}
308308

309+
static void mqprio_change_real_num_tx(struct Qdisc *sch,
310+
unsigned int new_real_tx)
311+
{
312+
struct net_device *dev = qdisc_dev(sch);
313+
struct Qdisc *qdisc;
314+
unsigned int i;
315+
316+
for (i = new_real_tx; i < dev->real_num_tx_queues; i++) {
317+
qdisc = netdev_get_tx_queue(dev, i)->qdisc_sleeping;
318+
/* Only update the default qdiscs we created,
319+
* qdiscs with handles are always hashed.
320+
*/
321+
if (qdisc != &noop_qdisc && !qdisc->handle)
322+
qdisc_hash_del(qdisc);
323+
}
324+
for (i = dev->real_num_tx_queues; i < new_real_tx; i++) {
325+
qdisc = netdev_get_tx_queue(dev, i)->qdisc_sleeping;
326+
if (qdisc != &noop_qdisc && !qdisc->handle)
327+
qdisc_hash_add(qdisc, false);
328+
}
329+
}
330+
309331
static struct netdev_queue *mqprio_queue_get(struct Qdisc *sch,
310332
unsigned long cl)
311333
{
@@ -623,6 +645,7 @@ static struct Qdisc_ops mqprio_qdisc_ops __read_mostly = {
623645
.init = mqprio_init,
624646
.destroy = mqprio_destroy,
625647
.attach = mqprio_attach,
648+
.change_real_num_tx = mqprio_change_real_num_tx,
626649
.dump = mqprio_dump,
627650
.owner = THIS_MODULE,
628651
};

0 commit comments

Comments
 (0)