Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp4820423ybc; Fri, 15 Nov 2019 10:34:14 -0800 (PST) X-Google-Smtp-Source: APXvYqzeT4eS8qyywuTcmhJ9yowjN1eguXEfWhuxNFqusA59o2zw3US4EHrYBeMEV7zoTTOmYbJz X-Received: by 2002:a17:906:52c3:: with SMTP id w3mr2918547ejn.122.1573842854699; Fri, 15 Nov 2019 10:34:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573842854; cv=none; d=google.com; s=arc-20160816; b=ZbILviNzQZALX+L+l8rIBtaMWaQLKDoV5eb09VFFF7W+AVrXF8UE9N9j5WzLMTmzM1 kKAe22jLmlGrkg47E5kMJZQbegFjYExfI4RcYkoLvF1iu7lrCx4lyf8a+DQPUmxHAqWe deVN5+hf51GLF5a1I1GxvhEfBcWJQopXOSwtborMbtBnz6WKkQSB0+DprGEN3XuJnxZu PXpiEzDOTQulgYLWLeJrpjTeT+4B6TW7dhc/rLDIYcGNBjHKY2x7ZAd5BIsKE4fCYLgT 12Y7qlA3UHjsNI5YKnjobqPBneA9IWJidOW5F2w134j/+XbosNTH1ZHnRkJ0F1Gfzsck J2dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=t4UEXSoBn1iFJ+KcendCkT30USlG2xbnRzPtkFENE4E=; b=IpPpidC/ARTkXuA0xdYaMS4XF2f6dfS84IFEJsw3FeEbfDWNQdDLcBnmTb7DXP7cOf LatWH/PrH0gjBMXFYk+IjgGL0B4kacrYiUHQYHkOCgwj27Vub3ejYP/YeZ0ZsFrfhcoo 7k+doYrOlkGcmA4jcsWTThU/Fln+e85J+O06bJsfYWGYuKukoa/Ml1YZYPD1C80M3sRH DRBhb3lMgD7EZ4rk/axr4Cm5jB6mGiiLgq9YmdR4vf3dY+8VAUbqjVHX2XIrY/HmIBRJ rNzFvAwm9Tt2eOmEf5JxXtYdaZMAztHXo0YkNa+tEvUS7/vyxjXsYlJC9HM5NnF7WrcW 7gXQ== 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 u2si6092651ejo.137.2019.11.15.10.33.49; Fri, 15 Nov 2019 10:34:14 -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 S1726598AbfKOScs (ORCPT + 99 others); Fri, 15 Nov 2019 13:32:48 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:44376 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726075AbfKOScs (ORCPT ); Fri, 15 Nov 2019 13:32:48 -0500 Received: from p5b06da22.dip0.t-ipconnect.de ([91.6.218.34] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1iVgOR-0005QE-69; Fri, 15 Nov 2019 19:32:27 +0100 Date: Fri, 15 Nov 2019 19:32:26 +0100 (CET) From: Thomas Gleixner To: Yunfeng Ye cc: Bart Van Assche , dsterba@suse.cz, bhelgaas@google.com, Alexander Duyck , sakari.ailus@linux.intel.com, "gregkh@linuxfoundation.org" , David Sterba , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v2] async: Let kfree() out of the critical area of the lock In-Reply-To: <9bfecf17-3c1b-414e-b271-4fd2d884faa3@huawei.com> Message-ID: References: <9bfecf17-3c1b-414e-b271-4fd2d884faa3@huawei.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Thanks, tglx