Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp30336ybc; Mon, 18 Nov 2019 19:32:07 -0800 (PST) X-Google-Smtp-Source: APXvYqyk16ioGlrWg+9FN6XOzDBUIWsZu7zIGJ3owyfq4zG4Sj/bxzjfm2aeg58RSlj+ABl35cc3 X-Received: by 2002:a17:906:1590:: with SMTP id k16mr31440470ejd.23.1574134327469; Mon, 18 Nov 2019 19:32:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574134327; cv=none; d=google.com; s=arc-20160816; b=EVyYBOKxIA4K9sve91VtUwklDNF+CuWt8hn9fARygm2VTGVF+oPQsEiQ7aTvbpTM10 G3KUvbQdQB1+En8a2wf7WgA7zGdBxKh5Y2Rdfhf4bFDB2Q4d/e9u1elYl/iSb4rfgc3o hKgww3Wffo/1W4G98kiAUGv+TWG50/TPRyAuOcxwVxjMfygeoCynUI2VmVikBvieVAyJ jNrn8PWNAFSLeb9F5VMwphzpww7qs+9hiKTZ6ixpVlP9cQE9PaeZItxcjIwncEw2k2Ml +x+N09TLWmQgwHo9ZgOMfHuKkBYGWKSe2N5xqkDiuoeOEXfbf5Zkg8bTUXe6fRFPshLX P7wg== 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=Jtqu5pUifOCSaLLPc7hrRzUt0vGo+9pPQWv7G7JezME=; b=Lh84x1BTawEqLQfbqdGS8edptgU6hOF82iHotDGEbtzAE1fDDf8L9VPTnQA0YGUSBb tzFSgcqU+FXc9GBSAOTLNH5KSRMzReIvcO5kPudI5Zgca/WLnzWKjmAjZcJWi6jUFm5+ OTz37Jz7/s9N/f62Lsom5DqcNPLxnAs1+lflK77SiMKYJ+E9lOdFCElxxaA11xD5A4o+ znaNjpHxW/bLRGoWrMdPGaAkCajiCvwt2fpqL4l8g8mWHZkaTqZt/mifKKsOjJilKkGd sb4smcYHBYEtXvPLHi3uiwbfCnAv8osmERSMGiWeILm6osLOEQf3/+XixDm26rNrkeEz yi9Q== 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 v26si12686236eje.425.2019.11.18.19.31.41; Mon, 18 Nov 2019 19:32:07 -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 S1727533AbfKSD1d (ORCPT + 99 others); Mon, 18 Nov 2019 22:27:33 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:48802 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727018AbfKSD1d (ORCPT ); Mon, 18 Nov 2019 22:27:33 -0500 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id C966391C286B9FECAB46; Tue, 19 Nov 2019 11:27:30 +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:27:21 +0800 To: Thomas Gleixner CC: , , , , , , "hushiyuan@huawei.com" , "linfeilong@huawei.com" From: Yunfeng Ye Subject: [PATCH v3] async: Let kfree() out of the critical area of the lock Message-ID: <89da0082-ebad-25c0-d82f-4a2feae628e6@huawei.com> Date: Tue, 19 Nov 2019 11:26:57 +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 --- v2 -> v3: - move kfree() after wake_up(&async_done) v1 -> v2: - update the description - add "Reviewed-by" kernel/async.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/async.c b/kernel/async.c index 4f9c1d614016..d2ab75e8b1ab 100644 --- a/kernel/async.c +++ b/kernel/async.c @@ -135,14 +135,14 @@ 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); - /* 4) wake up any waiters */ + /* 3) wake up any waiters */ wake_up(&async_done); + + /* 4) free the entry */ + kfree(entry); } /** -- 2.7.4