Skip to content

Commit

Permalink
net: sched: make newly activated qdiscs visible
Browse files Browse the repository at this point in the history
In their .attach callback, mq[prio] only add the qdiscs of the currently
active TX queues to the device's qdisc hash list.
If a user later increases the number of active TX queues, their qdiscs
are not visible via eg. 'tc qdisc show'.

Add a hook to netif_set_real_num_tx_queues() that walks all active
TX queues and adds those which are missing to the hash list.

CC: Eric Dumazet <edumazet@google.com>
CC: Jamal Hadi Salim <jhs@mojatatu.com>
CC: Cong Wang <xiyou.wangcong@gmail.com>
CC: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Julian Wiedmann authored and David S. Miller committed Mar 12, 2020
1 parent dacf470 commit 4cda752
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/net/sch_generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ static inline bool qdisc_is_empty(const struct Qdisc *qdisc)
return !READ_ONCE(qdisc->q.qlen);
}

static inline bool qdisc_hashed(struct Qdisc *qdisc)
{
return hash_hashed(&qdisc->hash);
}

static inline bool qdisc_run_begin(struct Qdisc *qdisc)
{
if (qdisc->flags & TCQ_F_NOLOCK) {
Expand Down Expand Up @@ -629,6 +634,7 @@ 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_set_real_num_tx_queues(struct net_device *dev);
void dev_init_scheduler(struct net_device *dev);
void dev_shutdown(struct net_device *dev);
void dev_activate(struct net_device *dev);
Expand Down
1 change: 1 addition & 0 deletions net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -2875,6 +2875,7 @@ int netif_set_real_num_tx_queues(struct net_device *dev, unsigned int txq)
netif_setup_tc(dev, txq);

dev->real_num_tx_queues = txq;
dev_qdisc_set_real_num_tx_queues(dev);

if (disabling) {
synchronize_net();
Expand Down
21 changes: 21 additions & 0 deletions net/sched/sch_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1268,6 +1268,27 @@ int dev_qdisc_change_tx_queue_len(struct net_device *dev)
return ret;
}

void dev_qdisc_set_real_num_tx_queues(struct net_device *dev)
{
#ifdef CONFIG_NET_SCHED
struct Qdisc *sch = dev->qdisc;
unsigned int ntx;

if (!sch)
return;

ASSERT_RTNL();

for (ntx = 0; ntx < dev->real_num_tx_queues; ntx++) {
struct netdev_queue *dev_queue = netdev_get_tx_queue(dev, ntx);
struct Qdisc *qdisc = dev_queue->qdisc;

if (qdisc && !qdisc_hashed(qdisc))
qdisc_hash_add(qdisc, false);
}
#endif
}

static void dev_init_scheduler_queue(struct net_device *dev,
struct netdev_queue *dev_queue,
void *_qdisc)
Expand Down

0 comments on commit 4cda752

Please sign in to comment.