linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Jakub Kicinski <kuba@kernel.org>,
	Matthew Massey <matthewmassey@fb.com>,
	Dave Taht <dave.taht@gmail.com>,
	"David S . Miller" <davem@davemloft.net>,
	Sasha Levin <sashal@kernel.org>,
	jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us,
	daniel@iogearbox.net, atenart@kernel.org, edumazet@google.com,
	alobakin@pm.me, weiwan@google.com, bjorn@kernel.org,
	arnd@arndb.de, memxor@gmail.com, netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 4.19 08/47] net: sched: update default qdisc visibility after Tx queue cnt changes
Date: Mon,  8 Nov 2021 12:49:52 -0500	[thread overview]
Message-ID: <20211108175031.1190422-8-sashal@kernel.org> (raw)
In-Reply-To: <20211108175031.1190422-1-sashal@kernel.org>

From: Jakub Kicinski <kuba@kernel.org>

[ Upstream commit 1e080f17750d1083e8a32f7b350584ae1cd7ff20 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/net/sch_generic.h |  4 ++++
 net/core/dev.c            |  2 ++
 net/sched/sch_generic.c   |  9 +++++++++
 net/sched/sch_mq.c        | 24 ++++++++++++++++++++++++
 net/sched/sch_mqprio.c    | 23 +++++++++++++++++++++++
 5 files changed, 62 insertions(+)

diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index d737a6a2600be..286bc674a6e79 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -216,6 +216,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 *);
@@ -547,6 +549,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);
diff --git a/net/core/dev.c b/net/core/dev.c
index 397bc2f50de08..2519a90a14827 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2648,6 +2648,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) {
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 4e15913e7519e..2128b77d5cb33 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -1256,6 +1256,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;
diff --git a/net/sched/sch_mq.c b/net/sched/sch_mq.c
index c008a316e9436..699b6bb444cea 100644
--- a/net/sched/sch_mq.c
+++ b/net/sched/sch_mq.c
@@ -130,6 +130,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);
@@ -285,6 +308,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,
 };
diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c
index fcfe41a954733..3fd0e5dd7ae3e 100644
--- a/net/sched/sch_mqprio.c
+++ b/net/sched/sch_mqprio.c
@@ -308,6 +308,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)
 {
@@ -632,6 +654,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,
 };
