linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net/sched: taprio: simplify list iteration in taprio_dev_notifier()
@ 2022-09-23 14:59 Vladimir Oltean
  2022-09-26 18:21 ` Vinicius Costa Gomes
  2022-09-26 19:50 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Vladimir Oltean @ 2022-09-23 14:59 UTC (permalink / raw)
  To: netdev
  Cc: Vinicius Costa Gomes, Jamal Hadi Salim, Cong Wang, Jiri Pirko,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	linux-kernel

taprio_dev_notifier() subscribes to netdev state changes in order to
determine whether interfaces which have a taprio root qdisc have changed
their link speed, so the internal calculations can be adapted properly.

The 'qdev' temporary variable serves no purpose, because we just use it
only once, and can just as well use qdisc_dev(q->root) directly (or the
"dev" that comes from the netdev notifier; this is because qdev is only
interesting if it was the subject of the state change, _and_ its root
qdisc belongs in the taprio list).

The 'found' variable also doesn't really serve too much of a purpose
either; we can just call taprio_set_picos_per_byte() within the loop,
and exit immediately afterwards.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 net/sched/sch_taprio.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c
index 136ae21ebce9..0bc6d90e1e51 100644
--- a/net/sched/sch_taprio.c
+++ b/net/sched/sch_taprio.c
@@ -1072,9 +1072,7 @@ static int taprio_dev_notifier(struct notifier_block *nb, unsigned long event,
 			       void *ptr)
 {
 	struct net_device *dev = netdev_notifier_info_to_dev(ptr);
-	struct net_device *qdev;
 	struct taprio_sched *q;
-	bool found = false;
 
 	ASSERT_RTNL();
 
@@ -1082,15 +1080,12 @@ static int taprio_dev_notifier(struct notifier_block *nb, unsigned long event,
 		return NOTIFY_DONE;
 
 	list_for_each_entry(q, &taprio_list, taprio_list) {
-		qdev = qdisc_dev(q->root);
-		if (qdev == dev) {
-			found = true;
-			break;
-		}
-	}
+		if (dev != qdisc_dev(q->root))
+			continue;
 
-	if (found)
 		taprio_set_picos_per_byte(dev, q);
+		break;
+	}
 
 	return NOTIFY_DONE;
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] net/sched: taprio: simplify list iteration in taprio_dev_notifier()
  2022-09-23 14:59 [PATCH net-next] net/sched: taprio: simplify list iteration in taprio_dev_notifier() Vladimir Oltean
@ 2022-09-26 18:21 ` Vinicius Costa Gomes
  2022-09-26 19:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Vinicius Costa Gomes @ 2022-09-26 18:21 UTC (permalink / raw)
  To: Vladimir Oltean, netdev
  Cc: Jamal Hadi Salim, Cong Wang, Jiri Pirko, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, linux-kernel

Vladimir Oltean <vladimir.oltean@nxp.com> writes:

> taprio_dev_notifier() subscribes to netdev state changes in order to
> determine whether interfaces which have a taprio root qdisc have changed
> their link speed, so the internal calculations can be adapted properly.
>
> The 'qdev' temporary variable serves no purpose, because we just use it
> only once, and can just as well use qdisc_dev(q->root) directly (or the
> "dev" that comes from the netdev notifier; this is because qdev is only
> interesting if it was the subject of the state change, _and_ its root
> qdisc belongs in the taprio list).
>
> The 'found' variable also doesn't really serve too much of a purpose
> either; we can just call taprio_set_picos_per_byte() within the loop,
> and exit immediately afterwards.
>
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> ---

Thanks,

Reviewed-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>


Cheers,
-- 
Vinicius

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] net/sched: taprio: simplify list iteration in taprio_dev_notifier()
  2022-09-23 14:59 [PATCH net-next] net/sched: taprio: simplify list iteration in taprio_dev_notifier() Vladimir Oltean
  2022-09-26 18:21 ` Vinicius Costa Gomes
@ 2022-09-26 19:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-09-26 19:50 UTC (permalink / raw)
  To: Vladimir Oltean
  Cc: netdev, vinicius.gomes, jhs, xiyou.wangcong, jiri, davem,
	edumazet, kuba, pabeni, linux-kernel

Hello:

This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Fri, 23 Sep 2022 17:59:21 +0300 you wrote:
> taprio_dev_notifier() subscribes to netdev state changes in order to
> determine whether interfaces which have a taprio root qdisc have changed
> their link speed, so the internal calculations can be adapted properly.
> 
> The 'qdev' temporary variable serves no purpose, because we just use it
> only once, and can just as well use qdisc_dev(q->root) directly (or the
> "dev" that comes from the netdev notifier; this is because qdev is only
> interesting if it was the subject of the state change, _and_ its root
> qdisc belongs in the taprio list).
> 
> [...]

Here is the summary with links:
  - [net-next] net/sched: taprio: simplify list iteration in taprio_dev_notifier()
    https://git.kernel.org/netdev/net-next/c/fc4f2fd02a1a

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-09-26 19:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-23 14:59 [PATCH net-next] net/sched: taprio: simplify list iteration in taprio_dev_notifier() Vladimir Oltean
2022-09-26 18:21 ` Vinicius Costa Gomes
2022-09-26 19:50 ` patchwork-bot+netdevbpf

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).