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=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS 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 5AF5EC4332D for ; Thu, 21 Jan 2021 14:44:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0E77C239EB for ; Thu, 21 Jan 2021 14:44:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731989AbhAUOoN (ORCPT ); Thu, 21 Jan 2021 09:44:13 -0500 Received: from foss.arm.com ([217.140.110.172]:38428 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732107AbhAUOng (ORCPT ); Thu, 21 Jan 2021 09:43:36 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6FF5411D4; Thu, 21 Jan 2021 06:31:24 -0800 (PST) Received: from e113632-lin (e113632-lin.cambridge.arm.com [10.1.194.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C40733F68F; Thu, 21 Jan 2021 06:31:22 -0800 (PST) From: Valentin Schneider To: Peter Zijlstra , mingo@kernel.org, tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, jiangshanlai@gmail.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: Re: [PATCH -v3 5/9] workqueue: Tag bound workers with KTHREAD_IS_PER_CPU In-Reply-To: <20210121103506.693465814@infradead.org> References: <20210121101702.402798862@infradead.org> <20210121103506.693465814@infradead.org> User-Agent: Notmuch/0.21 (http://notmuchmail.org) Emacs/26.3 (x86_64-pc-linux-gnu) Date: Thu, 21 Jan 2021 14:31:20 +0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 21/01/21 11:17, Peter Zijlstra wrote: > @@ -4972,9 +4977,11 @@ static void rebind_workers(struct worker > * of all workers first and then clear UNBOUND. As we're called > * from CPU_ONLINE, the following shouldn't fail. > */ > - for_each_pool_worker(worker, pool) > + for_each_pool_worker(worker, pool) { > + kthread_set_per_cpu(worker->task, pool->cpu); > WARN_ON_ONCE(set_cpus_allowed_ptr(worker->task, > pool->attrs->cpumask) < 0); At the end of this series, is_cpu_allowed() allows kthreads with KTHREAD_IS_PER_CPU on any online CPU, even if it isn't the designated kthread->cpu. I thought there might be a race here, given this gives us a window where a pcpu kworker has the flag but is still affined to cpus_possible_mask. Now, given cpus_write_lock(), we can't have a CPU going up while another goes down. So I think it's actually fine, and I've been chasing ghosts yet again. > + } > > raw_spin_lock_irq(&pool->lock); >