lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 18 Oct 2016 10:46:45 +0530
From:   Binoy Jayan <binoy.jayan@...aro.org>
To:     Arnd Bergmann <arnd@...db.de>
Cc:     Doug Ledford <dledford@...hat.com>,
        Sean Hefty <sean.hefty@...el.com>,
        Hal Rosenstock <hal.rosenstock@...il.com>,
        linux-rdma@...r.kernel.org,
        Linux kernel mailing list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 6/8] IB/hns: Replace counting semaphore event_sem with
 wait condition

On 18 October 2016 at 01:59, Arnd Bergmann <arnd@...db.de> wrote:
> On Monday, October 17, 2016 10:01:00 PM CEST Binoy Jayan wrote:
>> --- a/drivers/infiniband/hw/hns/hns_roce_cmd.c
>> +++ b/drivers/infiniband/hw/hns/hns_roce_cmd.c
>> @@ -248,10 +248,14 @@ static int hns_roce_cmd_mbox_wait(struct hns_roce_dev *hr_dev, u64 in_param,
>>  {
>>         int ret = 0;
>>
>> -       down(&hr_dev->cmd.event_sem);
>> +       wait_event(hr_dev->cmd.event_sem.wq,
>> +                  atomic_add_unless(&hr_dev->cmd.event_sem.count, -1, 0));
>> +
>>         ret = __hns_roce_cmd_mbox_wait(hr_dev, in_param, out_param,
>>                                        in_modifier, op_modifier, op, timeout);
>> -       up(&hr_dev->cmd.event_sem);
>> +
>> +       if (atomic_inc_return(&hr_dev->cmd.event_sem.count) == 1)
>> +               wake_up(&hr_dev->cmd.event_sem.wq);
>>
>>         return ret;
>>  }
>
> This is the only interesting use of the event_sem that cares about
> the counting and it protects the __hns_roce_cmd_mbox_wait() from being
> entered too often. The count here is the number of size of the
> hr_dev->cmd.context[] array.
>
> However, that function already use a spinlock to protect that array
> and pick the correct context. I think changing the inner function
> to handle the case of 'no context available' by using a waitqueue
> without counting anything would be a reasonable transformation
> away from the semaphore.
>
>         Arnd


Hi Arnd,

Thank you for replying for the questions. I''ll look for alternatives
for patches
6,7 and 8 and resend the series.

-Binoy

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