Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754130AbbFDBJO (ORCPT ); Wed, 3 Jun 2015 21:09:14 -0400 Received: from mail-pd0-f169.google.com ([209.85.192.169]:36381 "EHLO mail-pd0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753527AbbFDBJG (ORCPT ); Wed, 3 Jun 2015 21:09:06 -0400 Date: Thu, 4 Jun 2015 10:09:01 +0900 From: Tejun Heo To: Lai Jiangshan Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH 4/4] workqueue: reuse wq_update_unbound_numa_attrs_buf as temporary attrs Message-ID: <20150604010901.GL20091@mtj.duckdns.org> References: <1433341792-2017-1-git-send-email-laijs@cn.fujitsu.com> <1433341792-2017-5-git-send-email-laijs@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1433341792-2017-5-git-send-email-laijs@cn.fujitsu.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2530 Lines: 63 Hello, On Wed, Jun 03, 2015 at 10:29:52PM +0800, Lai Jiangshan wrote: > tmp_attrs in apply_wqattrs_prepare() is just temporary attrs, we can use > wq_update_unbound_numa_attrs_buf for it like wq_update_unbound_numa(); > > The wq_update_unbound_numa_attrs_buf is renamed to wq_calc_node_attrs_buf > since it is used both for apply_wqattrs_prepare() and wq_update_unbound_numa(). > > The comment for using wq_calc_node_attrs_buf in wq_update_unbound_numa() > is also moved to the defination of the wq_calc_node_attrs_buf. > > This change also avoids frequently alloc/free the tmp_attrs for every > workqueue when the low level cpumask is being updated. > > Signed-off-by: Lai Jiangshan > --- > kernel/workqueue.c | 31 +++++++++++++------------------ > 1 file changed, 13 insertions(+), 18 deletions(-) > > diff --git a/kernel/workqueue.c b/kernel/workqueue.c > index 0c2f819..4a40165 100644 > --- a/kernel/workqueue.c > +++ b/kernel/workqueue.c > @@ -295,8 +295,13 @@ module_param_named(power_efficient, wq_power_efficient, bool, 0444); > > static bool wq_numa_enabled; /* unbound NUMA affinity enabled */ > > -/* buf for wq_update_unbound_numa_attrs(), protected by CPU hotplug exclusion */ > -static struct workqueue_attrs *wq_update_unbound_numa_attrs_buf; > +/* > + * PL: resulted attrs of wq_calc_node_cpumask() for apply_wqattrs_prepare() > + * and wq_update_unbound_numa(). > + * We don't wanna alloc/free temporary attrs for each call. Let's preallocate > + * one with the access protection of wq_pool_mutex. > + */ > +static struct workqueue_attrs *wq_calc_node_attrs_buf; > > static DEFINE_MUTEX(wq_pool_mutex); /* protects pools and workqueues list */ > static DEFINE_SPINLOCK(wq_mayday_lock); /* protects wq->maydays list */ > @@ -3515,7 +3520,7 @@ apply_wqattrs_prepare(struct workqueue_struct *wq, > const struct workqueue_attrs *attrs) > { > struct apply_wqattrs_ctx *ctx; > - struct workqueue_attrs *new_attrs, *tmp_attrs; > + struct workqueue_attrs *new_attrs, *tmp_attrs = wq_calc_node_attrs_buf; Hmm... this actually bothers me a bit. Can we please do something like the following? static struct workqueue_attrs *wq_attrs_shared_buf(void) { lockdep_assert_held(...); return __wq_attrs_shared_buf; } -- tejun -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/