All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net/sched: taprio: remove unnecessary taprio_list_lock
@ 2022-09-21  9:56 Vladimir Oltean
  2022-09-21 23:09 ` Vinicius Costa Gomes
  2022-09-23  0:40 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 4+ messages in thread
From: Vladimir Oltean @ 2022-09-21  9:56 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

The 3 functions that want access to the taprio_list:
taprio_dev_notifier(), taprio_destroy() and taprio_init() are all called
with the rtnl_mutex held, therefore implicitly serialized with respect
to each other. A spin lock serves no purpose.

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

diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c
index 1ab92968c1e3..163255e0cd77 100644
--- a/net/sched/sch_taprio.c
+++ b/net/sched/sch_taprio.c
@@ -27,7 +27,6 @@
 #include <net/tcp.h>
 
 static LIST_HEAD(taprio_list);
-static DEFINE_SPINLOCK(taprio_list_lock);
 
 #define TAPRIO_ALL_GATES_OPEN -1
 
@@ -1082,7 +1081,6 @@ static int taprio_dev_notifier(struct notifier_block *nb, unsigned long event,
 	if (event != NETDEV_UP && event != NETDEV_CHANGE)
 		return NOTIFY_DONE;
 
-	spin_lock(&taprio_list_lock);
 	list_for_each_entry(q, &taprio_list, taprio_list) {
 		qdev = qdisc_dev(q->root);
 		if (qdev == dev) {
@@ -1090,7 +1088,6 @@ static int taprio_dev_notifier(struct notifier_block *nb, unsigned long event,
 			break;
 		}
 	}
-	spin_unlock(&taprio_list_lock);
 
 	if (found)
 		taprio_set_picos_per_byte(dev, q);
@@ -1602,9 +1599,7 @@ static void taprio_destroy(struct Qdisc *sch)
 	struct sched_gate_list *oper, *admin;
 	unsigned int i;
 
-	spin_lock(&taprio_list_lock);
 	list_del(&q->taprio_list);
-	spin_unlock(&taprio_list_lock);
 
 	/* Note that taprio_reset() might not be called if an error
 	 * happens in qdisc_create(), after taprio_init() has been called.
@@ -1653,9 +1648,7 @@ static int taprio_init(struct Qdisc *sch, struct nlattr *opt,
 	q->clockid = -1;
 	q->flags = TAPRIO_FLAGS_INVALID;
 
-	spin_lock(&taprio_list_lock);
 	list_add(&q->taprio_list, &taprio_list);
-	spin_unlock(&taprio_list_lock);
 
 	if (sch->parent != TC_H_ROOT) {
 		NL_SET_ERR_MSG_MOD(extack, "Can only be attached as root qdisc");
-- 
2.34.1


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

* Re: [PATCH net-next] net/sched: taprio: remove unnecessary taprio_list_lock
  2022-09-21  9:56 [PATCH net-next] net/sched: taprio: remove unnecessary taprio_list_lock Vladimir Oltean
@ 2022-09-21 23:09 ` Vinicius Costa Gomes
  2022-09-22 22:31   ` Vladimir Oltean
  2022-09-23  0:40 ` patchwork-bot+netdevbpf
  1 sibling, 1 reply; 4+ messages in thread
From: Vinicius Costa Gomes @ 2022-09-21 23:09 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:

