From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0066CC4332D for ; Sat, 16 Jan 2021 11:44:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C9F622311F for ; Sat, 16 Jan 2021 11:44:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726923AbhAPLoC (ORCPT ); Sat, 16 Jan 2021 06:44:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726751AbhAPLoB (ORCPT ); Sat, 16 Jan 2021 06:44:01 -0500 Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77257C0613D3 for ; Sat, 16 Jan 2021 03:43:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=iG+VYI5VLsPffn7LbYzbPRDpEEf5Kpxrq9KibfoDzJk=; b=UbAhYgVp1lIbFS/k2lbe6z/h2W 08i/X5HvXOkHudk7WvpU5LKTT9DX9njjwc6EygZUTUw3ubwHUtS3iYe6O1y81tV+86DGsN7ygX0Wk tqp8orNXr+UfTmg97NjnsPLC342MJbIdoPb021yvvzrVJujW38dwXfOXzpH3nbrMaLJYHWukjoAwv 2WhcBY1PRZ+QYgsNLcgQVUryLj52QFaGPwC6cgFq6GEnnFaIiSg3AggQGCGLp7pB8PGHWX3PjFa3r J0ClsDRfXjWjJPXSMagbKj/qxDdX3Uc+zFHt7Vu6Ufmjt10nAQAIubcpWW6oz51NuAc2lcYxaha2s x4nRVB8A==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1l0jyz-0002D0-5n; Sat, 16 Jan 2021 11:43:05 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id F2A28306099; Sat, 16 Jan 2021 12:42:30 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 310DD20285FB1; Sat, 16 Jan 2021 12:42:30 +0100 (CET) Message-ID: <20210116113920.018268080@infradead.org> User-Agent: quilt/0.66 Date: Sat, 16 Jan 2021 12:30:39 +0100 From: Peter Zijlstra To: mingo@kernel.org, tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, jiangshanlai@gmail.com, valentin.schneider@arm.com, cai@redhat.com, vincent.donnefort@arm.com, decui@microsoft.com, paulmck@kernel.org, vincent.guittot@linaro.org, rostedt@goodmis.org, tj@kernel.org, peterz@infradead.org Subject: [PATCH 6/8] workqueue: Restrict affinity change to rescuer References: <20210116113033.608340773@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org create_worker() will already set the right affinity using kthread_bind_mask(), this means only the rescuer will need to change it's affinity. Howveer, while in cpu-hot-unplug a regular task is not allowed to run on online&&!active as it would be pushed away quite agressively. We need KTHREAD_IS_PER_CPU to survive in that environment. Therefore set the affinity after getting that magic flag. Signed-off-by: Peter Zijlstra (Intel) --- kernel/workqueue.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -1849,12 +1849,6 @@ static void worker_attach_to_pool(struct mutex_lock(&wq_pool_attach_mutex); /* - * set_cpus_allowed_ptr() will fail if the cpumask doesn't have any - * online CPUs. It'll be re-applied when any of the CPUs come up. - */ - set_cpus_allowed_ptr(worker->task, pool->attrs->cpumask); - - /* * The wq_pool_attach_mutex ensures %POOL_DISASSOCIATED remains * stable across this function. See the comments above the flag * definition for details. @@ -1864,6 +1858,9 @@ static void worker_attach_to_pool(struct else kthread_set_per_cpu(worker->task, pool->cpu); + if (worker->rescue_wq) + set_cpus_allowed_ptr(worker->task, pool->attrs->cpumask); + list_add_tail(&worker->node, &pool->workers); worker->pool = pool;