Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp14271764pxu; Mon, 4 Jan 2021 18:43:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJwkaxfBYz7O1mwu4j/17n6aByKc/anWyUhpciGeFbTWRM0AI2HBSN/GVKnisDlMcyLBEjZ+ X-Received: by 2002:a17:906:5e0f:: with SMTP id n15mr62830489eju.459.1609814625463; Mon, 04 Jan 2021 18:43:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609814625; cv=none; d=google.com; s=arc-20160816; b=dF0DLEMCclOjW5PHOTybsXZ8mmiRnJ2M8cRD8gCplyIJtarG2h1urSmWmSIstLlqQX CIMMEqoDNxPfR8xm37AabcHATmEbsz6BQEhWZbJKCWL0w66AzYAY9plnPurKr9MLkl7Y aYdAYLntdjkvN47759N7k4yid8bGrnEvIGKIPSIuvdKrWvyLD1Rz+eTvmsWA1MdgLuRY pU2eXfDae1VhPETz0VDNIwIwUIrhw/gO7GLwabIc9+ukVL0t0f7rN0Ea3/rm+EG9HLUn QWuOsKGpGqylWRt0N1HZ0wJGAHDf7Bemv7M0+iwxwWvv0i/h039Ynp6ImVyuTR+NS4td iz2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=GcsC8lp175/RSBxacvCaBbl9ftLmbMsKR9zwf/ifHzg=; b=FevtNf1JzK29mHbN2umTh7yyC3PpltvO7+6K3iA0j/M1Qa1Qo+BMdUmq/H1GtkFRq3 TocnJAVNxXxL+KOKd9od9hZiMu5q0Zt3A/k9Du8dFduh0kMxUkugraerhEH9De7UM2df ssBSFvRpEJ6uN1bRn8jLQ4AwayxA1AdzHjPGe43a8Oz/6RJ9WBe0t1zIhFcSKONFxH6i XPSJpVMH04XByxKM1hK7s/Ep1wGLfdqiJeQgBL6Eek9hEj5k3DaBlyzSPRQoNRqAJlzc BIXIQGTz6yymnJFusrdzddyyxXBPg8My/yl6KEarBhme5r5ravhkgaE6qvYzCUnNJB7y UcvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SLcWXupB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hs12si31661354ejc.74.2021.01.04.18.43.22; Mon, 04 Jan 2021 18:43:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SLcWXupB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727701AbhAECmA (ORCPT + 99 others); Mon, 4 Jan 2021 21:42:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726239AbhAECmA (ORCPT ); Mon, 4 Jan 2021 21:42:00 -0500 Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E389DC061574 for ; Mon, 4 Jan 2021 18:41:19 -0800 (PST) Received: by mail-io1-xd2c.google.com with SMTP id w18so26977958iot.0 for ; Mon, 04 Jan 2021 18:41:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=GcsC8lp175/RSBxacvCaBbl9ftLmbMsKR9zwf/ifHzg=; b=SLcWXupBZc8HMhM+91+H2UlhEKcVksMphM8CG5/Q8gZUo+5VUDuaot1HWck411dKSg ZZnjYMTwChIQ7K5y12TC4tkiEb4MWdUgtQ/gcByWPsQNRASSKNkA4mfNib1b6AJVQHdV yH0WuXERXI/dWbY3dRON7zFZzTZzuVctpNQvzxZbP/N2TElc7PWkOvZj6tTOnV5fBWC2 OGUl5aepNIk831CToxOMhRH4YwcbKZiRFX+v/30037mtbBz1XzDj0yFoQNU7Ky6a+CW7 6eL9FFBzCTtp0bG7T3MBBeiwyCDErQnn64tbf3GFU79aSayd9iU0H/IMyUbnQUPHMoDF n65w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=GcsC8lp175/RSBxacvCaBbl9ftLmbMsKR9zwf/ifHzg=; b=Y3NtVgY6idY9KBccs8mCBw5Hf1S+JjjL140/CkzoThc9cCmXkMguLpyCf4utG9wMvr xwJz+nYz4ih7dye0grb9aQEz3FAu6ZhBO7rXHZdOxdyszaOwU0j8/cBv5N3l/qixRot0 BfthFk+u7tnN0Dx+b1fLRk/KKn4GAAFJVJy8oW7Zuvl/oU+5KEgFBoOY6YYBqUljJ+Vf pXr1XnEo2h8cb3r83UVPQvOsz1xaucxX3Zux68PB+Kp1zsVWfZ1nFuaJeIg0aSzTbAvO 0dYF2jfG7NhkTM5xzOJ6NzN65q7dHiDIB+60ZlMFXgjhyy2wn2Bh2fR9vkTN4weuBcbo r5oA== X-Gm-Message-State: AOAM532CCJfn7XTHuAJjOYKHzWUkyrfejkVGRRrmf7REwCPk9BLsdhbx ihg2RC2LDAZjcuQZVegjt5DKwI6YAsNexiBOVOc= X-Received: by 2002:a02:ccdc:: with SMTP id k28mr62694993jaq.137.1609814478958; Mon, 04 Jan 2021 18:41:18 -0800 (PST) MIME-Version: 1.0 References: <20201226025117.2770-1-jiangshanlai@gmail.com> <20201226025117.2770-4-jiangshanlai@gmail.com> <20210104135649.GO3021@hirez.programming.kicks-ass.net> In-Reply-To: <20210104135649.GO3021@hirez.programming.kicks-ass.net> From: Lai Jiangshan Date: Tue, 5 Jan 2021 10:41:07 +0800 Message-ID: Subject: Re: [PATCH -tip V3 3/8] workqueue: introduce wq_online_cpumask To: Peter Zijlstra Cc: LKML , Valentin Schneider , Qian Cai , Vincent Donnefort , Dexuan Cui , Lai Jiangshan , Tejun Heo Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 4, 2021 at 9:56 PM Peter Zijlstra wrote: > > On Sat, Dec 26, 2020 at 10:51:11AM +0800, Lai Jiangshan wrote: > > From: Lai Jiangshan > > > > wq_online_cpumask is the cached result of cpu_online_mask with the > > going-down cpu cleared. > > You can't use cpu_active_mask ? When a cpu is going out: (cpu_active_mask is not protected by workqueue mutexs.) create_worker() for unbound pool | cpu offlining check cpu_active_mask | | remove bit from cpu_active_mask | no cpu in pool->attrs->cpumask is active set pool->attrs->cpumask to worker| and hit the warning And when a cpu is onlining, there may be some workers which were just created after the workqueue hotplug callback is finished but before cpu_active_mask was updated. workqueue has not call back after cpu_active_mask updated and these workers' cpumask is not updated. For percpu workers, these problems can be handled with the help of POOL_DISASSOCIATED which is protected by workqueue mutexs and the help of sched/core.c which doesn't warn when per-cpu-kthread. For unbound workers, the way to handle it without using wq_online_cpumask is much more complex when a cpu is going out.