mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
net: fix a lockdep splat
We have for each socket :
One spinlock (sk_slock.slock)
One rwlock (sk_callback_lock)
Possible scenarios are :
(A) (this is used in net/sunrpc/xprtsock.c)
read_lock(&sk->sk_callback_lock) (without blocking BH)
<BH>
spin_lock(&sk->sk_slock.slock);
...
read_lock(&sk->sk_callback_lock);
...
(B)
write_lock_bh(&sk->sk_callback_lock)
stuff
write_unlock_bh(&sk->sk_callback_lock)
(C)
spin_lock_bh(&sk->sk_slock)
...
write_lock_bh(&sk->sk_callback_lock)
stuff
write_unlock_bh(&sk->sk_callback_lock)
spin_unlock_bh(&sk->sk_slock)
This (C) case conflicts with (A) :
CPU1 [A] CPU2 [C]
read_lock(callback_lock)
<BH> spin_lock_bh(slock)
<wait to spin_lock(slock)>
<wait to write_lock_bh(callback_lock)>
We have one problematic (C) use case in inet_csk_listen_stop() :
local_bh_disable();
bh_lock_sock(child); // spin_lock_bh(&sk->sk_slock)
WARN_ON(sock_owned_by_user(child));
...
sock_orphan(child); // write_lock_bh(&sk->sk_callback_lock)
lockdep is not happy with this, as reported by Tetsuo Handa
It seems only way to deal with this is to use read_lock_bh(callbacklock)
everywhere.
Thanks to Jarek for pointing a bug in my first attempt and suggesting
this solution.
Reported-by: Tetsuo Handa <[email protected]>
Tested-by: Tetsuo Handa <[email protected]>
Signed-off-by: Eric Dumazet <[email protected]>
CC: Jarek Poplawski <[email protected]>
Tested-by: Eric Dumazet <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
This commit is contained in:
parent
605c82bab5
commit
f064af1e50
6 changed files with 26 additions and 26 deletions
|
|
@ -43,7 +43,7 @@ void rds_tcp_state_change(struct sock *sk)
|
|||
struct rds_connection *conn;
|
||||
struct rds_tcp_connection *tc;
|
||||
|
||||
read_lock(&sk->sk_callback_lock);
|
||||
read_lock_bh(&sk->sk_callback_lock);
|
||||
conn = sk->sk_user_data;
|
||||
if (conn == NULL) {
|
||||
state_change = sk->sk_state_change;
|
||||
|
|
@ -68,7 +68,7 @@ void rds_tcp_state_change(struct sock *sk)
|
|||
break;
|
||||
}
|
||||
out:
|
||||
read_unlock(&sk->sk_callback_lock);
|
||||
read_unlock_bh(&sk->sk_callback_lock);
|
||||
state_change(sk);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ void rds_tcp_listen_data_ready(struct sock *sk, int bytes)
|
|||
|
||||
rdsdebug("listen data ready sk %p\n", sk);
|
||||
|
||||
read_lock(&sk->sk_callback_lock);
|
||||
read_lock_bh(&sk->sk_callback_lock);
|
||||
ready = sk->sk_user_data;
|
||||
if (ready == NULL) { /* check for teardown race */
|
||||
ready = sk->sk_data_ready;
|
||||
|
|
@ -131,7 +131,7 @@ void rds_tcp_listen_data_ready(struct sock *sk, int bytes)
|
|||
queue_work(rds_wq, &rds_tcp_listen_work);
|
||||
|
||||
out:
|
||||
read_unlock(&sk->sk_callback_lock);
|
||||
read_unlock_bh(&sk->sk_callback_lock);
|
||||
ready(sk, bytes);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -324,7 +324,7 @@ void rds_tcp_data_ready(struct sock *sk, int bytes)
|
|||
|
||||
rdsdebug("data ready sk %p bytes %d\n", sk, bytes);
|
||||
|
||||
read_lock(&sk->sk_callback_lock);
|
||||
read_lock_bh(&sk->sk_callback_lock);
|
||||
conn = sk->sk_user_data;
|
||||
if (conn == NULL) { /* check for teardown race */
|
||||
ready = sk->sk_data_ready;
|
||||
|
|
@ -338,7 +338,7 @@ void rds_tcp_data_ready(struct sock *sk, int bytes)
|
|||
if (rds_tcp_read_sock(conn, GFP_ATOMIC, KM_SOFTIRQ0) == -ENOMEM)
|
||||
queue_delayed_work(rds_wq, &conn->c_recv_w, 0);
|
||||
out:
|
||||
read_unlock(&sk->sk_callback_lock);
|
||||
read_unlock_bh(&sk->sk_callback_lock);
|
||||
ready(sk, bytes);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -224,7 +224,7 @@ void rds_tcp_write_space(struct sock *sk)
|
|||
struct rds_connection *conn;
|
||||
struct rds_tcp_connection *tc;
|
||||
|
||||
read_lock(&sk->sk_callback_lock);
|
||||
read_lock_bh(&sk->sk_callback_lock);
|
||||
conn = sk->sk_user_data;
|
||||
if (conn == NULL) {
|
||||
write_space = sk->sk_write_space;
|
||||
|
|
@ -244,7 +244,7 @@ void rds_tcp_write_space(struct sock *sk)
|
|||
queue_delayed_work(rds_wq, &conn->c_send_w, 0);
|
||||
|
||||
out:
|
||||
read_unlock(&sk->sk_callback_lock);
|
||||
read_unlock_bh(&sk->sk_callback_lock);
|
||||
|
||||
/*
|
||||
* write_space is only called when data leaves tcp's send queue if
|
||||
|
|
|
|||
Loading…
Reference in a new issue