Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2186998pxb; Fri, 5 Feb 2021 11:01:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJxfBGH9cY0Q8q83huywrUeDTevNNPv3vkCDfPpCyEcuUIDoWUgnuJmNqhjUwLoRsgYR5ioN X-Received: by 2002:a17:906:3e14:: with SMTP id k20mr5296653eji.42.1612551687538; Fri, 05 Feb 2021 11:01:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612551687; cv=none; d=google.com; s=arc-20160816; b=o0tfU4NlxflElzX1AM/eLh6iymvAGTuCJnHOlbjaef8Uvs6aYJvcgx9GA5VDKPA6qq /mPKCArZd+sRpEw7hz7sUjJUNUJNKENGTcs8273q8XUEtHjQAr6oK3pynf5pn2r8NEom GbIfHAH1mLDUjNJV2wNsjg0nWTxyeVtEHAYyuoz3RJFf4krbjZNR1+APlKSC6BuQQ/hN DLAOnqz/27AJ0E7ZLlve+Yq0enQrD4NVc32WzoecukJNlM3FyLgBIl+HSNbkx/RYsifo MYwhtPnnSfINgzm8LGlGyiJvFD70ItI//dsV4N9dB8CAHShLSJ3UTbRH6f4XFYSW/dk2 RyOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=gOSHrL2spfNcn7CXLUa5YhGsv4vv6pUOPjioJgLWu7c=; b=t+QXYsHSMuEvNiL4k/w7R8rJ3X/+kU7ur7NTkrame/wrhYdXHGiQzN88Qz1X07ehzR xOUTyAzlmBAsaXRUlxcNETSbu8xSNI87pSXh3RSJTigav8q5IKodGMa09vbfdI4nBxhG d5SUU6uOWUhsNOKYZjQbPeiVyCDpmyO4C9Jytsi+s4R3O+Qw2x6VSjvl60LeJXpxWnBL Pffg+695IvziFXKH6+aqQayPaqDfN474cwfdJG5Ett+6z25IhivUKCV3m5XaD70edrlA KFOPCm0NwXwTgotX6apO8ak/5KqccizA5F9A5QTbx80DVs03QjCFbQaeUgIyb2MOgtVN 5HMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=O0IHYjXf; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k13si5892668edk.387.2021.02.05.11.01.01; Fri, 05 Feb 2021 11:01:27 -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=@linuxfoundation.org header.s=korg header.b=O0IHYjXf; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233364AbhBERRj (ORCPT + 99 others); Fri, 5 Feb 2021 12:17:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:54522 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233481AbhBEQAH (ORCPT ); Fri, 5 Feb 2021 11:00:07 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id C38B465072; Fri, 5 Feb 2021 14:13:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612534383; bh=vm3Tf6PgpV/aRtwZ30Tdo+AbhfaHVugwMLr19Vq/+6s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O0IHYjXfVo/P2KRJhMqG/4yeI4U/Xg/dbhvSmaSIhTbHglKjhsvYKDTYAcV4r9DsO lT4ewVRp9UiYsUnxZ40uCsyXjq/LQeWy1ns9O7pGrZxM45ihjBdpDU0+ketBafwUcO dCmYm+Un7lnHi3FbfF7USegeoYLokek24XyshdFo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Peter Zijlstra (Intel)" , Valentin Schneider , Sasha Levin Subject: [PATCH 5.4 32/32] workqueue: Restrict affinity change to rescuer Date: Fri, 5 Feb 2021 15:07:47 +0100 Message-Id: <20210205140653.708479216@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210205140652.348864025@linuxfoundation.org> References: <20210205140652.348864025@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Zijlstra [ Upstream commit 640f17c82460e9724fd256f0a1f5d99e7ff0bda4 ] 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) Reviewed-by: Valentin Schneider Tested-by: Valentin Schneider Link: https://lkml.kernel.org/r/20210121103506.826629830@infradead.org Signed-off-by: Sasha Levin --- kernel/workqueue.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 28e52657e0930..29c36c0290623 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -1847,12 +1847,6 @@ static void worker_attach_to_pool(struct worker *worker, { 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 @@ -1861,6 +1855,9 @@ static void worker_attach_to_pool(struct worker *worker, if (pool->flags & POOL_DISASSOCIATED) worker->flags |= WORKER_UNBOUND; + if (worker->rescue_wq) + set_cpus_allowed_ptr(worker->task, pool->attrs->cpumask); + list_add_tail(&worker->node, &pool->workers); worker->pool = pool; -- 2.27.0