Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1867982ybn; Thu, 26 Sep 2019 03:28:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqw6r/a2823tul8vnbgTeiqCPbtivvP4HGoESJUA6Rq02Sf8uKDEWFrH+NYkVSUFuD2dfQbJ X-Received: by 2002:a05:6402:1202:: with SMTP id c2mr2617759edw.190.1569493710340; Thu, 26 Sep 2019 03:28:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569493710; cv=none; d=google.com; s=arc-20160816; b=OTPrwkjqbAsLnl8XvJ82QqCQK2iMqDCBWUwQQEn8Y60u7aHdDVzgfni/5dAUfMRZzk kUyi1VeyRWJrSzBHr5rHsrOFoxo5p8o/vcQhQh0KxSjYyheaUEbcVCVg8C4z0mBhOXcb W9ECytPjgmMM68xs1yTwhD2/I2AysVX7OSMduRAjZiRXiItbEga0/SJMe0gaXN8ypy+6 YrboCmCkw540BeHc9O04joWmh8Fa09KRFu7X07D7wWfs5i3r/j2SR/e0l2Mj3SrNbMPL SJfN55ii+JN7O13YX6fXplIXp3dbgtoIU5HTxmk6+iSJ7QV1e4ZdDZ21EQpYbO2Zslse IfJA== 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=J3sLwakCDKetrsPeZ5qfh1IHDG+sGBqEd7HJm0iJfFI=; b=VT1QBrZWnERqSK7l261ULhdwI9yq0tv9TYL5hJYelJ2sJiXF4oPinZDe3B0NohjI7p aZyImn2wfWKbRPy7wI4CRifDEVAIWbltgyPIvQQ4pbw3pyyRc8RTGimxz5YxJ+3VNhaZ QbhFgR1/6jreU7Vq71YJ0USDveHu4jj4tMIJIQ5wvEa4KzRxBINSBbmge7CAEwUIUaBD Qw3YTAgesBJXIcmKB6j1IiANhxvqop3HSzBy6sFWyg47BtE8oW2cqA93vKimMQ0Q5a6T lWtQPWrMrwCtN06XD+bR/PQ6doIIw/yDsKdeAA7volwzjdMNOK6/a7vjMPVbNiBZIEdt CgIQ== 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 l54si1009098edb.206.2019.09.26.03.28.07; Thu, 26 Sep 2019 03:28:30 -0700 (PDT) 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 S1728526AbfIZIBC (ORCPT + 99 others); Thu, 26 Sep 2019 04:01:02 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:54504 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727578AbfIZIBC (ORCPT ); Thu, 26 Sep 2019 04:01:02 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 6544E509E05ACE6FB941; Thu, 26 Sep 2019 16:01:00 +0800 (CST) Received: from [127.0.0.1] (10.177.251.225) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.439.0; Thu, 26 Sep 2019 16:00:58 +0800 Subject: Re: [PATCH] async: Let kfree() out of the critical area of the lock To: Alexander Duyck , "gregkh@linuxfoundation.org" , , , , "tglx@linutronix.de" , CC: "linux-kernel@vger.kernel.org" References: <216356b1-38c1-8477-c4e8-03f497dd6ac8@huawei.com> From: Yunfeng Ye Message-ID: Date: Thu, 26 Sep 2019 15:58:36 +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/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 >> --- >> 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 > > > . >