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]
Message-ID: <e59af8ae-bacb-2e7e-dd53-ea283960d40e@huawei.com>
Date:   Thu, 26 Sep 2019 15:58:36 +0800
From:   Yunfeng Ye <yeyunfeng@...wei.com>
To:     Alexander Duyck <alexander.h.duyck@...ux.intel.com>,
        "gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>,
        <bvanassche@....org>, <bhelgaas@...gle.com>, <dsterba@...e.com>,
        "tglx@...utronix.de" <tglx@...utronix.de>,
        <sakari.ailus@...ux.intel.com>
CC:     "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] async: Let kfree() out of the critical area of the lock



On 2019/9/25 23:20, Alexander Duyck wrote:
> On Wed, 2019-09-25 at 20:52 +0800, Yunfeng Ye wrote:
>> It's not necessary to put kfree() in the critical area of the lock, so
>> let it out.
>>
>> Signed-off-by: Yunfeng Ye <yeyunfeng@...wei.com>
>> ---
>>  kernel/async.c | 6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/kernel/async.c b/kernel/async.c
>> index 4f9c1d6..1de270d 100644
>> --- a/kernel/async.c
>> +++ b/kernel/async.c
>> @@ -135,12 +135,12 @@ static void async_run_entry_fn(struct work_struct *work)
>>  	list_del_init(&entry->domain_list);
>>  	list_del_init(&entry->global_list);
>>
>> -	/* 3) free the entry */
>> -	kfree(entry);
>>  	atomic_dec(&entry_count);
>> -
>>  	spin_unlock_irqrestore(&async_lock, flags);
>>
>> +	/* 3) free the entry */
>> +	kfree(entry);
>> +
>>  	/* 4) wake up any waiters */
>>  	wake_up(&async_done);
>>  }
> 
> It probably wouldn't hurt to update the patch description to mention that
> async_schedule_node_domain does the allocation outside of the lock, then
> takes the lock and does the list addition and entry_count increment inside
> the critical section so this is just updating the code to match that it
> seems.
> 
> Otherwise the change itself looks safe to me, though I am not sure there
> is a performance gain to be had so this is mostly just a cosmetic patch.
> 
The async_lock is big global lock, I think it's good to put kfree() outside
to keep the critical area as short as possible.

thanks.

> Reviewed-by: Alexander Duyck <alexander.h.duyck@...ux.intel.com>
> 
> 
> .
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