diff mbox

[net-next] ipv6: remove useless spin_lock/spin_unlock

Message ID 547E6832.4070403@cn.fujitsu.com
State Superseded, archived
Delegated to: David Miller
Headers show

Commit Message

Duan Jiong Dec. 3, 2014, 1:32 a.m. UTC
xchg is atomic, so there is no necessary to use spin_lock/spin_unlock
to protect it.

Signed-off-by: Duan Jiong <duanj.fnst@cn.fujitsu.com>
---
 net/ipv6/ipv6_sockglue.c | 2 --
 1 file changed, 2 deletions(-)

Comments

Eric Dumazet Dec. 3, 2014, 1:57 a.m. UTC | #1
On Wed, 2014-12-03 at 09:32 +0800, Duan Jiong wrote:
> xchg is atomic, so there is no necessary to use spin_lock/spin_unlock
> to protect it.
> 
> Signed-off-by: Duan Jiong <duanj.fnst@cn.fujitsu.com>
> ---
>  net/ipv6/ipv6_sockglue.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
> index e1a9583..92ca907 100644
> --- a/net/ipv6/ipv6_sockglue.c
> +++ b/net/ipv6/ipv6_sockglue.c
> @@ -112,9 +112,7 @@ struct ipv6_txoptions *ipv6_update_options(struct sock *sk,
>  		}
>  		opt = xchg(&inet6_sk(sk)->opt, opt);
>  	} else {
> -		spin_lock(&sk->sk_dst_lock);
>  		opt = xchg(&inet6_sk(sk)->opt, opt);
> -		spin_unlock(&sk->sk_dst_lock);
>  	}
>  	sk_dst_reset(sk);
>  

Why keeping 2 copies of opt = xchg(&inet6_sk(sk)->opt, opt); then ?



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Duan Jiong Dec. 3, 2014, 2:05 a.m. UTC | #2
On 12/03/2014 09:57 AM, Eric Dumazet wrote:
> On Wed, 2014-12-03 at 09:32 +0800, Duan Jiong wrote:
>> xchg is atomic, so there is no necessary to use spin_lock/spin_unlock
>> to protect it.
>>
>> Signed-off-by: Duan Jiong <duanj.fnst@cn.fujitsu.com>
>> ---
>>  net/ipv6/ipv6_sockglue.c | 2 --
>>  1 file changed, 2 deletions(-)
>>
>> diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
>> index e1a9583..92ca907 100644
>> --- a/net/ipv6/ipv6_sockglue.c
>> +++ b/net/ipv6/ipv6_sockglue.c
>> @@ -112,9 +112,7 @@ struct ipv6_txoptions *ipv6_update_options(struct sock *sk,
>>  		}
>>  		opt = xchg(&inet6_sk(sk)->opt, opt);
>>  	} else {
>> -		spin_lock(&sk->sk_dst_lock);
>>  		opt = xchg(&inet6_sk(sk)->opt, opt);
>> -		spin_unlock(&sk->sk_dst_lock);
>>  	}
>>  	sk_dst_reset(sk);
>>  
> 
> Why keeping 2 copies of opt = xchg(&inet6_sk(sk)->opt, opt); then ?
> 

Thanks for you remind, i didn't notice that.
The else statement could be removed, opt = xchg(&inet6_sk(sk)->opt, opt); should be
moved out, and i will send v2.

Thanks,
  Duan

> 
> 
> 

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index e1a9583..92ca907 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -112,9 +112,7 @@  struct ipv6_txoptions *ipv6_update_options(struct sock *sk,
 		}
 		opt = xchg(&inet6_sk(sk)->opt, opt);
 	} else {
-		spin_lock(&sk->sk_dst_lock);
 		opt = xchg(&inet6_sk(sk)->opt, opt);
-		spin_unlock(&sk->sk_dst_lock);
 	}
 	sk_dst_reset(sk);