Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp3018736ybn; Thu, 26 Sep 2019 23:05:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqzPtewmAbrbnnc1hAcD3kXPDX3xAwFXY4YcMv7LO4p1XH1fvpkxK9waoXwHy45a6lXizY7i X-Received: by 2002:aa7:d1d3:: with SMTP id g19mr2621860edp.150.1569564341124; Thu, 26 Sep 2019 23:05:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569564341; cv=none; d=google.com; s=arc-20160816; b=rAHGlcVKaOywPyegllt+iMc2uMWg1JP71Arx+O3beIs0Wz/ls14AI0LbsDqzwGScst z7Wqm8SUFir9V0qbRyo85s/2JznoAJY5xJS9o++gD6bwpSAEAj7PqS8k/U0k2M2VQprJ LCiz+7UWvquWaWq8ulBogUO8ayyl8w0NkqUJCMXg7MtFo5P78NehOXgdRZ4Qr3Cdcj8b 1Jl9ZYQyowIo+uwWCVqpFpklLcfloDyz+nep+lm+DUw+Vuf+4HJ/a4k9ZV2VKvXfkaWh oWXrTBllSbDe1wCzRGNwPiLw37o2lSKYK4BfMBLbUePbfWvaSM184ZMBDIuKDiILxtD0 avwg== 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:mime-version:user-agent:date:message-id:subject :from:cc:to; bh=XMc08aKFzFFFt6C179VvXYsDcfXXKnoG21hoWk8dcRw=; b=xTXbG0vge6Q6FbOfmQH+UHQ6CT1EhjaDo4Fbnqe6clVcYVtoP5yAq4d5jUP8S1RgCS Ny+Fy/+n39pXQ2Dbj5YTefmJyzvZEXr1fZYWjVCqwikLxMq6eWSVXJqzook3BqdyNPwX TsYNe2WXmJ4zP/XuPrt/dIas5C37rg42wBAaPSc6oYkkGXg5746QK+IUMD0EYI2g3dAx zSoqpswtHtSIA8YbzgBb+2bwfvQQvlnZ2b0unqDem/PGglc0smts9Bo7eRsQhlTqKZ27 ND0zrbUIgOETd2bQWBeJsczEyYhISjraqu5VLb3sRqb0vzaUHU+CIFcScd2UW8DFkvNT 4QqA== 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 m5si2162791ejr.125.2019.09.26.23.05.17; Thu, 26 Sep 2019 23:05:41 -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 S1726025AbfI0GDU (ORCPT + 99 others); Fri, 27 Sep 2019 02:03:20 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:3165 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725769AbfI0GDU (ORCPT ); Fri, 27 Sep 2019 02:03:20 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id E193F3365AF5D05ACBFF; Fri, 27 Sep 2019 14:03:15 +0800 (CST) Received: from [127.0.0.1] (10.177.251.225) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.439.0; Fri, 27 Sep 2019 14:03:10 +0800 To: Bart Van Assche , , , "tglx@linutronix.de" , "Alexander Duyck" , , "gregkh@linuxfoundation.org" , David Sterba CC: "linux-kernel@vger.kernel.org" From: Yunfeng Ye Subject: [PATCH v2] async: Let kfree() out of the critical area of the lock Message-ID: Date: Fri, 27 Sep 2019 14:03:04 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 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 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); } -- 2.7.4