From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935002AbdEOPsU (ORCPT ); Mon, 15 May 2017 11:48:20 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:51972 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934792AbdEOPsP (ORCPT ); Mon, 15 May 2017 11:48:15 -0400 Subject: Re: [PATCH] workqueue: Ensure that cpumask set for pools created after boot To: Tejun Heo References: <20170510173340.GF32165@htj.duckdns.org> Cc: Lai Jiangshan , linux-kernel@vger.kernel.org, Nathan Fontenot , Michael Bringmann From: Michael Bringmann Organization: IBM Linux Technology Center Date: Mon, 15 May 2017 10:48:04 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20170510173340.GF32165@htj.duckdns.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 17051515-0048-0000-0000-00000182A9ED X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007066; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000212; SDB=6.00860840; UDB=6.00426901; IPR=6.00640504; BA=6.00005350; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00015465; XFM=3.00000015; UTC=2017-05-15 15:48:07 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17051515-0049-0000-0000-00004122D222 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-05-15_09:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1705150155 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello: On 05/10/2017 12:33 PM, Tejun Heo wrote: > Hello, > > On Wed, May 10, 2017 at 11:48:17AM -0500, Michael Bringmann wrote: >> >> On NUMA systems with dynamic processors, the content of the cpumask >> may change over time. As new processors are added via DLPAR operations, >> workqueues are created for them. This patch ensures that the pools >> created for new workqueues will be initialized with a cpumask before >> the first worker is created, attached, and woken up. If the mask is >> not set up, then the kernel will crash when 'wakeup_process' is unable >> to find a valid CPU to which to assign the new worker. >> >> Signed-off-by: Michael Bringmann >> --- >> diff --git a/kernel/workqueue.c b/kernel/workqueue.c >> index c74bf39..6091069 100644 >> --- a/kernel/workqueue.c >> +++ b/kernel/workqueue.c >> @@ -3366,6 +3366,8 @@ static struct worker_pool *get_unbound_pool(const struct workqueue_attrs *attrs) >> copy_workqueue_attrs(pool->attrs, attrs); >> pool->node = target_node; >> >> + cpumask_copy(pool->attrs->cpumask, cpumask_of(smp_processor_id())); > > What prevents a cpu getting added right here tho? PowerPC has only one control path to add/remove CPUs via DLPAR operations. Even so, the underlying code is protected through multiple locks. > > Maybe the right thing to do is protecting the whole thing with hotplug > readlock? The operation is already within a hotplug readlock when performing DLPAR add/remove. Adding a CPU to the system, requires it to be brought online. Removing a CPU from the system, requires it to be taken offline. These involve calls to cpu_up / cpu_down, which go through _cpu_up / _cpu_down, which acquire the hotplug locks, among others along the path of execution. The locks are acquired before getting to the workqueue code, the pool creation/attachment code (which is where the cpu mask needs to be set), or trying to wakeup the initial created task in 'sched.c'. > > Thanks. > Regards, Michael -- Michael W. Bringmann Linux Technology Center IBM Corporation Tie-Line 363-5196 External: (512) 286-5196 Cell: (512) 466-0650 mwb@linux.vnet.ibm.com