Skip to content

Commit 8d433ab

Browse files
kuba-moogregkh
authored andcommitted
net: sched: update default qdisc visibility after Tx queue cnt changes
[ Upstream commit 1e080f1 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 28118dc commit 8d433ab

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
@@ -302,6 +302,8 @@ struct Qdisc_ops {
302302
struct netlink_ext_ack *extack);
303303
void (*attach)(struct Qdisc *sch);
304304
int (*change_tx_queue_len)(struct Qdisc *, unsigned int);
305+
void (*change_real_num_tx)(struct Qdisc *sch,
306+
unsigned int new_real_tx);
305307

306308
int (*dump)(struct Qdisc *, struct sk_buff *);
307309
int (*dump_stats)(struct Qdisc *, struct gnet_dump *);
@@ -683,6 +685,8 @@ void qdisc_class_hash_grow(struct Qdisc *, struct Qdisc_class_hash *);
683685
void qdisc_class_hash_destroy(struct Qdisc_class_hash *);
684686

685687
int dev_qdisc_change_tx_queue_len(struct net_device *dev);
688+
void dev_qdisc_change_real_num_tx(struct net_device *dev,
689+
unsigned int new_real_tx);
686690
void dev_init_scheduler(struct net_device *dev);
687691
void dev_shutdown(struct net_device *dev);
688692
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
@@ -2973,6 +2973,8 @@ int netif_set_real_num_tx_queues(struct net_device *dev, unsigned int txq)
29732973
if (dev->num_tc)
29742974
netif_setup_tc(dev, txq);
29752975

2976+
dev_qdisc_change_real_num_tx(dev, txq);
2977+
29762978
dev->real_num_tx_queues = txq;
29772979

29782980
if (disabling) {

‎net/sched/sch_generic.c‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,6 +1303,15 @@ static int qdisc_change_tx_queue_len(struct net_device *dev,
13031303
return 0;
13041304
}
13051305

1306+
void dev_qdisc_change_real_num_tx(struct net_device *dev,
1307+
unsigned int new_real_tx)
1308+
{
1309+
struct Qdisc *qdisc = dev->qdisc;
1310+
1311+
if (qdisc->ops->change_real_num_tx)
1312+
qdisc->ops->change_real_num_tx(qdisc, new_real_tx);
1313+
}
1314+
13061315
int dev_qdisc_change_tx_queue_len(struct net_device *dev)
13071316
{
13081317
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
{
@@ -629,6 +651,7 @@ static struct Qdisc_ops mqprio_qdisc_ops __read_mostly = {
629651
.init = mqprio_init,
630652
.destroy = mqprio_destroy,
631653
.attach = mqprio_attach,
654+
.change_real_num_tx = mqprio_change_real_num_tx,
632655
.dump = mqprio_dump,
633656
.owner = THIS_MODULE,
634657
};

0 commit comments

Comments
 (0)