* [PATCH] xfrm: replace xfrm_policy_afinfo_lock spinlock with mutex
@ 2013-07-04 6:53 Fan Du
2013-07-04 7:54 ` Cong Wang
2013-07-04 9:50 ` Eric Dumazet
0 siblings, 2 replies; 3+ messages in thread
From: Fan Du @ 2013-07-04 6:53 UTC (permalink / raw)
To: steffen.klassert; +Cc: herbert, davem, netdev
Signed-off-by: Fan Du <fan.du@windriver.com>
---
net/xfrm/xfrm_policy.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index e52cab3..27768ba 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -46,7 +46,7 @@ static DEFINE_SPINLOCK(xfrm_policy_sk_bundle_lock);
static struct dst_entry *xfrm_policy_sk_bundles;
static DEFINE_RWLOCK(xfrm_policy_lock);
-static DEFINE_SPINLOCK(xfrm_policy_afinfo_lock);
+static DEFINE_MUTEX(xfrm_policy_afinfo_lock);
static struct xfrm_policy_afinfo __rcu *xfrm_policy_afinfo[NPROTO]
__read_mostly;
@@ -2687,7 +2687,7 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
return -EINVAL;
if (unlikely(afinfo->family >= NPROTO))
return -EAFNOSUPPORT;
- spin_lock(&xfrm_policy_afinfo_lock);
+ mutex_lock(&xfrm_policy_afinfo_lock);
if (unlikely(xfrm_policy_afinfo[afinfo->family] != NULL))
err = -ENOBUFS;
else {
@@ -2710,7 +2710,7 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
afinfo->garbage_collect = xfrm_garbage_collect_deferred;
rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
}
- spin_unlock(&xfrm_policy_afinfo_lock);
+ mutex_unlock(&xfrm_policy_afinfo_lock);
rtnl_lock();
for_each_net(net) {
@@ -2743,7 +2743,7 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
return -EINVAL;
if (unlikely(afinfo->family >= NPROTO))
return -EAFNOSUPPORT;
- spin_lock(&xfrm_policy_afinfo_lock);
+ mutex_lock(&xfrm_policy_afinfo_lock);
if (likely(xfrm_policy_afinfo[afinfo->family] != NULL)) {
if (unlikely(xfrm_policy_afinfo[afinfo->family] != afinfo))
err = -EINVAL;
@@ -2751,7 +2751,7 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
RCU_INIT_POINTER(xfrm_policy_afinfo[afinfo->family],
NULL);
}
- spin_unlock(&xfrm_policy_afinfo_lock);
+ mutex_unlock(&xfrm_policy_afinfo_lock);
if (!err) {
struct dst_ops *dst_ops = afinfo->dst_ops;
--
1.7.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] xfrm: replace xfrm_policy_afinfo_lock spinlock with mutex
2013-07-04 6:53 [PATCH] xfrm: replace xfrm_policy_afinfo_lock spinlock with mutex Fan Du
@ 2013-07-04 7:54 ` Cong Wang
2013-07-04 9:50 ` Eric Dumazet
1 sibling, 0 replies; 3+ messages in thread
From: Cong Wang @ 2013-07-04 7:54 UTC (permalink / raw)
To: netdev
On Thu, 04 Jul 2013 at 06:53 GMT, Fan Du <fan.du@windriver.com> wrote:
> Signed-off-by: Fan Du <fan.du@windriver.com>
Reason?
What problem did you meet?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] xfrm: replace xfrm_policy_afinfo_lock spinlock with mutex
2013-07-04 6:53 [PATCH] xfrm: replace xfrm_policy_afinfo_lock spinlock with mutex Fan Du
2013-07-04 7:54 ` Cong Wang
@ 2013-07-04 9:50 ` Eric Dumazet
1 sibling, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2013-07-04 9:50 UTC (permalink / raw)
To: Fan Du; +Cc: steffen.klassert, herbert, davem, netdev
On Thu, 2013-07-04 at 14:53 +0800, Fan Du wrote:
> Signed-off-by: Fan Du <fan.du@windriver.com>
> ---
> net/xfrm/xfrm_policy.c | 10 +++++-----
> 1 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
> index e52cab3..27768ba 100644
> --- a/net/xfrm/xfrm_policy.c
> +++ b/net/xfrm/xfrm_policy.c
> @@ -46,7 +46,7 @@ static DEFINE_SPINLOCK(xfrm_policy_sk_bundle_lock);
> static struct dst_entry *xfrm_policy_sk_bundles;
> static DEFINE_RWLOCK(xfrm_policy_lock);
>
> -static DEFINE_SPINLOCK(xfrm_policy_afinfo_lock);
> +static DEFINE_MUTEX(xfrm_policy_afinfo_lock);
Why is it needed, and why is it safe ?
Is it a bug fix ? If answer is no please read :
http://www.spinics.net/lists/netdev/msg242161.html
This mutex or spinlock is not really needed anyway.
Check commit e0386005ff2a729 for a starting point.
("net: inet_add_protocol() can use cmpxchg()")
But do not send a patch until David reopens net-next.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-07-04 9:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-04 6:53 [PATCH] xfrm: replace xfrm_policy_afinfo_lock spinlock with mutex Fan Du
2013-07-04 7:54 ` Cong Wang
2013-07-04 9:50 ` Eric Dumazet
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.