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,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 EEF4CC433E0 for ; Wed, 13 Jan 2021 14:17:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A2F30233FC for ; Wed, 13 Jan 2021 14:17:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726626AbhAMORD (ORCPT ); Wed, 13 Jan 2021 09:17:03 -0500 Received: from foss.arm.com ([217.140.110.172]:36970 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725771AbhAMORC (ORCPT ); Wed, 13 Jan 2021 09:17:02 -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 4B1A9101E; Wed, 13 Jan 2021 06:16:17 -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 BA1023F70D; Wed, 13 Jan 2021 06:16:15 -0800 (PST) From: Valentin Schneider To: Lai Jiangshan , Peter Zijlstra Cc: Ingo Molnar , Thomas Gleixner , LKML , Qian Cai , Vincent Donnefort , Dexuan Cui , "Paul E. McKenney" , Vincent Guittot , Steven Rostedt , Tejun Heo Subject: Re: [PATCH 3/4] workqueue: Tag bound workers with KTHREAD_IS_PER_CPU In-Reply-To: References: <20210112144344.850850975@infradead.org> <20210112144843.849135905@infradead.org> User-Agent: Notmuch/0.21 (http://notmuchmail.org) Emacs/26.3 (x86_64-pc-linux-gnu) Date: Wed, 13 Jan 2021 14:16:10 +0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13/01/21 21:28, Lai Jiangshan wrote: > On Tue, Jan 12, 2021 at 10:51 PM 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) { >> WARN_ON_ONCE(set_cpus_allowed_ptr(worker->task, >> pool->attrs->cpumask) < 0); >> + kthread_set_per_cpu(worker->task, true); > > Will the schedule break affinity in the middle of these two lines due to > patch4 allowing it and result in Paul's reported splat. > You might be right; at this point we would still have BALANCE_PUSH set, so something like the below could happen rebind_workers() set_cpus_allowed_ptr() affine_move_task() task_running() => stop_one_cpu() ... // Stopper migrates the kworker here in the meantime switch_to() // Both cpuhp thread and kworker should be enqueued // here, so one or the other could be picked balance_switch() balance_push() ^-- no KTHREAD_IS_PER_CPU ! This should however trigger the WARN_ON_ONCE() in kthread_set_per_cpu() *before* the one in process_one_work(), which I haven't seen in Paul's mails. >> + } >> >> raw_spin_lock_irq(&pool->lock); >> >> >>