Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp12477ybc; Mon, 18 Nov 2019 19:07:22 -0800 (PST) X-Google-Smtp-Source: APXvYqx4imAY8QomOfEzGnnm77hgsoRLPQuokBzVgk5q1wwsN4ofgFP4bYgsyzZHehyHyXhxbKPo X-Received: by 2002:a17:906:3418:: with SMTP id c24mr31802342ejb.121.1574132842310; Mon, 18 Nov 2019 19:07:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574132842; cv=none; d=google.com; s=arc-20160816; b=g77WU8vTdqrn2SGCM7DofYAZOeiuUX6CK8cgdy2VTBNhW6lyjbFPKbP7cCIcUnWQMj Kdg6I+XThFILNJVNQbs1J4lrrom5vNuJIKWtQw2pBjRdgZvQhr2VQMciNZqg3XWeznnU +t9t5S8VZt1vxwgI2Mo+2o2923ia1iV+EUdTKGUpB3a6KrG40xiIPIyAdFgXSDybu3Cy oPtjVpad6dvkYxCpVmLZNOKLm5aaeJ5v2DXREq+ooxtQgXYlGK96G9qaTBWZgy5/V4z1 hoV1SCU9GyATzsA6UXzKRf09OrNRpmXs3UxLq1WY6AjNa1YST8g6ds0rw6RpWaDBkXlG RGoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=olsOpIcnzwKRWS/AGnLOKMLllhiZqGG56NzlyI6d5e8=; b=rR4X6wCL+cKE+RFWpawabbWJZBuQewtVwoX0mdS4zlaWMoDWUq3zpHNSsiHyMRDKGj C/1Hiwku21nsmegAHmoST4KnBTqXXKGRJsIn7S+wURX1a0GOj6KcHCgu/QlXBCj5ODyg gz6+uZ1Isz6qkf5a1dXWwGB8zdsXK69VgISBGfwipVvtVygd0o0OHoKWzoTltZC3Ii4v 7/PSYHJ7a6rgcfh48hnzeJG8DBe2ZO/boXAhT7mw2Fq/IVPYPHJiEaV/6O4RUXFgW/Vc zb8NZ/Naya4bxbjw/QKTTTHAOlyIRMBeH9IavbOdTzGbpa+5B7k/ojXlRorUXuI3RGW+ Tx+w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f50si11318731edb.422.2019.11.18.19.06.59; Mon, 18 Nov 2019 19:07:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727386AbfKSDBu (ORCPT + 99 others); Mon, 18 Nov 2019 22:01:50 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:7141 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727014AbfKSDBu (ORCPT ); Mon, 18 Nov 2019 22:01:50 -0500 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 2DFEACDE6268824CF66A; Tue, 19 Nov 2019 11:01:48 +0800 (CST) Received: from [127.0.0.1] (10.177.251.225) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.439.0; Tue, 19 Nov 2019 11:01:39 +0800 Subject: Re: [PATCH v2] async: Let kfree() out of the critical area of the lock To: Thomas Gleixner CC: Bart Van Assche , , , Alexander Duyck , , "gregkh@linuxfoundation.org" , David Sterba , "linux-kernel@vger.kernel.org" , "hushiyuan@huawei.com" , "linfeilong@huawei.com" References: <9bfecf17-3c1b-414e-b271-4fd2d884faa3@huawei.com> From: Yunfeng Ye Message-ID: Date: Tue, 19 Nov 2019 11:01:15 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.251.225] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >> Reviewed-by: Alexander Duyck >> Reviewed-by: Bart Van Assche >> --- >> 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 > > . >