Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp609297ybp; Fri, 11 Oct 2019 01:13:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqwf2wkyfkS6lRpE7TomcasWicUMXtTMtN6ISKUaLSVKuT6qfqjNAuOP8EwMospciYd0pAWS X-Received: by 2002:a17:906:2cd4:: with SMTP id r20mr12341064ejr.307.1570781591240; Fri, 11 Oct 2019 01:13:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570781591; cv=none; d=google.com; s=arc-20160816; b=Kn307ewmfmra1PKNjdNwygkKaBh8MW/jafp1aHw9vhZ+nSaUtMBEamapEY4ra6bHgu dCVUljWL9lhVRNAbpf4D6M3nGA4zPirFNJq405Qel4GN4dUZurLWBGPhEs9tAFQag76g wQAA9qFLVdust/n3nIV4zmXiFLknjP57PPZTAVJmSwB4HAZ4sCC/uEqCqR8nhjTo5R6W JWAgYYVG0BfnLkNHFTJBXtCO1efN49473nv0uMIC2O+IDGKs4l5UxDtDjRznvArgVoAK TauE2o2JHtKW+K3XrEdnc65t6oc2IfKj6ZifbXcABtKwf8fwnUBILnEaq8FBSBYdnIeo GYyw== 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:references:cc:to:from:subject; bh=XMc08aKFzFFFt6C179VvXYsDcfXXKnoG21hoWk8dcRw=; b=DzG4slFtR5iHxwKYkImzk0K2DKQEZEmMai9D6hZTzqT55lKp9eSio7CC6A5rVRSfKT eNY/W3086ll/qdP41VruqoAPE63Nx7VuBkQymolRW1cpCmGwdKWU6ekepg8278H7oK7U W05mQsZotks5UN2FdntDs41vNe+FrOAahQNgoxGX1omvQzDhtPP3AEnkHDjELhO/kRQR dJ6fz0eOJmlosuym5+l/vTVRl8OPNwECJPnFEiQczBHdVrRC+wbRxnTTCmYdPE1r6xe3 YHHOJq5LmlXt3dDU6hZpdMOfbYEkmHmCT9muW067r+SU0KLM1rAuCkIuGfMYh5A7twib jo6A== 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 e23si4701362edq.344.2019.10.11.01.12.47; Fri, 11 Oct 2019 01:13:11 -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 S1727618AbfJKILu (ORCPT + 99 others); Fri, 11 Oct 2019 04:11:50 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:3732 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726461AbfJKILt (ORCPT ); Fri, 11 Oct 2019 04:11:49 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 6DFA1D90DC880845E81A; Fri, 11 Oct 2019 16:11:47 +0800 (CST) Received: from [127.0.0.1] (10.177.251.225) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.439.0; Fri, 11 Oct 2019 16:11:42 +0800 Subject: [PATCH v2] async: Let kfree() out of the critical area of the lock From: Yunfeng Ye To: Bart Van Assche , , , "tglx@linutronix.de" , "Alexander Duyck" , , "gregkh@linuxfoundation.org" , David Sterba CC: "linux-kernel@vger.kernel.org" References: Message-ID: <9bfecf17-3c1b-414e-b271-4fd2d884faa3@huawei.com> Date: Fri, 11 Oct 2019 16:11: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 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