From patchwork Mon Feb 5 19:46:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 197035 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1158753dyb; Mon, 5 Feb 2024 13:36:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IElAAqNlaFdK4Ro3Xdc4+w14Qs+9bzbrgGTABdECul/VDVma1QMJ7YJm8ceVTTXwiDElmeg X-Received: by 2002:a17:903:1cf:b0:1d9:a4bb:29f2 with SMTP id e15-20020a17090301cf00b001d9a4bb29f2mr462897plh.46.1707169016376; Mon, 05 Feb 2024 13:36:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707169016; cv=pass; d=google.com; s=arc-20160816; b=oDDfQDJ4GDy8EYzSLxaQrtVXPOcgkh4uO+swGko8uT5wxqnVM4lCDvs/XKZQzL6wzo DxSdpJj1X1bqNmwPlRyk+gzActtjePTojnS6clvCPB6wXz3RsRIGbb49sFUIk4u6g+La nlde/20BhLtP/4emENSY89S8yDhnf+N7iq2vTQJe1FMVCMXbif2VP+44EDs5mJz3nNH7 UuAgH9p+FXeAJ1iA3Rx/AKKHvN/x3dmbmhek9D77D5pLs0M1g0f8PrSinQozRnskd7As AtUta+WUGw4eMgonMiv3xX0bm1j1SSEmCX+dd/q1s8deYVWZSz2LNAkHONsGATRrU0Tw Rs1g== 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=8fhJVNF3lWvjfwTgTO/+j3df6cdCJ3ZEvdWETu+5JAU=; fh=z/cqOEBRAMhXRHT141J5/R4klt7EA1vSVdZ6xIbGPlQ=; b=vZLgl74am9XxOjKViJjgga/TdaM0XNmbKxomPeBF3Ip4zparGedvzLOdyE6HZZttuT QpmFY+1sfeecttocH85H6+cIfV070xplce0LR2KejEohnOLdeAbOHajqMEJvVqm5dgbb UiN52JILwD3KYfpF6mWyFLxAo/P+e6vAFuG7+X3IEYBajWBYrX+29oZepOBwfJURDfjh Faynte0MLAOj4orzWFjLvCzppZAhPHfkF4H8Ufl/9SWYOhb6H65VNtSp6EVyVQGeZz1h ywF0dgmwIGprL704AcwtRn2cwWP01muiLZ5Tqye/cB51svKeV12Rf6YUoXbIj5xzyj+f Tzrw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GHUUy+oJ; 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-53861-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53861-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=1; AJvYcCVwKynqLsFtNZk/1Nj0J/BBnxLIA4A8873RC0KbnZeSB2QPPKjsfIug1SxFMVIjhyzHBCAQ5Szbkf4bNllVeC24F+KQ/A== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id q21-20020a170902c9d500b001d989e834ccsi429654pld.223.2024.02.05.13.36.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 13:36:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53861-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GHUUy+oJ; 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-53861-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53861-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 09B2C289644 for ; Mon, 5 Feb 2024 21:30:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 83C927FBA8; Mon, 5 Feb 2024 19:46:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="GHUUy+oJ" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 620DC7E59B for ; Mon, 5 Feb 2024 19:46:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707162402; cv=none; b=Od2Q6AD/jsbh0OVZpx2Tc8Rn+cygnYgq/dq2CJD8uvaPGk+ZgdUA9mUrBoXrVaWGkgoWxiFXti2DNQfLMXL7jEtRGwfKjTSA5JjSUNV4zEKGvXDefYbv0R6ugmBgB93ygrKeX0v6tXFOCzmBPKVSEwdfjhvNbBO4qMU9+q+P3Fo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707162402; c=relaxed/simple; bh=dD7RzPOu/yZs0SQ7pUw18W4NFsgZFjiCRghDj6nC4Pk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZHyQXIoexvJzzEXyhzFlNV9K6e6L6r1Ald4eZ9Fue8oa51zWBMCWtnw4eexKX32xhOw+jQX3MECywiisK92tT2Js7ZheabnstwDMzRDlKjA6XqY+7dO9+i3HRrUq/tQss+ZUZhP9PaGfO08m2f50mCRiFqw6dFXmGumCJ5Whd7g= 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=GHUUy+oJ; arc=none smtp.client-ip=170.10.133.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=1707162400; 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=8fhJVNF3lWvjfwTgTO/+j3df6cdCJ3ZEvdWETu+5JAU=; b=GHUUy+oJzpVvJkdtmEBhVKo5K9wTZ/vyOJcyg/7qM7cxZspnmrUgVbJVnaFmJBe/Z3wsA/ yd+NXfwydhTOE45pqCRRKx2gEpAXPtZd9UtmGy5t4IvlWGVJFNN+QBPtKp9uKo7X4gPIWG YhFOLxBx9MHndm916dnJNPkCETiWwkI= 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-584-9WDAA6SHPl2JC0toqD9PkQ-1; Mon, 05 Feb 2024 14:46:37 -0500 X-MC-Unique: 9WDAA6SHPl2JC0toqD9PkQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (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 096A5380451D; Mon, 5 Feb 2024 19:46:37 +0000 (UTC) Received: from llong.com (unknown [10.22.17.212]) by smtp.corp.redhat.com (Postfix) with ESMTP id 884B51C060AF; Mon, 5 Feb 2024 19:46:36 +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 v3 3/4] kernel/workqueue: Let rescuers follow unbound wq cpumask changes Date: Mon, 5 Feb 2024 14:46:01 -0500 Message-Id: <20240205194602.871505-4-longman@redhat.com> In-Reply-To: <20240205194602.871505-1-longman@redhat.com> References: <20240205194602.871505-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.7 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790096458663359530 X-GMAIL-MSGID: 1790096458663359530 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 Tested-by: Juri Lelli --- kernel/workqueue.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index f453f339f74a..bbd4269d2729 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -5049,6 +5049,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); }