Re: Fwd: [PATCH 1/1] team: remove unnecessary lock
From: Jiri Pirko <jiri@resnulli.us>
Date: 2016-05-27 14:58:01
Fri, May 27, 2016 at 04:25:29AM CEST, zyjzyj2000@gmail.com wrote:
Hi, Jiri
I delved into the source code of team. And I found that the function
team_add_slave actually works in the protection of rtnl lock. So in my
humble opinion, it is not necessary to use the mutex lock to protect
team_port_add again.
And I made tests in ubuntu 16.04 server, without the mutex lock, the
team_add_slave can also work well.
The steps:
1.
nmcli con add type team con-name team0 ifname team0 config
'{"runner":{"name":"activebackup"}}'
2.
nmcli con add type team-slave con-name team0-port1 ifname eno16777736
master team0
nmcli con add type team-slave con-name team0-port2 ifname eno33554960
master team0
The above test can work well without the mutex lock. So I made the
following patch, please comment on this patch.Well, team lock could be replaced by rtnl and removed. Removing just this tiny usage solves nothing. I decided to use team-specific lock to do not overload rtnl at the beginning.
quoted hunk
Thanks a lot. Zhu Yanjun From: Zhu Yanjun<zyjzyj2000@gmail.com> The function team_add_slave works in the context of the rtnl lock. It is not necessary to use the mutex lock since the rtnl lock is enough. Signed-off-by: Zhu Yanjun <zyjzyj2000@gmail.com> --- drivers/net/team/team.c | 2 -- 1 file changed, 2 deletions(-)diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c index a0f64cb..ad84069 100644 --- a/drivers/net/team/team.c +++ b/drivers/net/team/team.c@@ -1936,9 +1936,7 @@ static int team_add_slave(struct net_device *dev,struct net_device *port_dev) struct team *team = netdev_priv(dev); int err; - mutex_lock(&team->lock); err = team_port_add(team, port_dev); - mutex_unlock(&team->lock); return err; } -- 1.9.1