]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
net: sched: update default qdisc visibility after Tx queue cnt changes
authorJakub Kicinski <kuba@kernel.org>
Mon, 13 Sep 2021 22:53:30 +0000 (15:53 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 15 Sep 2021 14:46:02 +0000 (15:46 +0100)
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 1f27cde313d7 ("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>
include/net/sch_generic.h
net/core/dev.c
net/sched/sch_generic.c
net/sched/sch_mq.c
net/sched/sch_mqprio.c

index c0069ac00e62d28a13cb0086d6657948317b68ca..8c2d611639fcadb5bd2f9109eeb4c2e557ff1589 100644 (file)
@@ -308,6 +308,8 @@ struct Qdisc_ops {
                                          struct netlink_ext_ack *extack);
        void                    (*attach)(struct Qdisc *sch);
        int                     (*change_tx_queue_len)(struct Qdisc *, unsigned int);
+       void                    (*change_real_num_tx)(struct Qdisc *sch,
+                                                     unsigned int new_real_tx);
 
        int                     (*dump)(struct Qdisc *, struct sk_buff *);
        int                     (*dump_stats)(struct Qdisc *, struct gnet_dump *);
@@ -684,6 +686,8 @@ void qdisc_class_hash_grow(struct Qdisc *, struct Qdisc_class_hash *);
 void qdisc_class_hash_destroy(struct Qdisc_class_hash *);
 
 int dev_qdisc_change_tx_queue_len(struct net_device *dev);
+void dev_qdisc_change_real_num_tx(struct net_device *dev,
+                                 unsigned int new_real_tx);
 void dev_init_scheduler(struct net_device *dev);
 void dev_shutdown(struct net_device *dev);
 void dev_activate(struct net_device *dev);
index 74fd402d26ddeba725d7447b855f4d3c1fea8238..f930329f0dc26afbe55dd4365b8248c418328efc 100644 (file)
@@ -2921,6 +2921,8 @@ int netif_set_real_num_tx_queues(struct net_device *dev, unsigned int txq)
                if (dev->num_tc)
                        netif_setup_tc(dev, txq);
 
+               dev_qdisc_change_real_num_tx(dev, txq);
+
                dev->real_num_tx_queues = txq;
 
                if (disabling) {
index a8dd06c74e318cd23d1fb8b38e5032f0034666d2..66d2fbe9ef5014a4eb849008221091121ad71c08 100644 (file)
@@ -1330,6 +1330,15 @@ static int qdisc_change_tx_queue_len(struct net_device *dev,
        return 0;
 }
 
+void dev_qdisc_change_real_num_tx(struct net_device *dev,
+                                 unsigned int new_real_tx)
+{
+       struct Qdisc *qdisc = dev->qdisc;
+
+       if (qdisc->ops->change_real_num_tx)
+               qdisc->ops->change_real_num_tx(qdisc, new_real_tx);
+}
+
 int dev_qdisc_change_tx_queue_len(struct net_device *dev)
 {
        bool up = dev->flags & IFF_UP;
index e79f1afe0cfd6f55c2f0fdecf9c1e70bad0961e9..db18d8a860f9cc50608afe47d1b0fa9996295505 100644 (file)
@@ -125,6 +125,29 @@ static void mq_attach(struct Qdisc *sch)
        priv->qdiscs = NULL;
 }
 
+static void mq_change_real_num_tx(struct Qdisc *sch, unsigned int new_real_tx)
+{
+#ifdef CONFIG_NET_SCHED
+       struct net_device *dev = qdisc_dev(sch);
+       struct Qdisc *qdisc;
+       unsigned int i;
+
+       for (i = new_real_tx; i < dev->real_num_tx_queues; i++) {
+               qdisc = netdev_get_tx_queue(dev, i)->qdisc_sleeping;
+               /* Only update the default qdiscs we created,
+                * qdiscs with handles are always hashed.
+                */
+               if (qdisc != &noop_qdisc && !qdisc->handle)
+                       qdisc_hash_del(qdisc);
+       }
+       for (i = dev->real_num_tx_queues; i < new_real_tx; i++) {
+               qdisc = netdev_get_tx_queue(dev, i)->qdisc_sleeping;
+               if (qdisc != &noop_qdisc && !qdisc->handle)
+                       qdisc_hash_add(qdisc, false);
+       }
+#endif
+}
+
 static int mq_dump(struct Qdisc *sch, struct sk_buff *skb)
 {
        struct net_device *dev = qdisc_dev(sch);
@@ -288,6 +311,7 @@ struct Qdisc_ops mq_qdisc_ops __read_mostly = {
        .init           = mq_init,
        .destroy        = mq_destroy,
        .attach         = mq_attach,
+       .change_real_num_tx = mq_change_real_num_tx,
        .dump           = mq_dump,
        .owner          = THIS_MODULE,
 };
index 8766ab5b8788042df03b0b8cdb9e35734ef1a8a7..7f23a92849d5df1fc538fe8bd242b7c6fbf6e4be 100644 (file)
@@ -306,6 +306,28 @@ static void mqprio_attach(struct Qdisc *sch)
        priv->qdiscs = NULL;
 }
 
+static void mqprio_change_real_num_tx(struct Qdisc *sch,
+                                     unsigned int new_real_tx)
+{
+       struct net_device *dev = qdisc_dev(sch);
+       struct Qdisc *qdisc;
+       unsigned int i;
+
+       for (i = new_real_tx; i < dev->real_num_tx_queues; i++) {
+               qdisc = netdev_get_tx_queue(dev, i)->qdisc_sleeping;
+               /* Only update the default qdiscs we created,
+                * qdiscs with handles are always hashed.
+                */
+               if (qdisc != &noop_qdisc && !qdisc->handle)
+                       qdisc_hash_del(qdisc);
+       }
+       for (i = dev->real_num_tx_queues; i < new_real_tx; i++) {
+               qdisc = netdev_get_tx_queue(dev, i)->qdisc_sleeping;
+               if (qdisc != &noop_qdisc && !qdisc->handle)
+                       qdisc_hash_add(qdisc, false);
+       }
+}
+
 static struct netdev_queue *mqprio_queue_get(struct Qdisc *sch,
                                             unsigned long cl)
 {
@@ -623,6 +645,7 @@ static struct Qdisc_ops mqprio_qdisc_ops __read_mostly = {
        .init           = mqprio_init,
        .destroy        = mqprio_destroy,
        .attach         = mqprio_attach,
+       .change_real_num_tx = mqprio_change_real_num_tx,
        .dump           = mqprio_dump,
        .owner          = THIS_MODULE,
 };