Re: [PATCH] Bluetooth: Use non locking get_chan and explicit lock

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

 



Hi Andrei,

> > > For receiving ACL packets use __l2cap_get_chan_by_scid which is not
> > > locking sk and explicitly lock sk after checking that it is exist.
> > > Code looks nicer since now it is surrounded by lock/release.
> > > 
> > > Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@xxxxxxxxx>
> > > ---
> > >  net/bluetooth/l2cap_core.c |    7 +++++--
> > >  1 files changed, 5 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> > > index d16ad49..53dbfd3 100644
> > > --- a/net/bluetooth/l2cap_core.c
> > > +++ b/net/bluetooth/l2cap_core.c
> > > @@ -4243,7 +4243,7 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk
> > >  	u16 tx_seq;
> > >  	int len;
> > >  
> > > -	chan = l2cap_get_chan_by_scid(conn, cid);
> > > +	chan = __l2cap_get_chan_by_scid(conn, cid);
> > >  	if (!chan) {
> > >  		if (cid == L2CAP_CID_A2MP) {
> > >  			chan = a2mp_channel_create(conn, skb);
> > > @@ -4255,6 +4255,8 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk
> > >  	}
> > >  
> > >  	sk = chan->sk;
> > > +	if (sk)
> > > +		lock_sock(sk);
> > 
> > this is the part I clearly do not like. This is pretty nasty conditional
> > locking. We need to figure out something better.
> 
> Actually l2cap_data_channel function ends with:
> 
>         <------8<--------------------
>         |  if (sk)
>         |          release_sock(sk);
>         |
>         <------8<--------------------

that one slipped past me :(

> So in _this_ case it looks consistent. But I agree that generally it does
> not looks nice. The reason for that is l2cap_chan is locked with socket
> lock. Maybe we could create mutex l2cap_lock and functions like
> lock_chan(chan) / unlock_chan(chan) and change socket locks in l2cap_core
> with these new locks?

I agree. Lets see what happens if we lock l2cap_chan with its own lock.

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