> The 3 functions that want access to the taprio_list:
> taprio_dev_notifier(), taprio_destroy() and taprio_init() are all called
> with the rtnl_mutex held, therefore implicitly serialized with respect
> to each other. A spin lock serves no purpose.
>
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> ---
>  net/sched/sch_taprio.c | 7 -------
>  1 file changed, 7 deletions(-)
>
> diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c
> index 1ab92968c1e3..163255e0cd77 100644
> --- a/net/sched/sch_taprio.c
> +++ b/net/sched/sch_taprio.c
> @@ -27,7 +27,6 @@
>  #include <net/tcp.h>
>  
>  static LIST_HEAD(taprio_list);
> -static DEFINE_SPINLOCK(taprio_list_lock);
>  
>  #define TAPRIO_ALL_GATES_OPEN -1
>  
> @@ -1082,7 +1081,6 @@ static int taprio_dev_notifier(struct notifier_block *nb, unsigned long event,
>  	if (event != NETDEV_UP && event != NETDEV_CHANGE)
>  		return NOTIFY_DONE;
>  
> -	spin_lock(&taprio_list_lock);
>  	list_for_each_entry(q, &taprio_list, taprio_list) {
>  		qdev = qdisc_dev(q->root);
>  		if (qdev == dev) {

Optional simplification: do you mind removing 'found' and moving the
call to taprio_set_picos_per_byte() here?

Anyway,

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

> @@ -1090,7 +1088,6 @@ static int taprio_dev_notifier(struct notifier_block *nb, unsigned long event,
>  			break;
>  		}
>  	}
> -	spin_unlock(&taprio_list_lock);
>  
>  	if (found)
>  		taprio_set_picos_per_byte(dev, q);
> @@ -1602,9 +1599,7 @@ static void taprio_destroy(struct Qdisc *sch)
>  	struct sched_gate_list *oper, *admin;
>  	unsigned int i;
>  
> -	spin_lock(&taprio_list_lock);
>  	list_del(&q->taprio_list);
> -	spin_unlock(&taprio_list_lock);
>  
>  	/* Note that taprio_reset() might not be called if an error
>  	 * happens in qdisc_create(), after taprio_init() has been called.
> @@ -1653,9 +1648,7 @@ static int taprio_init(struct Qdisc *sch, struct nlattr *opt,
>  	q->clockid = -1;
>  	q->flags = TAPRIO_FLAGS_INVALID;
>  
> -	spin_lock(&taprio_list_lock);
>  	list_add(&q->taprio_list, &taprio_list);
> -	spin_unlock(&taprio_list_lock);
>  
>  	if (sch->parent != TC_H_ROOT) {
>  		NL_SET_ERR_MSG_MOD(extack, "Can only be attached as root qdisc");
> -- 
> 2.34.1
>


Cheers,
-- 
Vinicius

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

* Re: [PATCH net-next] net/sched: taprio: remove unnecessary taprio_list_lock
  2022-09-21 23:09 ` Vinicius Costa Gomes
@ 2022-09-22 22:31   ` Vladimir Oltean
  0 siblings, 0 replies; 4+ messages in thread
From: Vladimir Oltean @ 2022-09-22 22:31 UTC (permalink / raw)
  To: Vinicius Costa Gomes
  Cc: netdev, Jamal Hadi Salim, Cong Wang, Jiri Pirko, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, linux-kernel

On Wed, Sep 21, 2022 at 04:09:55PM -0700, Vinicius Costa Gomes wrote:
> Optional simplification: do you mind removing 'found' and moving the
> call to taprio_set_picos_per_byte() here?

Yes, I can do that (in a follow-up patch).

> Anyway,
> 
> Acked-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>

Thanks.

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

* Re: [PATCH net-next] net/sched: taprio: remove unnecessary taprio_list_lock
  2022-09-21  9:56 [PATCH net-next] net/sched: taprio: remove unnecessary taprio_list_lock Vladimir Oltean
  2022-09-21 23:09 ` Vinicius Costa Gomes
@ 2022-09-23  0:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-09-23  0:40 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 Wed, 21 Sep 2022 12:56:31 +0300 you wrote:
> The 3 functions that want access to the taprio_list:
> taprio_dev_notifier(), taprio_destroy() and taprio_init() are all called
> with the rtnl_mutex held, therefore implicitly serialized with respect
> to each other. A spin lock serves no purpose.
> 
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> 
> [...]

Here is the summary with links:
  - [net-next] net/sched: taprio: remove unnecessary taprio_list_lock
    https://git.kernel.org/netdev/net-next/c/a2c2a4ddc27d

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] 4+ messages in thread

end of thread, other threads:[~2022-09-23  0:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-21  9:56 [PATCH net-next] net/sched: taprio: remove unnecessary taprio_list_lock Vladimir Oltean
2022-09-21 23:09 ` Vinicius Costa Gomes
2022-09-22 22:31   ` Vladimir Oltean
2022-09-23  0:40 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.