From patchwork Wed Feb 7 01:19:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 197697 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1931199dyb; Tue, 6 Feb 2024 17:21:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IEe7kJiZdq+7ktKkBC3kzJttCdNWAi5pg4iXv+NXfTq4OnYzmgFvrM7dN+RLGtIPmjzS/zf X-Received: by 2002:a17:906:110e:b0:a38:40eb:9fe6 with SMTP id h14-20020a170906110e00b00a3840eb9fe6mr2469404eja.33.1707268879210; Tue, 06 Feb 2024 17:21:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707268879; cv=pass; d=google.com; s=arc-20160816; b=qGGiiossgJpCNDFhRLL3guFn1b2X/d3h9vyR/WLcHwOsoMspg2e6GXjkPTsX35z3A7 EnmmsGdThw/+WXAzKgp0BQfixxLAHTMmsrpy/IuqzYFjNBu54xa43hP+mfDj8kBjjOk+ v8AmkEFwkp5u7k2+aOxEU3lJ9oXKz8EcX3YmhdMOuRKhXo6z7gv9ZOTGzfHR/UycIQ4a R6/9lnDYwag3sOKPi6c5XntV5VgUZkUb+NlkY0Q/HqPm4+x0kDN5GTJKeuPVTU8fw6P4 +D2YjGjGYnPrVcGOa0NXwXb9Fm6Km9kHBmltF/4Nyfd6HfCm2VecV0JcWXMGoUe6nvxP cBsw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=vJQWPdqy08UQ8K2twJy9pwfGNKDdokiadGdxmJITQUM=; fh=kT0FJWp4eHoP5uhLdp63MTxTzboChLYL4pcZhbNhXmU=; b=CgVcCN62C5MkizNo8RF1alpJBzKxRhEY0xwoO4oUJZ6o8fzE5h1e/rE6pcMo3Q3s6x bWBfVo3fi+qDWncQ/7jwcWxFieHJd1iHNxVNFdplRod6CV9x2GqEPuqnfAnAGX9+nZoo rjTn96Nb2yvUexyE7ldSMpVHzChjnWy+ztSK+ZKtxDRNvszbCik8IuE8pOQUN0/dDrFw uv2QMl5OS3rxXQKx/2Iae9jNMb+EkHcLIAVONaGlnuU3XTHwDKFWAvE55fHRDrm0pAWD Wi6Uk5BeMEpEt1TLVuuVh9qUZjGlYkEzJYND5cPAcZYvv7hdXGjJrmPJpTKLI0k7Gz6g yzXw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=a93f2x24; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-55795-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55795-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=2; AJvYcCWHTxvmEC4oGFivGiimBfEAG4LQvEo5t8KW0UCkfOlq3wkEn+8AbAVPquyOPtraXM4jvPVm7R7njzS4I9UAUObiizAGWg== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id rs6-20020a170907036600b00a385a44bb03si200583ejb.516.2024.02.06.17.21.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 17:21:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55795-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=a93f2x24; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-55795-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55795-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 24DBE1F2547E for ; Wed, 7 Feb 2024 01:21:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7253AFC15; Wed, 7 Feb 2024 01:19:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="a93f2x24" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B6FC1B95B for ; Wed, 7 Feb 2024 01:19:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707268781; cv=none; b=Zl8jq+/FQlow4HZs9HnzJUB+AyU+KD56VTNRMAaORcLAgTGpjcTj0YShtCy1J5GG10anVy9WpVD/AW9czQ15z9BrLocjee5h/8VaviUpyBbUQj7UnlPOQl5k4QixBloxvaMYdqPSdWJNpnbXhqjgNCC7BP+EFY9ca/LLA7Lr1RY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707268781; c=relaxed/simple; bh=FS+l524qoBFbVz1FfbcQ2i0NBRG/MdSdZhRbd/PgfWA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lUtMiVrZ42epUvre2g9XleIRHVB4GaxHEUsBbBx05I63fH1FcITtFrVPRHV2CsdscNo2Bcpr8C/RlWgxBH3HRSL0TkVzVB2OSZ6fcusahHtFU070s7gqiW7svmZOQCRXlWWabANbL3gFP87pPc0oGbPudfoWRKuAPkwmMMdSmT0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=a93f2x24; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707268779; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vJQWPdqy08UQ8K2twJy9pwfGNKDdokiadGdxmJITQUM=; b=a93f2x24Sw81Gh/wSK/QjTOtDKgf1UrWDsRaaZZD7tz+ncEKYuvejZEyuR33mHlZyPte2C TiqXb9yOFYPaU1HYCt2ahTeeS/gZiN6qWJyi96cxblXCfWK//P/9/VaOSPnJE3y6JACigH XipJez7eKOk3U/Gz15ceoyHAFAKjdso= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-455-3g99GikHP0uEyRJ_BmBzXA-1; Tue, 06 Feb 2024 20:19:34 -0500 X-MC-Unique: 3g99GikHP0uEyRJ_BmBzXA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CA4311C04B4C; Wed, 7 Feb 2024 01:19:33 +0000 (UTC) Received: from llong.com (unknown [10.22.16.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4E18640D1B60; Wed, 7 Feb 2024 01:19:33 +0000 (UTC) From: Waiman Long To: Tejun Heo , Lai Jiangshan Cc: linux-kernel@vger.kernel.org, Juri Lelli , Cestmir Kalina , Alex Gladkov , Phil Auld , Costa Shulyupin , Waiman Long Subject: [PATCH wq/for-6.9 v4 3/4] kernel/workqueue: Let rescuers follow unbound wq cpumask changes Date: Tue, 6 Feb 2024 20:19:10 -0500 Message-Id: <20240207011911.975608-4-longman@redhat.com> In-Reply-To: <20240207011911.975608-1-longman@redhat.com> References: <20240207011911.975608-1-longman@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790201172117442311 X-GMAIL-MSGID: 1790201172117442311 From: Juri Lelli When workqueue cpumask changes are committed the associated rescuer (if one exists) affinity is not touched and this might be a problem down the line for isolated setups. Make sure rescuers affinity is updated every time a workqueue cpumask changes, so that rescuers can't break isolation. [longman: set_cpus_allowed_ptr() will block until the designated task is enqueued on an allowed CPU, no wake_up_process() needed. Also use the unbound_effective_cpumask() helper as suggested by Tejun.] Signed-off-by: Juri Lelli Signed-off-by: Waiman Long --- kernel/workqueue.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 49fe082fe328..3044ad6f9496 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -5084,6 +5084,11 @@ static void apply_wqattrs_commit(struct apply_wqattrs_ctx *ctx) /* update node_nr_active->max */ wq_update_node_max_active(ctx->wq, -1); + /* rescuer needs to respect wq cpumask changes */ + if (ctx->wq->rescuer) + set_cpus_allowed_ptr(ctx->wq->rescuer->task, + unbound_effective_cpumask(ctx->wq)); + mutex_unlock(&ctx->wq->mutex); }