From: Ulisses Furquim <ulisses@profusion.mobi>
To: Andre Guedes <andre.guedes@openbossa.org>
Cc: Anderson Lizardo <anderson.lizardo@openbossa.org>,
Andre Guedes <aguedespe@gmail.com>,
linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH 3/3] Bluetooth: Use advertising cache thread-safe functions
Date: Tue, 7 Feb 2012 13:20:09 -0200 [thread overview]
Message-ID: <CAA37ikagyceFEAkcKmcZ3uPthUTOBkZR3nmwRLoQazj6pA22Aw@mail.gmail.com> (raw)
In-Reply-To: <CACJA=fURLb2RrD_P+gbFG=KXfniSpmB7a4xWmE43dAUgycQWHA@mail.gmail.com>
Hi Andre,
On Tue, Feb 7, 2012 at 12:46 PM, Andre Guedes
<andre.guedes@openbossa.org> wrote:
> Hi Ulisses,
>
> On Tue, Feb 7, 2012 at 10:26 AM, Ulisses Furquim <ulisses@profusion.mobi> wrote:
>> Hi Andre,
>>
>> On Tue, Feb 7, 2012 at 10:20 AM, Andre Guedes
>> <andre.guedes@openbossa.org> wrote:
>>> Hi Lizardo,
>>>
>>> On Tue, Feb 7, 2012 at 7:48 AM, Anderson Lizardo
>>> <anderson.lizardo@openbossa.org> wrote:
>>>> Hi Andre,
>>>>
>>>> On Tue, Feb 7, 2012 at 12:29 AM, Andre Guedes <aguedespe@gmail.com> wrote:
>>>>> diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
>>>>> index 6808069..3933ccd 100644
>>>>> --- a/net/bluetooth/hci_event.c
>>>>> +++ b/net/bluetooth/hci_event.c
>>>>> @@ -3255,12 +3255,10 @@ static inline void hci_le_adv_report_evt(struct hci_dev *hdev,
>>>>> void *ptr = &skb->data[1];
>>>>> s8 rssi;
>>>>>
>>>>> - hci_dev_lock(hdev);
>>>>> -
>>>>
>>>> So there is no need to lock hdev between the hci_add_adv_entry() and
>>>> mgmt_device_found() calls? This looks different from what is done for
>>>> BR/EDR for the inquiry cache.
>>>
>>> Yes, mgmt_device_found() does not require locking hdev->lock.
>>
>> We could then move the lock and unlock calls to inside the loop. But
>> as we might have more than one call to hci_add_adv_entry() it'd be
>> good to lock and unlock only once, no? Any problems I don't see?
>
> Yes, that's right. For this particular case, it may be better to lock
> hdev outside while() and call the thread-unsafe version here.
>
> This way, it may be better we just drop patches 02/03 and 03/03.
>
>>>>> while (num_reports--) {
>>>>> struct hci_ev_le_advertising_info *ev = ptr;
>>>>>
>>>>> - __hci_add_adv_entry(hdev, ev);
>>>>> + hci_add_adv_entry(hdev, ev);
>>>>>
>>>>> rssi = ev->data[ev->length];
>>>>> mgmt_device_found(hdev, &ev->bdaddr, LE_LINK, ev->bdaddr_type,
>>>>> @@ -3268,8 +3266,6 @@ static inline void hci_le_adv_report_evt(struct hci_dev *hdev,
>>>>>
>>>>> ptr += sizeof(*ev) + ev->length + 1;
>>>>> }
>>>>> -
>>>>> - hci_dev_unlock(hdev);
>>>>> }
>>>>>
>>>>> static inline void hci_le_ltk_request_evt(struct hci_dev *hdev,
>>>>> --
>>>>> 1.7.9
>>
>> While I don't see anything wrong with your changes I don't think we
>> really need it. All the other functions that need to be called with
>> hdev->lock held don't have "__" prefix so it'll be different than the
>> others. And you added 3 new locked functions but your last patch only
>> uses 2 of them and only in 2 places. Unless I'm missing something here
>> we don't really need this refactoring at all. Do you have any other
>> reason to do that? Are you gonna use those functions in other
>> patchset?
>
> Yes, some other functions don't have the prefix "__" and that fact
> makes a bit painful and error-prone since we always have to dig in
> the "call chain" to know if we need to hold hdev->lock or not.
> Prefixing a function with "__" is just a standard way to indicate
> that.
I understand that. I just don't know if Marcel will want to change
them all to have "__" prefixes, though. Having only one subset with
this prefix can make things even more confusing, don't you agree?
And have you been working with these functions or is this just a
cleanup you thought it'd be good to do?
Regards,
--
Ulisses Furquim
ProFUSION embedded systems
http://profusion.mobi
Mobile: +55 19 9250 0942
Skype: ulissesffs
next prev parent reply other threads:[~2012-02-07 15:20 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-07 4:29 [PATCH 0/3] Advertising cache locking code refactoring Andre Guedes
2012-02-07 4:29 ` [PATCH 1/3] Bluetooth: Add prefix "__" to advertising cache functions Andre Guedes
2012-02-07 4:29 ` [PATCH 2/3] Bluetooth: Create thread-safe " Andre Guedes
2012-02-07 4:29 ` [PATCH 3/3] Bluetooth: Use advertising cache thread-safe functions Andre Guedes
2012-02-07 10:48 ` Anderson Lizardo
2012-02-07 12:20 ` Andre Guedes
2012-02-07 13:26 ` Ulisses Furquim
2012-02-07 14:46 ` Andre Guedes
2012-02-07 15:20 ` Ulisses Furquim [this message]
2012-02-07 17:41 ` Andre Guedes
2012-02-07 17:47 ` Ulisses Furquim
2012-02-09 13:49 ` [PATCH 0/3] Advertising cache locking code refactoring Marcel Holtmann
2012-02-09 17:23 ` Ulisses Furquim
2012-02-09 19:18 ` 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=CAA37ikagyceFEAkcKmcZ3uPthUTOBkZR3nmwRLoQazj6pA22Aw@mail.gmail.com \
--to=ulisses@profusion.mobi \
--cc=aguedespe@gmail.com \
--cc=anderson.lizardo@openbossa.org \
--cc=andre.guedes@openbossa.org \
--cc=linux-bluetooth@vger.kernel.org \
/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 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).