From patchwork Fri Oct 9 03:53:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xunlei Pang X-Patchwork-Id: 54681 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by patches.linaro.org (Postfix) with ESMTPS id 718D822FF4 for ; Fri, 9 Oct 2015 03:53:00 +0000 (UTC) Received: by lbcao8 with SMTP id ao8sf33014770lbc.1 for ; Thu, 08 Oct 2015 20:52:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=IANcECMHtzQONV6XLqDmWEPE5lHGygoHZBpcY40JGKw=; b=HhxAc7YEWC9FLLfZd6BJSl5Epnj69MgLA7dGEFgBibGkQPYL927sx1mGTEvBAPiYyg +ttCzH1uulCfDNh1zpAsDQWXcofIsl8jEfKTiivxU0nDhAD1wf3zPJFKhPr4Veukum/4 23BSmXIqzS/1uKs7EeQpZk11OubCAK8SYgdJjVaoPfiRLFrHe3iIZqSrEe7KqvEsI/HF GSl/57DKkVPacL8ScsjRrLlPqOXeEDhqNrXwfncjRJqSjI3zWV0DFyAXVYnFWe70b4Jw kBrrs1xp8hH5SqLkAbakfTelN+V6kQZu2fPCcTWW+ynairhtVwMSTIs18QOkVtSiDi+S TWLg== X-Gm-Message-State: ALoCoQkWURcu5Tr2OyMyrya8yqMAQkUf6MUploCvvjtCzJqvN7rdwMyh/KP/ffm7c0O53MnCx1Qq X-Received: by 10.180.107.167 with SMTP id hd7mr1415148wib.6.1444362779189; Thu, 08 Oct 2015 20:52:59 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.152.7 with SMTP id a7ls269795lfe.100.gmail; Thu, 08 Oct 2015 20:52:58 -0700 (PDT) X-Received: by 10.112.131.102 with SMTP id ol6mr5367662lbb.6.1444362778928; Thu, 08 Oct 2015 20:52:58 -0700 (PDT) Received: from mail-lb0-x229.google.com (mail-lb0-x229.google.com. [2a00:1450:4010:c04::229]) by mx.google.com with ESMTPS id c20si32305451lfb.26.2015.10.08.20.52.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Oct 2015 20:52:58 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::229 as permitted sender) client-ip=2a00:1450:4010:c04::229; Received: by lbwr8 with SMTP id r8so67111457lbw.2 for ; Thu, 08 Oct 2015 20:52:58 -0700 (PDT) X-Received: by 10.112.129.202 with SMTP id ny10mr5306759lbb.112.1444362778439; Thu, 08 Oct 2015 20:52:58 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp930250lbq; Thu, 8 Oct 2015 20:52:57 -0700 (PDT) X-Received: by 10.66.151.203 with SMTP id us11mr12633545pab.54.1444362777354; Thu, 08 Oct 2015 20:52:57 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v12si70270851pbs.27.2015.10.08.20.52.56; Thu, 08 Oct 2015 20:52:57 -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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756387AbbJIDwy (ORCPT + 30 others); Thu, 8 Oct 2015 23:52:54 -0400 Received: from m50-110.126.com ([123.125.50.110]:43979 "EHLO m50-110.126.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750948AbbJIDwx (ORCPT ); Thu, 8 Oct 2015 23:52:53 -0400 Received: from localhost.localdomain (unknown [210.21.223.3]) by smtp4 (Coremail) with SMTP id jdKowAA3ph7QORdWrszoBA--.20360S3; Fri, 09 Oct 2015 11:52:10 +0800 (CST) From: Xunlei Pang To: linux-kernel@vger.kernel.org Cc: Tejun Heo , Lai Jiangshan , Xunlei Pang Subject: [PATCH] workqueue: Allocate the unbound pool using local node memory Date: Fri, 9 Oct 2015 11:53:12 +0800 Message-Id: <1444362792-27705-1-git-send-email-xlpang@126.com> X-Mailer: git-send-email 1.9.1 X-CM-TRANSID: jdKowAA3ph7QORdWrszoBA--.20360S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7uF45GFy5uryUZw17Cr1DGFg_yoW8uryxpr 43CrWIg397XrWSgas3Ka1rZa4ag348G39rG3Z7Ww4rZw4Sqry3X3W0vFy3JFyUtFZ8Ww1r XFWkJ39Fkr4qvF7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07juFALUUUUU= X-Originating-IP: [210.21.223.3] X-CM-SenderInfo: p0ost0bj6rjloofrz/1tbiWwuOv1PM-UNkiAAAss Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Original-Sender: xlpang@126.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::229 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (body hash did not verify) header.i=@126.com; dmarc=fail (p=NONE dis=NONE) header.from=126.com Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Xunlei Pang Currently, get_unbound_pool() uses kzalloc() to allocate the worker pool. Actually, we can use the right node to do the allocation, achieving local memory access. This patch selects target node first, and uses kzalloc_node() instead. Signed-off-by: Xunlei Pang --- kernel/workqueue.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index ca71582..96d3747 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -3199,6 +3199,7 @@ static struct worker_pool *get_unbound_pool(const struct workqueue_attrs *attrs) u32 hash = wqattrs_hash(attrs); struct worker_pool *pool; int node; + int target_node = NUMA_NO_NODE; lockdep_assert_held(&wq_pool_mutex); @@ -3210,13 +3211,25 @@ static struct worker_pool *get_unbound_pool(const struct workqueue_attrs *attrs) } } + /* if cpumask is contained inside a NUMA node, we belong to that node */ + if (wq_numa_enabled) { + for_each_node(node) { + if (cpumask_subset(attrs->cpumask, + wq_numa_possible_cpumask[node])) { + target_node = node; + break; + } + } + } + /* nope, create a new one */ - pool = kzalloc(sizeof(*pool), GFP_KERNEL); + pool = kzalloc_node(sizeof(*pool), GFP_KERNEL, target_node); if (!pool || init_worker_pool(pool) < 0) goto fail; lockdep_set_subclass(&pool->lock, 1); /* see put_pwq() */ copy_workqueue_attrs(pool->attrs, attrs); + pool->node = target_node; /* * no_numa isn't a worker_pool attribute, always clear it. See @@ -3224,17 +3237,6 @@ static struct worker_pool *get_unbound_pool(const struct workqueue_attrs *attrs) */ pool->attrs->no_numa = false; - /* if cpumask is contained inside a NUMA node, we belong to that node */ - if (wq_numa_enabled) { - for_each_node(node) { - if (cpumask_subset(pool->attrs->cpumask, - wq_numa_possible_cpumask[node])) { - pool->node = node; - break; - } - } - } - if (worker_pool_assign_id(pool) < 0) goto fail;