From: Yunfeng Ye <yeyunfeng@huawei.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Bart Van Assche <bvanassche@acm.org>, <dsterba@suse.cz>,
<bhelgaas@google.com>,
Alexander Duyck <alexander.h.duyck@linux.intel.com>,
<sakari.ailus@linux.intel.com>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
David Sterba <dsterba@suse.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"hushiyuan@huawei.com" <hushiyuan@huawei.com>,
"linfeilong@huawei.com" <linfeilong@huawei.com>
Subject: Re: [PATCH v2] async: Let kfree() out of the critical area of the lock
Date: Tue, 19 Nov 2019 11:01:15 +0800 [thread overview]
Message-ID: <d44b91fb-95d9-fadb-535f-898cca512bf4@huawei.com> (raw)
In-Reply-To: <alpine.DEB.2.21.1911151931420.28787@nanos.tec.linutronix.de>
On 2019/11/16 2:32, Thomas Gleixner wrote:
>
>
> On Fri, 11 Oct 2019, Yunfeng Ye wrote:
>
>> The async_lock is big global lock, and kfree() is not always cheap, it
>> will increase lock contention. it's better let kfree() outside the lock
>> to keep the critical area as short as possible.
>>
>> Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>
>> Reviewed-by: Alexander Duyck <alexander.h.duyck@linux.intel.com>
>> Reviewed-by: Bart Van Assche <bvanassche@acm.org>
>> ---
>> v1 -> v2:
>> - update the description
>> - add "Reviewed-by"
>>
>> 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);
>
> The wakeup should happen before the kfree() for the very same reasons.
>
ok, I will modify as your suggest, thanks.
> Thanks,
>
> tglx
>
> .
>
prev parent reply other threads:[~2019-11-19 3:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-27 6:03 Yunfeng Ye
2019-10-11 8:11 ` Yunfeng Ye
2019-11-15 18:32 ` Thomas Gleixner
2019-11-19 3:01 ` Yunfeng Ye [this message]
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=d44b91fb-95d9-fadb-535f-898cca512bf4@huawei.com \
--to=yeyunfeng@huawei.com \
--cc=alexander.h.duyck@linux.intel.com \
--cc=bhelgaas@google.com \
--cc=bvanassche@acm.org \
--cc=dsterba@suse.com \
--cc=dsterba@suse.cz \
--cc=gregkh@linuxfoundation.org \
--cc=hushiyuan@huawei.com \
--cc=linfeilong@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=tglx@linutronix.de \
/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
all inboxes | Powered by JetHome®