-- 
2.33.0


  parent reply	other threads:[~2021-11-09  1:14 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-08 17:49 [PATCH AUTOSEL 4.19 01/47] drm: panel-orientation-quirks: Add quirk for KD Kurio Smart C15200 2-in-1 Sasha Levin
2021-11-08 17:49 ` [PATCH AUTOSEL 4.19 02/47] Bluetooth: sco: Fix lock_sock() blockage by memcpy_from_msg() Sasha Levin
2021-11-08 17:49 ` [PATCH AUTOSEL 4.19 03/47] Bluetooth: fix use-after-free error in lock_sock_nested() Sasha Levin
2021-11-08 17:49 ` [PATCH AUTOSEL 4.19 04/47] platform/x86: wmi: do not fail if disabling fails Sasha Levin
2021-11-08 17:49 ` [PATCH AUTOSEL 4.19 05/47] MIPS: lantiq: dma: add small delay after reset Sasha Levin
2021-11-08 17:49 ` [PATCH AUTOSEL 4.19 06/47] MIPS: lantiq: dma: reset correct number of channel Sasha Levin
2021-11-08 17:49 ` [PATCH AUTOSEL 4.19 07/47] locking/lockdep: Avoid RCU-induced noinstr fail Sasha Levin
2021-11-08 17:49 ` Sasha Levin [this message]
2021-11-08 17:49 ` [PATCH AUTOSEL 4.19 09/47] smackfs: Fix use-after-free in netlbl_catmap_walk() Sasha Levin
2021-11-08 17:49 ` [PATCH AUTOSEL 4.19 10/47] NET: IPV4: fix error "do not initialise globals to 0" Sasha Levin
2021-11-09  1:49   ` Joe Perches
2021-11-14 14:13     ` Sasha Levin
2021-11-08 17:49 ` [PATCH AUTOSEL 4.19 11/47] x86: Increase exception stack sizes Sasha Levin
2021-11-08 17:49 ` [PATCH AUTOSEL 4.19 12/47] mwifiex: Run SET_BSS_MODE when changing from P2P to STATION vif-type Sasha Levin
2021-11-08 17:49 ` [PATCH AUTOSEL 4.19 13/47] mwifiex: Properly initialize private structure on interface type changes Sasha Levin
2021-11-08 17:49 ` [PATCH AUTOSEL 4.19 14/47] media: mt9p031: Fix corrupted frame after restarting stream Sasha Levin
2021-11-08 17:49 ` [PATCH AUTOSEL 4.19 15/47] media: netup_unidvb: handle interrupt properly according to the firmware Sasha Levin
2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 16/47] media: uvcvideo: Set capability in s_param Sasha Levin
2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 17/47] media: uvcvideo: Return -EIO for control errors Sasha Levin
2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 18/47] media: s5p-mfc: fix possible null-pointer dereference in s5p_mfc_probe() Sasha Levin
2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 19/47] media: s5p-mfc: Add checking to s5p_mfc_probe() Sasha Levin
2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 20/47] media: mceusb: return without resubmitting URB in case of -EPROTO error Sasha Levin
2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 21/47] ia64: don't do IA64_CMPXCHG_DEBUG without CONFIG_PRINTK Sasha Levin
2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 22/47] media: rcar-csi2: Add checking to rcsi2_start_receiver() Sasha Levin
2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 23/47] ACPICA: Avoid evaluating methods too early during system resume Sasha Levin
2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 24/47] media: usb: dvd-usb: fix uninit-value bug in dibusb_read_eeprom_byte() Sasha Levin
2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 25/47] tracefs: Have tracefs directories not set OTH permission bits by default Sasha Levin
2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 26/47] ath: dfs_pattern_detector: Fix possible null-pointer dereference in channel_detector_create() Sasha Levin
2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 27/47] ACPI: battery: Accept charges over the design capacity as full Sasha Levin
2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 28/47] leaking_addresses: Always print a trailing newline Sasha Levin
2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 29/47] memstick: r592: Fix a UAF bug when removing the driver Sasha Levin
2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 30/47] lib/xz: Avoid overlapping memcpy() with invalid input with in-place decompression Sasha Levin
2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 31/47] lib/xz: Validate the value before assigning it to an enum variable Sasha Levin
2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 32/47] workqueue: make sysfs of unbound kworker cpumask more clever Sasha Levin
2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 33/47] tracing/cfi: Fix cmp_entries_* functions signature mismatch Sasha Levin
2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 34/47] mwl8k: Fix use-after-free in mwl8k_fw_state_machine() Sasha Levin
2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 35/47] PM: hibernate: Get block device exclusively in swsusp_check() Sasha Levin
2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 36/47] iwlwifi: mvm: disable RX-diversity in powersave Sasha Levin
2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 37/47] smackfs: use __GFP_NOFAIL for smk_cipso_doi() Sasha Levin
2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 38/47] ARM: clang: Do not rely on lr register for stacktrace Sasha Levin
2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 39/47] gre/sit: Don't generate link-local addr if addr_gen_mode is IN6_ADDR_GEN_MODE_NONE Sasha Levin
2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 40/47] ARM: 9136/1: ARMv7-M uses BE-8, not BE-32 Sasha Levin
2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 41/47] arm64/sve: Add stub for sve_max_virtualisable_vl() Sasha Levin
2021-11-09 13:20   ` Catalin Marinas
2021-11-14 14:04     ` Sasha Levin
2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 42/47] spi: bcm-qspi: Fix missing clk_disable_unprepare() on error in bcm_qspi_probe() Sasha Levin
2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 43/47] x86/hyperv: Protect set_hv_tscchange_cb() against getting preempted Sasha Levin
2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 44/47] parisc: fix warning in flush_tlb_all Sasha Levin
2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 45/47] task_stack: Fix end_of_stack() for architectures with upwards-growing stack Sasha Levin
2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 46/47] parisc/unwind: fix unwinder when CONFIG_64BIT is enabled Sasha Levin
2021-11-08 17:50 ` [PATCH AUTOSEL 4.19 47/47] parisc/kgdb: add kgdb_roundup() to make kgdb work with idle polling Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211108175031.1190422-8-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=alobakin@pm.me \
    --cc=arnd@arndb.de \
    --cc=atenart@kernel.org \
    --cc=bjorn@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=dave.taht@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthewmassey@fb.com \
    --cc=memxor@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=weiwan@google.com \
    --cc=xiyou.wangcong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).