* [PATCH-rt 1/1] Fix spinlock issue in net/core/sock.c
@ 2009-06-25 12:07 Vivek Satpute
2009-06-29 11:57 ` Jan Blunck
2009-12-27 8:15 ` Vivek Satpute
0 siblings, 2 replies; 4+ messages in thread
From: Vivek Satpute @ 2009-06-25 12:07 UTC (permalink / raw)
To: linux-rt-users; +Cc: prtproj, Thomas Gleixner
Kernel panic's and reboot while doing network operations such ifconfig
and ping on MIPS architecture after RT-patches applied.
In case of CONFIG_PREEMPT_RT, after releasing the lock with
"spin_unlock", context switch might occur before enabling the bottom
half with local_bh_enable and this causes the kernel to panic.
The issue is resolved by releasing the lock afer acquiring the mutex
using spin_unlock_bh.
Tested the fix on MIPS and X86 architecture.
Signed-off-by: Vivek Satpute <vivek@linsyssoft.com>
---
net/core/sock.c | 8 ++++++++
1 file changed, 8 insertions(+)
Index: linux-2.6.28.4/net/core/sock.c
===================================================================
--- linux-2.6.28.4.orig/net/core/sock.c
+++ linux-2.6.28.4/net/core/sock.c
@@ -1752,12 +1752,20 @@ void lock_sock_nested(struct sock *sk, i
if (sk->sk_lock.owned)
__lock_sock(sk);
sk->sk_lock.owned = 1;
+
+#ifndef CONFIG_PREEMPT_RT
spin_unlock(&sk->sk_lock.slock);
+#endif
/*
* The sk_lock has mutex_lock() semantics here:
*/
mutex_acquire(&sk->sk_lock.dep_map, subclass, 0, _RET_IP_);
+
+#ifdef CONFIG_PREEMPT_RT
+ spin_unlock_bh(&sk->sk_lock.slock);
+#else
local_bh_enable();
+#endif
}
EXPORT_SYMBOL(lock_sock_nested);
Thanks and Regards,
Vivek Satpute
System Software Engineer
LinSysSoft Technologies, Pune
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH-rt 1/1] Fix spinlock issue in net/core/sock.c
2009-06-25 12:07 [PATCH-rt 1/1] Fix spinlock issue in net/core/sock.c Vivek Satpute
@ 2009-06-29 11:57 ` Jan Blunck
[not found] ` <fae6a9700906290649j176493f7u39c4ce674a3a66fc@mail.gmail.com>
2009-12-27 8:15 ` Vivek Satpute
1 sibling, 1 reply; 4+ messages in thread
From: Jan Blunck @ 2009-06-29 11:57 UTC (permalink / raw)
To: Vivek Satpute; +Cc: linux-rt-users, prtproj, Thomas Gleixner
On Thu, Jun 25, 2009 at 2:07 PM, Vivek Satpute<vivek@linsyssoft.com> wrote:
> Kernel panic's and reboot while doing network operations such ifconfig
> and ping on MIPS architecture after RT-patches applied.
>
> In case of CONFIG_PREEMPT_RT, after releasing the lock with
> "spin_unlock", context switch might occur before enabling the bottom
> half with local_bh_enable and this causes the kernel to panic.
> The issue is resolved by releasing the lock afer acquiring the mutex
> using spin_unlock_bh.
>
> Tested the fix on MIPS and X86 architecture.
>
> Signed-off-by: Vivek Satpute <vivek@linsyssoft.com>
> ---
> net/core/sock.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> Index: linux-2.6.28.4/net/core/sock.c
> ===================================================================
> --- linux-2.6.28.4.orig/net/core/sock.c
> +++ linux-2.6.28.4/net/core/sock.c
> @@ -1752,12 +1752,20 @@ void lock_sock_nested(struct sock *sk, i
> if (sk->sk_lock.owned)
> __lock_sock(sk);
> sk->sk_lock.owned = 1;
> +
> +#ifndef CONFIG_PREEMPT_RT
> spin_unlock(&sk->sk_lock.slock);
> +#endif
> /*
> * The sk_lock has mutex_lock() semantics here:
> */
> mutex_acquire(&sk->sk_lock.dep_map, subclass, 0, _RET_IP_);
> +
> +#ifdef CONFIG_PREEMPT_RT
> + spin_unlock_bh(&sk->sk_lock.slock);
> +#else
> local_bh_enable();
> +#endif
> }
>
I don't think you should move the unlock after the mutex_acquire(). I
guess that this will lead to false positive lockdep warnings.
Anyway, I wonder why using spin_unlock_bh() is fixing the problem that
you are having. Do you have more context about the problem or maybe an
Oops or so?
Thanks,
Jan
> EXPORT_SYMBOL(lock_sock_nested);
>
>
>
>
> Thanks and Regards,
> Vivek Satpute
> System Software Engineer
> LinSysSoft Technologies, Pune
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH-rt 1/1] Fix spinlock issue in net/core/sock.c
2009-06-25 12:07 [PATCH-rt 1/1] Fix spinlock issue in net/core/sock.c Vivek Satpute
2009-06-29 11:57 ` Jan Blunck
@ 2009-12-27 8:15 ` Vivek Satpute
1 sibling, 0 replies; 4+ messages in thread
From: Vivek Satpute @ 2009-12-27 8:15 UTC (permalink / raw)
To: linux-rt-users
Hi,
I want to keep this thread alive. Has anyone encountered/tested this
issue ?
Thanks and Regards,
Vivek Satpute
System Software Engineer
LinSysSoft Technologies, Pune
On Thu, 2009-06-25 at 17:37 +0530, Vivek Satpute wrote:
> Kernel panic's and reboot while doing network operations such ifconfig
> and ping on MIPS architecture after RT-patches applied.
>
> In case of CONFIG_PREEMPT_RT, after releasing the lock with
> "spin_unlock", context switch might occur before enabling the bottom
> half with local_bh_enable and this causes the kernel to panic.
> The issue is resolved by releasing the lock afer acquiring the mutex
> using spin_unlock_bh.
>
> Tested the fix on MIPS and X86 architecture.
>
> Signed-off-by: Vivek Satpute <vivek@linsyssoft.com>
> ---
> net/core/sock.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> Index: linux-2.6.28.4/net/core/sock.c
> ===================================================================
> --- linux-2.6.28.4.orig/net/core/sock.c
> +++ linux-2.6.28.4/net/core/sock.c
> @@ -1752,12 +1752,20 @@ void lock_sock_nested(struct sock *sk, i
> if (sk->sk_lock.owned)
> __lock_sock(sk);
> sk->sk_lock.owned = 1;
> +
> +#ifndef CONFIG_PREEMPT_RT
> spin_unlock(&sk->sk_lock.slock);
> +#endif
> /*
> * The sk_lock has mutex_lock() semantics here:
> */
> mutex_acquire(&sk->sk_lock.dep_map, subclass, 0, _RET_IP_);
> +
> +#ifdef CONFIG_PREEMPT_RT
> + spin_unlock_bh(&sk->sk_lock.slock);
> +#else
> local_bh_enable();
> +#endif
> }
>
> EXPORT_SYMBOL(lock_sock_nested);
>
>
>
>
> Thanks and Regards,
> Vivek Satpute
> System Software Engineer
> LinSysSoft Technologies, Pune
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-12-27 8:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-25 12:07 [PATCH-rt 1/1] Fix spinlock issue in net/core/sock.c Vivek Satpute
2009-06-29 11:57 ` Jan Blunck
[not found] ` <fae6a9700906290649j176493f7u39c4ce674a3a66fc@mail.gmail.com>
2009-06-29 13:54 ` Vivek Satpute
2009-12-27 8:15 ` Vivek Satpute
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).