All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrei Emeltchenko <andrei.emeltchenko.news@gmail.com>
To: "Gustavo F. Padovan" <padovan@profusion.mobi>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [RFC 07/22] Bluetooth: Don't use spin_lock socket lock anymore
Date: Mon, 19 Dec 2011 11:53:01 +0200	[thread overview]
Message-ID: <20111219095259.GA3982@aemeltch-MOBL1> (raw)
In-Reply-To: <1324157382-1815-8-git-send-email-padovan@profusion.mobi>

Hi Gustavo,

On Sat, Dec 17, 2011 at 07:29:27PM -0200, Gustavo F. Padovan wrote:
> From: "Gustavo F. Padovan" <padovan@profusion.mobi>
> 
> We now run everything in process context, so the mutex lock is the best
> option. But in some places we still need the bh_lock_sock()

minor comment: {lock,release}_sock

Best regards 
Andrei Emeltchenko 

> 
> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
> ---
>  net/bluetooth/l2cap_core.c |   66 +++++++++++++------------------------------
>  1 files changed, 20 insertions(+), 46 deletions(-)
> 
> diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> index 89cda6d..ed67ac0 100644
> --- a/net/bluetooth/l2cap_core.c
> +++ b/net/bluetooth/l2cap_core.c
> @@ -118,7 +118,7 @@ static struct l2cap_chan *l2cap_get_chan_by_scid(struct l2cap_conn *conn, u16 ci
>  	read_lock(&conn->chan_lock);
>  	c = __l2cap_get_chan_by_scid(conn, cid);
>  	if (c)
> -		bh_lock_sock(c->sk);
> +		lock_sock(c->sk);
>  	read_unlock(&conn->chan_lock);
>  	return c;
>  }
> @@ -141,7 +141,7 @@ static inline struct l2cap_chan *l2cap_get_chan_by_ident(struct l2cap_conn *conn
>  	read_lock(&conn->chan_lock);
>  	c = __l2cap_get_chan_by_ident(conn, ident);
>  	if (c)
> -		bh_lock_sock(c->sk);
> +		lock_sock(c->sk);
>  	read_unlock(&conn->chan_lock);
>  	return c;
>  }
> @@ -889,7 +889,7 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn)
>  
>  	parent = pchan->sk;
>  
> -	bh_lock_sock(parent);
> +	lock_sock(parent);
>  
>  	/* Check for backlog size */
>  	if (sk_acceptq_is_full(parent)) {
> @@ -922,7 +922,7 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn)
>  	write_unlock_bh(&conn->chan_lock);
>  
>  clean:
> -	bh_unlock_sock(parent);
> +	release_sock(parent);
>  }
>  
>  static void l2cap_chan_ready(struct sock *sk)
> @@ -1024,9 +1024,9 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err)
>  	/* Kill channels */
>  	list_for_each_entry_safe(chan, l, &conn->chan_l, list) {
>  		sk = chan->sk;
> -		bh_lock_sock(sk);
> +		lock_sock(sk);
>  		l2cap_chan_del(chan, err);
> -		bh_unlock_sock(sk);
> +		release_sock(sk);
>  		chan->ops->close(chan->data);
>  	}
>  
> @@ -2568,7 +2568,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
>  
>  	parent = pchan->sk;
>  
> -	bh_lock_sock(parent);
> +	lock_sock(parent);
>  
>  	/* Check if the ACL is secure enough (if not SDP) */
>  	if (psm != cpu_to_le16(0x0001) &&
> @@ -2645,7 +2645,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
>  	write_unlock_bh(&conn->chan_lock);
>  
>  response:
> -	bh_unlock_sock(parent);
> +	release_sock(parent);
>  
>  sendresp:
>  	rsp.scid   = cpu_to_le16(scid);
> @@ -2727,19 +2727,11 @@ static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hd
>  		break;
>  
>  	default:
> -		/* don't delete l2cap channel if sk is owned by user */
> -		if (sock_owned_by_user(sk)) {
> -			l2cap_state_change(chan, BT_DISCONN);
> -			__clear_chan_timer(chan);
> -			__set_chan_timer(chan, L2CAP_DISC_TIMEOUT);
> -			break;
> -		}
> -
>  		l2cap_chan_del(chan, ECONNREFUSED);
>  		break;
>  	}
>  
> -	bh_unlock_sock(sk);
> +	release_sock(sk);
>  	return 0;
>  }
>  
> @@ -2861,7 +2853,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr
>  	}
>  
>  unlock:
> -	bh_unlock_sock(sk);
> +	release_sock(sk);
>  	return 0;
>  }
>  
> @@ -2968,7 +2960,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr
>  	}
>  
>  done:
> -	bh_unlock_sock(sk);
> +	release_sock(sk);
>  	return 0;
>  }
>  
> @@ -2997,17 +2989,8 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, struct l2cap_cmd
>  
>  	sk->sk_shutdown = SHUTDOWN_MASK;
>  
> -	/* don't delete l2cap channel if sk is owned by user */
> -	if (sock_owned_by_user(sk)) {
> -		l2cap_state_change(chan, BT_DISCONN);
> -		__clear_chan_timer(chan);
> -		__set_chan_timer(chan, L2CAP_DISC_TIMEOUT);
> -		bh_unlock_sock(sk);
> -		return 0;
> -	}
> -
>  	l2cap_chan_del(chan, ECONNRESET);
> -	bh_unlock_sock(sk);
> +	release_sock(sk);
>  
>  	chan->ops->close(chan->data);
>  	return 0;
> @@ -3031,17 +3014,8 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, struct l2cap_cmd
>  
>  	sk = chan->sk;
>  
> -	/* don't delete l2cap channel if sk is owned by user */
> -	if (sock_owned_by_user(sk)) {
> -		l2cap_state_change(chan, BT_DISCONN);
> -		__clear_chan_timer(chan);
> -		__set_chan_timer(chan, L2CAP_DISC_TIMEOUT);
> -		bh_unlock_sock(sk);
> -		return 0;
> -	}
> -
>  	l2cap_chan_del(chan, 0);
> -	bh_unlock_sock(sk);
> +	release_sock(sk);
>  
>  	chan->ops->close(chan->data);
>  	return 0;
> @@ -4284,7 +4258,7 @@ drop:
>  
>  done:
>  	if (sk)
> -		bh_unlock_sock(sk);
> +		release_sock(sk);
>  
>  	return 0;
>  }
> @@ -4300,7 +4274,7 @@ static inline int l2cap_conless_channel(struct l2cap_conn *conn, __le16 psm, str
>  
>  	sk = chan->sk;
>  
> -	bh_lock_sock(sk);
> +	lock_sock(sk);
>  
>  	BT_DBG("sk %p, len %d", sk, skb->len);
>  
> @@ -4318,7 +4292,7 @@ drop:
>  
>  done:
>  	if (sk)
> -		bh_unlock_sock(sk);
> +		release_sock(sk);
>  	return 0;
>  }
>  
> @@ -4333,7 +4307,7 @@ static inline int l2cap_att_channel(struct l2cap_conn *conn, __le16 cid, struct
>  
>  	sk = chan->sk;
>  
> -	bh_lock_sock(sk);
> +	lock_sock(sk);
>  
>  	BT_DBG("sk %p, len %d", sk, skb->len);
>  
> @@ -4351,7 +4325,7 @@ drop:
>  
>  done:
>  	if (sk)
> -		bh_unlock_sock(sk);
> +		release_sock(sk);
>  	return 0;
>  }
>  
> @@ -4656,11 +4630,11 @@ static int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 fl
>  				BT_ERR("Frame exceeding recv MTU (len %d, "
>  							"MTU %d)", len,
>  							chan->imtu);
> -				bh_unlock_sock(sk);
> +				release_sock(sk);
>  				l2cap_conn_unreliable(conn, ECOMM);
>  				goto drop;
>  			}
> -			bh_unlock_sock(sk);
> +			release_sock(sk);
>  		}
>  
>  		/* Allocate skb for the complete frame (with header) */
> -- 
> 1.7.6.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2011-12-19  9:53 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-17 21:29 [RFC 00/22] Bluetooth: change tasklets to workqueue Gustavo F. Padovan
2011-12-17 21:29 ` [RFC 01/22] Bluetooth: Process recv path in a workqueue instead of a tasklet Gustavo F. Padovan
2011-12-17 21:29   ` [RFC 02/22] Bluetooth: Replace spin_lock by mutex in hci_dev Gustavo F. Padovan
2011-12-17 21:29     ` [RFC 03/22] Bluetooth: Use delayed_work for connection timeout Gustavo F. Padovan
2011-12-17 21:29       ` [RFC 04/22] Bluetooth: Use delayed work for advertisiment cache timeout Gustavo F. Padovan
2011-12-17 21:29         ` [RFC 05/22] Bluetooth: hci_conn_auto_accept() doesn't need locking Gustavo F. Padovan
2011-12-17 21:29           ` [RFC 06/22] Bluetooth: Move L2CAP timers to workqueue Gustavo F. Padovan
2011-12-17 21:29             ` [RFC 07/22] Bluetooth: Don't use spin_lock socket lock anymore Gustavo F. Padovan
2011-12-17 21:29               ` [RFC 08/22] Bluetooth: Remove sk_backlog usage from L2CAP Gustavo F. Padovan
2011-12-17 21:29                 ` [RFC 09/22] Bluetooth: move hci_task_lock to mutex Gustavo F. Padovan
2011-12-17 21:29                   ` [RFC 10/22] Bluetooth: convert chan_lock " Gustavo F. Padovan
2011-12-17 21:29                     ` [RFC 11/22] Bluetooth: Use RCU to manipulate chan_list Gustavo F. Padovan
2011-12-17 21:29                       ` [RFC 12/22] Bluetooth: convert conn hash to RCU Gustavo F. Padovan
2011-12-17 21:29                         ` [RFC 13/22] Bluetooth: Don't disable tasklets to call hdev->notify() Gustavo F. Padovan
2011-12-17 21:29                           ` [RFC 14/22] Bluetooth: Move command task to workqueue Gustavo F. Padovan
2011-12-17 21:29                             ` [RFC 15/22] Bluetooth: convert tx_task " Gustavo F. Padovan
2011-12-17 21:29                               ` [RFC 16/22] Bluetooth: convert info timer to delayed_work Gustavo F. Padovan
2011-12-17 21:29                                 ` [RFC 17/22] Bluetooth: remove power_on work_struct Gustavo F. Padovan
2011-12-17 21:29                                   ` [RFC 18/22] Bluetooth: invert locking order in connect path Gustavo F. Padovan
2011-12-17 21:29                                     ` [RFC 19/22] Bluetooth: Change l2cap chan_list to use RCU Gustavo F. Padovan
2011-12-17 21:29                                       ` [RFC 20/22] Bluetooth: move power_off to system workqueue Gustavo F. Padovan
2011-12-17 21:29                                         ` [RFC 21/22] Bluetooth: Use new alloc_workqueue() Gustavo F. Padovan
2011-12-17 21:29                                           ` [RFC 22/22] Bluetooth: Remove work_add and work_del from hci_sysfs Gustavo F. Padovan
2011-12-17 22:15                                       ` [RFC 19/22] Bluetooth: Change l2cap chan_list to use RCU Marcel Holtmann
2011-12-19 10:42                                       ` Andrei Emeltchenko
2011-12-19 13:53                                         ` Gustavo Padovan
2011-12-17 22:13                                   ` [RFC 17/22] Bluetooth: remove power_on work_struct Marcel Holtmann
2012-01-26 13:20                       ` [RFC 11/22] Bluetooth: Use RCU to manipulate chan_list Andrei Emeltchenko
2011-12-19  9:58                     ` [RFC 10/22] Bluetooth: convert chan_lock to mutex Andrei Emeltchenko
2011-12-19  9:53               ` Andrei Emeltchenko [this message]
2011-12-19 11:05             ` [RFC 06/22] Bluetooth: Move L2CAP timers to workqueue Andrei Emeltchenko
2011-12-19 12:59               ` Ulisses Furquim
2011-12-17 21:34 ` [RFC 00/22] Bluetooth: change tasklets " Gustavo Padovan
2011-12-17 22:17 ` Marcel Holtmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111219095259.GA3982@aemeltch-MOBL1 \
    --to=andrei.emeltchenko.news@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=padovan@profusion.mobi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.