From patchwork Mon Aug 21 13:49:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 804026 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xbZpv2hc7z9s78 for ; Mon, 21 Aug 2017 23:51:19 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3xbZpv1rbwzDqZw for ; Mon, 21 Aug 2017 23:51:19 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3xbZnK2RQZzDqZ7 for ; Mon, 21 Aug 2017 23:49:57 +1000 (AEST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D9AAC4A6E7; Mon, 21 Aug 2017 13:49:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D9AAC4A6E7 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=lvivier@redhat.com Received: from thinkpad.redhat.com (ovpn-116-24.ams2.redhat.com [10.36.116.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id C56DD600C8; Mon, 21 Aug 2017 13:49:52 +0000 (UTC) From: Laurent Vivier To: linux-kernel@vger.kernel.org Subject: [PATCH 1/2] powerpc/workqueue: update list of possible CPUs Date: Mon, 21 Aug 2017 15:49:50 +0200 Message-Id: <20170821134951.18848-1-lvivier@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 21 Aug 2017 13:49:55 +0000 (UTC) X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jens Axboe , Lai Jiangshan , linux-block@vger.kernel.org, Tejun Heo , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" In wq_numa_init() a list of NUMA nodes with their list of possible CPUs is built. Unfortunately, on powerpc, the Firmware is only able to provide the node of a CPU if the CPU is present. So, in our case (possible CPU) CPU ids are known, but as the CPU is not present, the node id is unknown and all the unplugged CPUs are attached to node 0. When we hotplugged CPU, there can be an inconsistency between the node id known by the workqueue, and the real node id of the CPU. This patch adds a hotplug handler to add the hotplugged CPU to update the node entry in wq_numa_possible_cpumask array. Signed-off-by: Laurent Vivier --- arch/powerpc/kernel/smp.c | 1 + include/linux/workqueue.h | 1 + kernel/workqueue.c | 21 +++++++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index 8d3320562c70..abc533146514 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c @@ -964,6 +964,7 @@ void start_secondary(void *unused) set_numa_node(numa_cpu_lookup_table[cpu]); set_numa_mem(local_memory_node(numa_cpu_lookup_table[cpu])); + wq_numa_add_possible_cpu(cpu); smp_wmb(); notify_cpu_starting(cpu); diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h index db6dc9dc0482..4ef030dae22c 100644 --- a/include/linux/workqueue.h +++ b/include/linux/workqueue.h @@ -644,6 +644,7 @@ int workqueue_online_cpu(unsigned int cpu); int workqueue_offline_cpu(unsigned int cpu); #endif +void wq_numa_add_possible_cpu(unsigned int cpu); int __init workqueue_init_early(void); int __init workqueue_init(void); diff --git a/kernel/workqueue.c b/kernel/workqueue.c index ca937b0c3a96..d1a99e25d5da 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -5486,6 +5486,27 @@ static inline void wq_watchdog_init(void) { } #endif /* CONFIG_WQ_WATCHDOG */ +void wq_numa_add_possible_cpu(unsigned int cpu) +{ + int node; + + if (num_possible_nodes() <= 1) + return; + + if (wq_disable_numa) + return; + + if (!wq_numa_enabled) + return; + + node = cpu_to_node(cpu); + if (node == NUMA_NO_NODE) + return; + + cpumask_set_cpu(cpu, wq_numa_possible_cpumask[node]); +} +EXPORT_SYMBOL_GPL(wq_numa_add_possible_cpu); + static void __init wq_numa_init(void) { cpumask_var_t *tbl;