From patchwork Wed Feb 7 01:19:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 197694 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1930870dyb; Tue, 6 Feb 2024 17:20:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IFOF00YRaGijTPJqs7dVMZvQfNP7Q0r6M4ewcrq5CPp7MF+szSZesHmq7p8aIu/MFWbt9TQ X-Received: by 2002:a17:903:24c:b0:1d9:63e2:680a with SMTP id j12-20020a170903024c00b001d963e2680amr4022693plh.24.1707268828468; Tue, 06 Feb 2024 17:20:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707268828; cv=pass; d=google.com; s=arc-20160816; b=J8lquErnroasPlZgm37VtvHvYnS2t7ZTFmqpK2rMTDaQoZLBYBJeccn4PauH6EhDS0 Rcl7Mr6hYm40b8BU+lWKq2T3JXy5Z8j/9a2YMd4mpY4tJRLUPJ2UnCwBNeSfiL0k6ZC0 kJh6Vh3/LrEzw5SueqPdOWoqNKNIX/hUgwvW/aMd5nkgOm88a817ro7yQ0PBupeqcSRl iVzuV2+5Xnkhpq33JWudacNB2MMyJBKMC0hBdnGkK6hwArYtmbyz8AKqqqwazUprfcI4 YZgiOP70KuRS6ivufLPOE7pmEvXT7HJSFlgj9GiObdZLdVBQfubNJxBFnuLmkB96m7D1 gITg== 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=/Xu6Dy+LgyMX67Ta0NVKivdXcqKGVmjFkpKpX1QNbOE=; fh=1dxJLh+QIs55LKZJQ7J+dy07UPlexyaEvM3cDuCfT94=; b=iQggo+Cnb9gNdpTe+FhrGIozraPWA8d/fB2Da2PoJ8vjLh9QEpTcgRCf3GPYChjAih Ew7ChHxgZdDslSXb4t1+6O2c4TuiJRunqgonAfNPOaNvgIc+Yzcu7+MIZIpb7ojDuOEu /4935+Ll6YibPdWe+FeSx2Fq63P+W3ti+wd+dhfqT9E5IoKMYKJoALxgy9lJzqvmSvvd LvER36xrdTw9yUVj+9MI6jMALrAnDxOscxl2PdlJswMwLiD7afXMi1bGDhxvlinvaD/E xLAncPJNWCQDd8y+vE53ReHzgSs+0l5WBq+sk5IIuZJ6TYhFBJbYrYMxRYfOAzS3bUMO V0JQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EPKf5oQF; 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-55791-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55791-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=2; AJvYcCWO5PJnUq+EEH/BeLOFCgUT1fOYcyDgK23inkFZWS/ETWrjtpnD+6rXijFszWmkqZr4iUzknfRL3nJ0vedJXOMgk7vBYQ== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id c20-20020a170902c1d400b001d78f9081a9si288458plc.313.2024.02.06.17.20.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 17:20:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55791-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EPKf5oQF; 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-55791-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55791-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 0DEAF282D20 for ; Wed, 7 Feb 2024 01:20:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1AA3C1B942; Wed, 7 Feb 2024 01:19:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="EPKf5oQF" 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 6962612E7E for ; Wed, 7 Feb 2024 01:19:35 +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=1707268777; cv=none; b=GBcZvNIP+kk2iBIH2b6YKdshsJeJLxNrb/InxxQyi4fvR/3C+E3tb4Lm9V2sCsdt735F9VRq1ikZTmkqqtKugHlDVSpfXK0GgcPGFBzUH5kpv1zCASrfqTtEZYGc9lFz8Wuuyj4PV34VATOSi1IjWmMyr+e98cDF1Do52yy+fGE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707268777; c=relaxed/simple; bh=jtcRfS7FK70oPiJGDW4/0HuF2nzmDdtB4If+8e4T7MQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=d+aH4J7wYVi9SSuHAs4n0qTaY/GrL1cEUTfQ3G2DTEgPI4g19iEtmpuSJhHLMblK3yJDDnd2qXqKzof3KWuoM5Zk9qB2TtyP8l2W3EVqLAqAk0ChfHqM2b0BdyA2CK2nauQXOj8zSWKQ2ZpJqfc/EZIF94VgRXs7GxGL4nA9Tkw= 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=EPKf5oQF; 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=1707268774; 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=/Xu6Dy+LgyMX67Ta0NVKivdXcqKGVmjFkpKpX1QNbOE=; b=EPKf5oQFaXlRfqe7kyJfqDpWchYQNpBsKGIagmPmKHukQ2DxYp2hjz7LLUDmS3HQaWEhwf hyKvcORWhIRWM+pH2dqljEkkPbdWeUmSwmGkk10ppo3viu5IoLkxh/Bl669RUDv5bp5EEA v+x6U9AgCiF+792v8ynnCZsrJTiaNAs= 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-624-v9z3RzMnM_qw_2dRQMJXGA-1; Tue, 06 Feb 2024 20:19:33 -0500 X-MC-Unique: v9z3RzMnM_qw_2dRQMJXGA-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 AAC7A3816449; Wed, 7 Feb 2024 01:19:32 +0000 (UTC) Received: from llong.com (unknown [10.22.16.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2F50240D1B62; Wed, 7 Feb 2024 01:19:32 +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 1/4] workqueue: Link pwq's into wq->pwqs from oldest to newest Date: Tue, 6 Feb 2024 20:19:08 -0500 Message-Id: <20240207011911.975608-2-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: 1790201119099541277 X-GMAIL-MSGID: 1790201119099541277 Add a new pwq into the tail of wq->pwqs so that pwq iteration will start from the oldest pwq to the newest. This ordering will facilitate the inclusion of ordered workqueues in a wq_unbound_cpumask update. Signed-off-by: Waiman Long --- kernel/workqueue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index cf514ba0dfc3..fa7bd3b34f52 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -4804,7 +4804,7 @@ static void link_pwq(struct pool_workqueue *pwq) pwq->work_color = wq->work_color; /* link in @pwq */ - list_add_rcu(&pwq->pwqs_node, &wq->pwqs); + list_add_tail_rcu(&pwq->pwqs_node, &wq->pwqs); } /* obtain a pool matching @attr and create a pwq associating the pool and @wq */ From patchwork Wed Feb 7 01:19:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 197696 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1931173dyb; Tue, 6 Feb 2024 17:21:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IGD2/Z4H3hsKGMPD2FaIVfsNU2eVmPd45ihCm2XPbXtPInDCRXsdcTdkuVYRmqzEysvgrVr X-Received: by 2002:a05:6902:120b:b0:dc6:9e21:9079 with SMTP id s11-20020a056902120b00b00dc69e219079mr3575132ybu.45.1707268873997; Tue, 06 Feb 2024 17:21:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707268873; cv=pass; d=google.com; s=arc-20160816; b=QlGxocO3gNpkTk3egc+BF5IBHCAkd7Qg9AZC4NiFkKYL8fDBsE0Yg0ca4H3hWBObQt E7HUDJIPKCbcXZVIXm4YzxEbbKL9ODKKWYQwpGGXkswZhZh/jKyl/0T5A6UcvUBZCOG/ 6P8ZOF/SlbAvfL8M3Ye1yl2bUU3H/5E+IsmQot7pM4186PGFps5X2oJoRWEAsMS4zkr8 PDpgzXtl8ntbWTQyn8lz5Bk2JZrVft0WGBR/oMElw25fa+xwVQfZiyfp6SXqzCVyCu2C alp4ISBAPYBI5CCe+Q9SplzyFigUiTapR7GQ4Tp2lijdmBH/Pq53hHT0dvdDDX+8xgOE FDiA== 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=hwZ9dmpqpCvKkj51vCJ2+0Ny4PTM8rYb+AJFZphIZm4=; fh=viz7t/yRI7ZT8Movk3TkEk366+monqgoCwkr8TEaJ3s=; b=y+z6lAJVJ8LQ22T0dyg2yK3ubrp2GHAHKD4n1KkNtCYKaljqh/XXU5J92z10L/UV6X 3S0zE+gzLYkG2R3VPWg+07shDAaz5zDxsSq7RlA8qA4gM/nrxNiSzXb/ZESTSrsQ/8Mm ONbyTQKdmBuaFmQMjMXb9aXBg6aF7ZqkG1P59+LA+rH6T0gOsaVetPlWzyRyIZN2xGLk WN36rpFc138uDFC3QWErY3p1vFE1DR8IyxCdUeMGDB8VuM29Is/j1V8BkzWKDUXMj8Qx J5VcKocB8LnDOORJjLRKdeimb9CXowiTBydaTEShI1gyvSV0Ie4auoJsXQyyHkOb8C9y a6Sg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="TpTVTw/k"; 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-55794-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55794-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=2; AJvYcCUgWSP474ZfZfQ98nT94pbXci/A8fjPGnyzQm9bGHE4Gn3xb3lACBKPdFvrake4R8au0IPPBogPC3AoCdH1GgkYOeGAMw== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id x17-20020ac85f11000000b0042c3cf7282csi159947qta.537.2024.02.06.17.21.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 17:21:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55794-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="TpTVTw/k"; 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-55794-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55794-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id B67741C247E6 for ; Wed, 7 Feb 2024 01:21:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0410DFBF7; 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="TpTVTw/k" 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 7076C13FF2 for ; Wed, 7 Feb 2024 01:19:38 +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=1707268780; cv=none; b=BNVNWM3nusxX4Zj8dtwXcevU9UPgLQoB9I1Iix6OXbtAdBhV3a+RpCxuWtJjD9Y8DiI3ijStvinvFlzuof9svBErs5sspXomGXBOk+zfNeQ/s/Y5IktxAsPk2yCbwRQ0NUTbX7+585oGnpdAhl2AYGxF80/tUIxI2Xhrr0vIVDo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707268780; c=relaxed/simple; bh=QOD1jsvG/al9EJLO1f2eMnYHH/QabzJmg01wtGY+e5w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mliHu2ri9plmM0PgZZ3slrw1PZYyMIfjpQKbIm4961zoHNnr5Vw1ivv5bU4PaxqhnDb7LvLLPZY4DEqw/A7w1VKntUO8GwOmGdQdKXH9lwhizS1aXwLF2c+KkiCGvBvaQ7HybNvxOxUvsZ4VYmck9sZlfjrWPvG7bvWLrz7is2M= 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=TpTVTw/k; 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=1707268777; 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=hwZ9dmpqpCvKkj51vCJ2+0Ny4PTM8rYb+AJFZphIZm4=; b=TpTVTw/kW/opBsCK53tyQ3125grgdh5v0lRyD58ucQVn1pG/xUgsmKn6tHTAHLJx+puDmF Gg2mW19BCFFK8RyJPIJoSegr4Ful8T43PtKIVj+Yp+9vzdjyZOp4sVVvLPDJ3qm5eg+O09 qXOlHwE6UP9QLfBOzOXzbgGe1nQ4Q1g= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-609-fHpVIqdqNauEsen1Ax00gg-1; Tue, 06 Feb 2024 20:19:33 -0500 X-MC-Unique: fHpVIqdqNauEsen1Ax00gg-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 3ECC985A58E; 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 BA51540C9444; Wed, 7 Feb 2024 01:19:32 +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 2/4] workqueue: Enable unbound cpumask update on ordered workqueues Date: Tue, 6 Feb 2024 20:19:09 -0500 Message-Id: <20240207011911.975608-3-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: 1790201166681394862 X-GMAIL-MSGID: 1790201166681394862 Ordered workqueues does not currently follow changes made to the global unbound cpumask because per-pool workqueue changes may break the ordering guarantee. IOW, a work function in an ordered workqueue may run on an isolated CPU. This patch enables ordered workqueues to follow changes made to the global unbound cpumask by temporaily plug or suspend the newly allocated pool_workqueue from executing newly queued work items until the old pwq has been properly drained. For ordered workqueues, there should only be one pwq that is unplugged, the rests should be plugged. This enables ordered workqueues to follow the unbound cpumask changes like other unbound workqueues at the expense of some delay in execution of work functions during the transition period. Signed-off-by: Waiman Long --- kernel/workqueue.c | 102 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 92 insertions(+), 10 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index fa7bd3b34f52..49fe082fe328 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -255,6 +255,7 @@ struct pool_workqueue { int refcnt; /* L: reference count */ int nr_in_flight[WORK_NR_COLORS]; /* L: nr of in_flight works */ + bool plugged; /* L: execution suspended */ /* * nr_active management and WORK_STRUCT_INACTIVE: @@ -1708,6 +1709,9 @@ static bool pwq_tryinc_nr_active(struct pool_workqueue *pwq, bool fill) goto out; } + if (unlikely(pwq->plugged)) + return false; + /* * Unbound workqueue uses per-node shared nr_active $nna. If @pwq is * already waiting on $nna, pwq_dec_nr_active() will maintain the @@ -1782,6 +1786,58 @@ static bool pwq_activate_first_inactive(struct pool_workqueue *pwq, bool fill) } } +/** + * unplug_oldest_pwq - restart an oldest plugged pool_workqueue + * @wq: workqueue_struct to be restarted + * @pwq: pwq to be excluded + * + * pwq's are linked into wq->pwqs with the oldest first. For ordered + * workqueues, only the oldest pwq is unplugged, the others are plugged to + * suspend execution until the oldest one is drained. When this happens, the + * next oldest one (first plugged pwq in iteration) will be unplugged to + * restart work item execution to ensure proper work item ordering. + * + * dfl_pwq --------------+ [P] - plugged + * | + * v + * pwqs -> A -> B [P] -> C [P] (newest) + * | | | + * 1 3 5 + * | | | + * 2 4 6 + * + * The unplugging is done either in apply_wqattrs_cleanup() [fast path] when + * the workqueue was idle or in pwq_release_workfn() [slow path] when the + * workqueue was busy. + */ +static void unplug_oldest_pwq(struct workqueue_struct *wq, + struct pool_workqueue *exlude_pwq) +{ + struct pool_workqueue *pwq; + unsigned long flags; + bool found = false; + + for_each_pwq(pwq, wq) { + if (pwq == exlude_pwq) + continue; + if (!pwq->plugged) + return; /* No unplug needed */ + found = true; + break; + } + if (WARN_ON_ONCE(!found)) + return; + + raw_spin_lock_irqsave(&pwq->pool->lock, flags); + if (!pwq->plugged) + goto out_unlock; + pwq->plugged = false; + if (pwq_activate_first_inactive(pwq, true)) + kick_pool(pwq->pool); +out_unlock: + raw_spin_unlock_irqrestore(&pwq->pool->lock, flags); +} + /** * node_activate_pending_pwq - Activate a pending pwq on a wq_node_nr_active * @nna: wq_node_nr_active to activate a pending pwq for @@ -4740,6 +4796,13 @@ static void pwq_release_workfn(struct kthread_work *work) mutex_lock(&wq->mutex); list_del_rcu(&pwq->pwqs_node); is_last = list_empty(&wq->pwqs); + + /* + * For ordered workqueue with a plugged dfl_pwq, restart it now. + */ + if (!is_last && (wq->flags & __WQ_ORDERED)) + unplug_oldest_pwq(wq, NULL); + mutex_unlock(&wq->mutex); } @@ -4906,8 +4969,26 @@ static void apply_wqattrs_cleanup(struct apply_wqattrs_ctx *ctx) for_each_possible_cpu(cpu) put_pwq_unlocked(ctx->pwq_tbl[cpu]); + + /* + * Acquire rcu_read_lock() before refcnt can become 0 to + * ensure that ctx->dfl_pwq won't be freed & we can + * iterate wq->pwqs. + */ + rcu_read_lock(); put_pwq_unlocked(ctx->dfl_pwq); + /* + * It is possible that ctx->dfl_pwq (previous wq->dfl_pwq) + * may not be the oldest one with the plugged flag still set. + * unplug_oldest_pwq() will still do the right thing to allow + * only one unplugged pwq in the workqueue. + */ + if ((ctx->wq->flags & __WQ_ORDERED) && + ctx->dfl_pwq && !ctx->dfl_pwq->refcnt) + unplug_oldest_pwq(ctx->wq, ctx->dfl_pwq); + rcu_read_unlock(); + free_workqueue_attrs(ctx->attrs); kfree(ctx); @@ -4966,6 +5047,15 @@ apply_wqattrs_prepare(struct workqueue_struct *wq, cpumask_copy(new_attrs->__pod_cpumask, new_attrs->cpumask); ctx->attrs = new_attrs; + /* + * For initialized ordered workqueues, there is only one pwq (dfl_pwq). + * Set the plugged flag of ctx->dfl_pwq to suspend execution of newly + * queued work items until execution of older work items in the old + * pwq's have completed. + */ + if (!list_empty(&wq->pwqs) && (wq->flags & __WQ_ORDERED)) + ctx->dfl_pwq->plugged = true; + ctx->wq = wq; return ctx; @@ -5006,10 +5096,6 @@ static int apply_workqueue_attrs_locked(struct workqueue_struct *wq, if (WARN_ON(!(wq->flags & WQ_UNBOUND))) return -EINVAL; - /* creating multiple pwqs breaks ordering guarantee */ - if (!list_empty(&wq->pwqs) && WARN_ON(wq->flags & __WQ_ORDERED)) - return -EINVAL; - ctx = apply_wqattrs_prepare(wq, attrs, wq_unbound_cpumask); if (IS_ERR(ctx)) return PTR_ERR(ctx); @@ -6489,9 +6575,6 @@ static int workqueue_apply_unbound_cpumask(const cpumask_var_t unbound_cpumask) list_for_each_entry(wq, &workqueues, list) { if (!(wq->flags & WQ_UNBOUND) || (wq->flags & __WQ_DESTROYING)) continue; - /* creating multiple pwqs breaks ordering guarantee */ - if (wq->flags & __WQ_ORDERED) - continue; ctx = apply_wqattrs_prepare(wq, wq->unbound_attrs, unbound_cpumask); if (IS_ERR(ctx)) { @@ -7006,9 +7089,8 @@ int workqueue_sysfs_register(struct workqueue_struct *wq) int ret; /* - * Adjusting max_active or creating new pwqs by applying - * attributes breaks ordering guarantee. Disallow exposing ordered - * workqueues. + * Adjusting max_active breaks ordering guarantee. Disallow exposing + * ordered workqueues. */ if (WARN_ON(wq->flags & __WQ_ORDERED)) return -EINVAL; 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); } From patchwork Wed Feb 7 01:19:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 197695 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1931032dyb; Tue, 6 Feb 2024 17:20:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IHo3cZ0yUibQBNNNrJAIi9YoH3vs0fZS2g9nsxVSFXdpU/0N3GxRLoEmjJ9w504KU2FhVKD X-Received: by 2002:a17:902:d54a:b0:1d9:6071:30a9 with SMTP id z10-20020a170902d54a00b001d9607130a9mr4949512plf.13.1707268850972; Tue, 06 Feb 2024 17:20:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707268850; cv=pass; d=google.com; s=arc-20160816; b=fALc7acjNX32r77WhvtADDvSZypqKunO+21+Ek5vJ3GbCR3tPscjMCpBrCCMJ9z1HX 2Ze4xiyX9T4SUTXAw7LpxNu4uLWc8Kk6WKqb8y/6i5r/TNKWE+C/FWnQLDtiUHXqSG8+ 5s31jJGjqSjCDU5UGhoJNPiHrPbwbGdUXkZ9Y26YLnGIH+zNL9MeFZBpZKxri5HYZXJq 7qeJTU/FjADZnjl22OQR+76cNa/W4rVFvXYnHdGHUL08yZdi7sbgpDI+r0oRjaitSrcp CfaQ25MaG+tELn6wvwC9nHdos+bvxeYAaUPL17YQBFbMEnf+3tD6ZG6Gs/db/a7YJKBr qp6g== 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=rs0fe4YlOD0l4N4FR/S8D6TW5/0PHTLNKLmnFNrs1i4=; fh=+Qf8SdoBLv6mG30lbUL8Hn5uuF1SpkCosD2wBdtu0ng=; b=CjSRZF98B8CdF0iMl/DSheJA9T/wMxiMQ1zB4UpdXTkxfMQGs5rA/c2f5AxdSKpy4T LeOLSWZozatdoiPlp7I08654EHmojdSTUcKRFoHHTCUEWtclcJgMxm3lgIV5nIQyPw2V FxO0p1Q58zVm2PQN2wjwWsEqzdUcHa+cTFRbMBN/VPR5dqjb8b80BaI19mjv5YXa6yWR jfJPFBtk7KN9jmzz3MY/3EobtrBxXGtwMUG8e5DF0Oj5QfR1YiEk/wgnHO1OfvvDWRHJ RDhl0muZo5SjM8mNhfLAl9d5mURKwORUF5wDbc5Z+UYClw0PNrlDYupNLJHIacWbrfxW poEQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=G35drRw8; 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-55793-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55793-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=2; AJvYcCXXVvKlhG8GpMPkLFNnO1zYUWANRj86X3mipfUq/IUJuwW3F5Zo6SOXa4nEC3TxWDj5IMdu5ROtwKKrziGsMMG185LEmQ== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id u13-20020a170902e80d00b001d960e75074si340602plg.31.2024.02.06.17.20.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 17:20:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55793-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=G35drRw8; 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-55793-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55793-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 B7B272882A8 for ; Wed, 7 Feb 2024 01:20:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D59558F5B; Wed, 7 Feb 2024 01:19:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="G35drRw8" 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 5393012E78 for ; Wed, 7 Feb 2024 01:19:37 +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=1707268778; cv=none; b=F7Vvwkquh7LJU7AHsQy9jjJ4fkZe3mbH3u73yRYHpU3lV3J1asu98D7dLzpqRwzzytE20Bpb+WoQFeMzXvP05ERHpptBSj+viv1V8I7SZMlFPCnIeNnQl/R5rL/lOCGRHHkxsXAA+s5OJAQOl6Z84xat3CmAiKogX9GCKb040yQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707268778; c=relaxed/simple; bh=J65o7hPKuyaZeWfHkvaapxx63RY6RSdtfljnA5r1ZuY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pDLTbo5nu+zpvsI2w3NorwBYMPXc6BuNTSPitw4kUN7aqe+2J2uqFWtVigpt202O8hAiu6LrgKKb5Fil2HvPpgH8fUflt+v6eH5xW+etnGoVaMNO16pR5xdNJYS1DkLCRmdx3opWtzDUfKkIfv5YE242k4ymlluxlR3ustNM53U= 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=G35drRw8; 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=1707268776; 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=rs0fe4YlOD0l4N4FR/S8D6TW5/0PHTLNKLmnFNrs1i4=; b=G35drRw8u9IcnIz6OglUMA+4Q/SdN6crsh9QQgA8fhKf/I5P81zfA6mFj5i6+c7AP5HKha 5KenPJ7Ugp3q6XL9bwhSTCfZ2qo1PKeS/zkFwn6hNraqdfoqRw6sl2UjPpgaOaQFhZVdCd WNDFUf1nM1/w9LCwANjh+k2hVX03ORg= 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-457-6g3ZwjHbPjGY7P-phbz64w-1; Tue, 06 Feb 2024 20:19:34 -0500 X-MC-Unique: 6g3ZwjHbPjGY7P-phbz64w-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 57EB93C1E9C5; Wed, 7 Feb 2024 01:19:34 +0000 (UTC) Received: from llong.com (unknown [10.22.16.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id D93F040C106C; 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 4/4] workqueue: Bind unbound workqueue rescuer to wq_unbound_cpumask Date: Tue, 6 Feb 2024 20:19:11 -0500 Message-Id: <20240207011911.975608-5-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: 1790201142603712629 X-GMAIL-MSGID: 1790201142603712629 Commit 85f0ab43f9de ("kernel/workqueue: Bind rescuer to unbound cpumask for WQ_UNBOUND") modified init_rescuer() to bind rescuer of an unbound workqueue to the cpumask in wq->unbound_attrs. However unbound_attrs->cpumask's of all workqueues are initialized to cpu_possible_mask and will only be changed if it has the WQ_SYSFS flag to expose a cpumask sysfs file to be written by users. So this patch doesn't achieve what it is intended to do. If an unbound workqueue is created after wq_unbound_cpumask is modified and there is no more unbound cpumask update after that, the unbound rescuer will be bound to all CPUs unless the workqueue is created with the WQ_SYSFS flag and a user explicitly modified its cpumask sysfs file. Fix this problem by binding directly to wq_unbound_cpumask in init_rescuer(). Fixes: 85f0ab43f9de ("kernel/workqueue: Bind rescuer to unbound cpumask for WQ_UNBOUND") Signed-off-by: Waiman Long --- kernel/workqueue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 3044ad6f9496..81800cc2ee28 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -5332,7 +5332,7 @@ static int init_rescuer(struct workqueue_struct *wq) wq->rescuer = rescuer; if (wq->flags & WQ_UNBOUND) - kthread_bind_mask(rescuer->task, wq->unbound_attrs->cpumask); + kthread_bind_mask(rescuer->task, wq_unbound_cpumask); else kthread_bind_mask(rescuer->task, cpu_possible_mask); wake_up_process(rescuer->task);