Re: [RFC 19/22] Bluetooth: Change l2cap chan_list to use RCU

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Gustavo,

> This list has much more reads than writes, so RCU makes senses here, also
> it avoid deadlock against the socket lock.
> 
> Signed-off-by: Gustavo F. Padovan <padovan@xxxxxxxxxxxxxx>
> ---
>  net/bluetooth/l2cap_core.c |  117 +++++++++++++++++++++----------------------
>  1 files changed, 57 insertions(+), 60 deletions(-)
> 
> diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> index d616519..a212295 100644
> --- a/net/bluetooth/l2cap_core.c
> +++ b/net/bluetooth/l2cap_core.c
> @@ -89,24 +89,36 @@ static inline void chan_put(struct l2cap_chan *c)
>  
>  static struct l2cap_chan *__l2cap_get_chan_by_dcid(struct l2cap_conn *conn, u16 cid)
>  {
> -	struct l2cap_chan *c;
> +	struct l2cap_chan *c, *r = NULL;
>  
> -	list_for_each_entry(c, &conn->chan_l, list) {
> -		if (c->dcid == cid)
> -			return c;
> +	rcu_read_lock();
> +
> +	list_for_each_entry_rcu(c, &conn->chan_l, list) {
> +		if (c->dcid == cid) {
> +			r = c;
> +			break;
> +		}
>  	}
> +
> +	rcu_read_unlock();
>  	return NULL;
>  }

shouldn't this say return r;
 
Regards

Marcel


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


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux