From patchwork Thu Feb 8 16:10: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: 198462 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp283112dyd; Thu, 8 Feb 2024 08:20:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IGOj5YmgNAmG2i72xZVY+2/wztIoWNZSqxJmSigLm7ygOXdrmwswQcxHcSbrGqmVOEEzjFp X-Received: by 2002:a05:6358:793:b0:175:cfa7:953d with SMTP id n19-20020a056358079300b00175cfa7953dmr7218483rwj.2.1707409214822; Thu, 08 Feb 2024 08:20:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707409214; cv=pass; d=google.com; s=arc-20160816; b=P5HBuYK7+k7QHXoq8N9MLboakWYXqlE68CW/YlL28uigXhLyyzuu2acKfU5fA7W8nM 5ECrP4hxJ56AYCC3DBqdQNDuiG4p99WnZ+qIXGwRVyP2GLPPRNTYLofyO7n9JSaElASS wJnb+MHAnqvFpQ0kWhb1VkS4oTMYzCZztZG3B2iv35v491Tf0yr/H1EUQTuZxNv8aB8f OG8mjt7bE1giPVKPsO3O8NKHeRpCblxuVGRozuljSaNIB6XYlgES66X+2l9dUSmAhWlj NW2YeeXAdcvskg7fN3R9CypxN8JkPE2qp2orgZM8G9vy92zaKJ/8LLSQfvbm1/wvzJXR 4hCQ== 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=5XA6lxJRtme9XZjOU29sOA5VGCyBxUCqfyNP4YrGPvg=; b=MGhVC/WBXegXJ34RSH1y62IZ5Ty4M2vgHqXPNOei1Rri1+/wVK53iyXZu91zWWKBQG kD0msp9PFoOGNkE7gkXt3JSwfdsXvFzqutUMueBVATHLfjunvl15SNV2AGq5vozpcuqo cohNBSu/bhnowIptDYENwnf1CSypZkAhgYefEvUEVc4GiaoLg4+pIGYB0qMmYXCysJWZ mDz1ZYeOxod58PbkvNSkGGnN7P+h2wMnGW3A2X/j0JvQVwMZLJN1NAlIRDBAtKsEeSEH 0YBmdMPaMIouAVDlKNS7e3y5WRA+siC3KYqR3CNVDOMweF6X4parzJ1opsu9V0KyM74T jUUw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MTHnVcTX; 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-58330-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58330-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=2; AJvYcCWl3SgZByR4UwbuGkwEuRvSV3v6Iqg+dYrQATQpV7EYmcbkZ/aZPciC9OGSTj87SmVc0C/MjAniXPkX8LfqxxTfwgWO+g== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id o24-20020a637e58000000b005d8fdbbd5e8si3935966pgn.611.2024.02.08.08.20.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 08:20:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58330-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MTHnVcTX; 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-58330-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58330-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 3E420B25CB0 for ; Thu, 8 Feb 2024 16:11:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3FC727EF04; Thu, 8 Feb 2024 16:10:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="MTHnVcTX" 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 AE82E7D413 for ; Thu, 8 Feb 2024 16:10:31 +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=1707408633; cv=none; b=g4gdJt8e7GUffiIXlufjrU24bUbYQ6BTv4iMyK5W02mXOtS0dOlzk/XShDWqesOL55Ns61ubRn3D6XanoN/RvboeXCf6Rqre1yZ3Fg3wI1CQ2hIMAaXIFClttGiTjgozJKEN5knNyA6nA/vMnBh8voqa0h5uxFiJDhbHCQaqcWA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707408633; c=relaxed/simple; bh=jtcRfS7FK70oPiJGDW4/0HuF2nzmDdtB4If+8e4T7MQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RI16iIiXbxNG4YWZ/K2KtaiCFk1v5tcjMfm3WgJFN0xSgpXayuQakgC/NxK0tS5wvgkbZ5waTO2iMx4fTulDErDPe/XKxKo7oKAtpg+2Q6YrPv6ZwCWmjZOPRWffsI1bxIU85NSCwZTUyGZhFLCFJzDr/0ykzqFYR3gdi+TiPvI= 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=MTHnVcTX; 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=1707408630; 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=MTHnVcTXT//xsWX7usokCHK0FS4aLrXml0ki6SiEikeplu1opSBl1oD6YHy6Fs9AEHVgs+ F+X5uMSZbUVT57gXJZyeNwRVhoC102dV0Yos18Z1mBjh2XX7ZpSsaMzOoKEU6ZnwDaHTyE Qq44S2YnZJQ3k2/+6ppumrbwL/irdEM= 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-1-3Fv6xqkQNByRzOKeLgBVHw-1; Thu, 08 Feb 2024 11:10:26 -0500 X-MC-Unique: 3Fv6xqkQNByRzOKeLgBVHw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 EF068381644E; Thu, 8 Feb 2024 16:10:25 +0000 (UTC) Received: from llong.com (unknown [10.22.32.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7C130492BC8; Thu, 8 Feb 2024 16:10:25 +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 v5 1/4] workqueue: Link pwq's into wq->pwqs from oldest to newest Date: Thu, 8 Feb 2024 11:10:11 -0500 Message-Id: <20240208161014.1084943-2-longman@redhat.com> In-Reply-To: <20240208161014.1084943-1-longman@redhat.com> References: <20240208161014.1084943-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.9 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790348324693483287 X-GMAIL-MSGID: 1790348324693483287 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 Thu Feb 8 16:10:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 198459 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp276761dyd; Thu, 8 Feb 2024 08:11:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IHuwuwum7nkrhg7orSxVj5Yd0DOJwzk1IHCytwVb2Le4wA10Zl/SctmcQw78r/Fg/O2sXJ5 X-Received: by 2002:a50:d697:0:b0:560:b758:5e2d with SMTP id r23-20020a50d697000000b00560b7585e2dmr5131686edi.27.1707408714765; Thu, 08 Feb 2024 08:11:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707408714; cv=pass; d=google.com; s=arc-20160816; b=1H971E4oBi/iQM3nxAW1hj0Gu77gGcAMS+T4OarZQ4uuXlRLmLCGhybeUuQC4IuuZl 3h9m491JupAqlnpiwouYk2WlURn6wuiI+0m/Zrny8tDHE0KXPu5ZpPEZEJ2/pFkV7tfI yWUNEOipUpEgyQ1ODw0rofcZghyHm2JQbBzvuFofPRRmYEh094+M5YDCmnuWxlrGfkki qnp0XLEM3diqrtN32L40SSTSFhoXeJGTIUqaRqzmhjuQ6qZibQjHDD2WpzNGohqhH+qc 2b+5UoSvjIFLGdBglRJ+9RNNqVBKU2r/VM+u9I/Pr4iIaEMdzmNWKj/ALPScJnq9+Zui QDkw== 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=jjWwGxP0KxUYOxdmuDnOunDZH5/kaF4YpdnTH6SYbsI=; fh=6GgOncx5SGnLVrHPmfXxpkXeQyp/h800SuBKEnm0oC4=; b=ULoyxDlBQZx2uUiFLAivEPTFzmf2qUExihqk6k1fvd49flVUYOivlYnGv5cBw1pj3f 1Yavl2tdTt0SJWBVB8Lf4S2DAnD4elpKg2E9e+s228WwlWwhu3rxmCLXFMqrvtPXt9MY fWBeUnTjSxz2/ma/J4XsBU4hoKPeiQagn9gYa155OwsK4RDJ5Ci6lnaF2UUnSIXZx6dj I3SvuroRcLTsWfnX+qu1jsl6ixJYHNRKJepoCuQhB3ZFkRxrGekrRfjY4Jqe7BsA/Uj8 NiPYonEyvoKfEtRNSIL1oTpNCVcfteq0ZLmZofxRYBjSwSFa0SYkvzEC6hSwfasfYzER lFbQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HF9u6cPy; 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-58328-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58328-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=2; AJvYcCWA/KTS8T3civjDDDnmlLysQa4a+d25vGPYWmZ0nl/p4i5CqGSKub7dIZGRzcaTb47H5a8rez4cNLnkh51KSUDQ8hzNAg== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id z15-20020a05640235cf00b00561207ef594si189351edc.55.2024.02.08.08.11.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 08:11:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58328-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=HF9u6cPy; 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-58328-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58328-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 316101F23249 for ; Thu, 8 Feb 2024 16:11:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DC61781AC7; Thu, 8 Feb 2024 16:10:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="HF9u6cPy" 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 6C4127CF3A for ; Thu, 8 Feb 2024 16:10:31 +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=1707408633; cv=none; b=UJDRBE04tAAnnxzi8UJdfAKGRz8LVPh+gGCbWkNoxyVmnccAwTSLMTlpkgFY6aN9saTjIpdRs8IGYoUczo0QNRp/rDHM5i6kp9C4lYQWhyq0xoxZGGXU8c/MkApgLZTs71afi2TPtzXKEHVAAGdv8q36d05Iok1YaQwNhLoLJm4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707408633; c=relaxed/simple; bh=D5JMEe8lTSWuGsEK9VwlOoiVTZNVySteiIE0qWPY+QM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DBuOV6j2nmz+4upk8ijHQLRC9ZkumwNgpAIjpLJiOVj261v/DhbgL00P8Q+/z6J+pqNi8Fyl5vUkvs4J7AsIqz3cNCgJ8xR/SvJNtJ+KufbXkP9KpY51/jkyI6iFxWl3xjuB6MnCU/0e1IWgbVXZRj/3AYWleecgHvo8igWCG+Q= 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=HF9u6cPy; 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=1707408630; 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=jjWwGxP0KxUYOxdmuDnOunDZH5/kaF4YpdnTH6SYbsI=; b=HF9u6cPymxLaTR1mK5N4idZ34gayYJEUCJKU0+F2OEsdcoDWY5c5N+AaBisS+I3TPCFT// gp/B3ldoWcQYFzsD0D88iBoQZCVWADxvLEMHGHzWl/LoX1gZD4YAeaD6Od+HGZUC4UBH/2 tl90dRkGbWaTbf3lUEKuCHD1oZPy0S8= 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-56-jV7ckQhPNdivU-fS1x2orw-1; Thu, 08 Feb 2024 11:10:26 -0500 X-MC-Unique: jV7ckQhPNdivU-fS1x2orw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 7B65B85A58A; Thu, 8 Feb 2024 16:10:26 +0000 (UTC) Received: from llong.com (unknown [10.22.32.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A81D492BC6; Thu, 8 Feb 2024 16:10:26 +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 v5 2/4] workqueue: Enable unbound cpumask update on ordered workqueues Date: Thu, 8 Feb 2024 11:10:12 -0500 Message-Id: <20240208161014.1084943-3-longman@redhat.com> In-Reply-To: <20240208161014.1084943-1-longman@redhat.com> References: <20240208161014.1084943-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.9 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790347800737329075 X-GMAIL-MSGID: 1790347800737329075 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 | 72 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 62 insertions(+), 10 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index fa7bd3b34f52..e261acf258b8 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,46 @@ 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'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 + */ +static void unplug_oldest_pwq(struct workqueue_struct *wq) +{ + struct pool_workqueue *pwq; + unsigned long flags; + + lockdep_assert_held(&wq->mutex); + + pwq = list_first_entry_or_null(&wq->pwqs, struct pool_workqueue, + pwqs_node); + if (WARN_ON_ONCE(!pwq)) + return; + + raw_spin_lock_irqsave(&pwq->pool->lock, flags); + if (pwq->plugged) { + pwq->plugged = false; + if (pwq_activate_first_inactive(pwq, true)) + kick_pool(pwq->pool); + } + 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 +4784,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); + mutex_unlock(&wq->mutex); } @@ -4966,6 +5017,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 +5066,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 +6545,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 +7059,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 Thu Feb 8 16:10:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 198458 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp276697dyd; Thu, 8 Feb 2024 08:11:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IGyru2cAn5OLEqCG+MvFelE9TqxNlnLpy9r8ZZZ64qWKtaTR4oKmHYG7cxxzgwJ4s2E07Qm X-Received: by 2002:a05:651c:1508:b0:2d0:c9af:a336 with SMTP id e8-20020a05651c150800b002d0c9afa336mr4696644ljf.28.1707408709724; Thu, 08 Feb 2024 08:11:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707408709; cv=pass; d=google.com; s=arc-20160816; b=DvosVexB/k3Ua7Zkv1K0bEMrWCbvRbg2kilvsjzSYiCh7ipxRVnkAFge69JE/Q48ZG RMdRYzV6BgnGGbr3dRF6ndckUGyWuwJ1X2Sgo9pWuTKMwH6yy4fZnQFRFWhk8FVS7zQ3 F0xGsl/ltV4sPrlvsm7WMfqYVJxYZFGhvx6ceAfiHbOy2ClQR7P2lVfJon3zugqCspFS vn45tb53piUpn8ED/ANUijnc6dQXjhXhm3pC963d1NBLmAGg2KVoKeJ9vrQOz0YSIbA9 Irn61noSZ/Hfk8VFyEgp4zql3B6Da23Kflc71QWkh5iP7y3zG321hgmcUqNDY+c6cNci kpuw== 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=UVT04WTuQZOL2MdMj2b0Oo6Y1zY5WCBFIOr5ePYEIio=; fh=h/KZBJQpxELxZvmaxOKSnItCGgB1jjHiVNvkJ+IaFGs=; b=qKXcLCvh+9v5joUwvQ/t6brCGp25lPrI/GxV4M/Q0qRLfCuj+BMZTDBHAh2DQzfjRU ucBLNeGoSfjQ4SbuMUnxSsoICFmbRf7mK/BOQdA1juGxdGpVMSs3BBdQNZgzNVAeMph4 vD0jUOWj2RowlEKOK1QYOmkN+wAZr5sA8mvnKV97Gb/4pLsJ4JxRb7GXDAjuStFasYFk Hgx+HchoQEDUPK29Az13S9m9yWn02z/vO2zLMETDToQa6XS4hpnc0LBw3qpo4Iqs7MOD TV4bcYKjkcwcXrdIgoZ/qTFxHsW3WQJZ8MNM4okW/KQ6V/SJL49AyFOaVEmIO3P1EA6l hifw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TrQWBEtM; 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-58329-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58329-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=2; AJvYcCVi7Szz7leVPnfBDv9eWa5vSqJdqLFDitZrr+ePcU6DZwilH8OJwLr9HorgPXVDUj7Xp1uteIsj/e+6vBXdpcpr7nbLZA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id s25-20020aa7d799000000b00560c9a5fe2bsi1033157edq.230.2024.02.08.08.11.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 08:11:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58329-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=TrQWBEtM; 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-58329-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58329-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 370C11F28BAD for ; Thu, 8 Feb 2024 16:11:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3FC177E59D; Thu, 8 Feb 2024 16:10:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="TrQWBEtM" 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 AE7E57D411 for ; Thu, 8 Feb 2024 16:10:31 +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=1707408633; cv=none; b=IqA6a9hOMmoDzpk2KQycR0TYXORIneZGlrz42s0KVrdVjrPqcbTqPGX+Ygdtwp/nA2SYpX8QIt/UuKyCnSSaM9JpwYS1Z3v9Htt7E/OS41Vsujo/TlZ1iw4+TcfAhIE+LztXCp189P2oHQg60HIRovFkvwNB4ekBx7HZFD2vnE4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707408633; c=relaxed/simple; bh=3oS9kSqj13klcEDeru35Hnr/W1vfC6t+2kJTHNu3Y/w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fXlKCI4HSqbA4lLbe0dGeRcc8Mo4904PrTcdNHSebjy50aHBxd08gE14XEQwQuICswEHTjifqj5eBm3jcYJNl3iH3knz7eg/hEc1GfuUsqDZQEi99hEquySRYW7oLkuClxDiK4k0JBbsBb7mmtNd5bqxyzLLsyoSOeUNVp9gUTQ= 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=TrQWBEtM; 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=1707408630; 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=UVT04WTuQZOL2MdMj2b0Oo6Y1zY5WCBFIOr5ePYEIio=; b=TrQWBEtMFeBNjuuQnY4gzlnOKCXZcmvoHkBsDTwKnEY85bP8h2Pi7vDjDzvGIJvtIbXWzF P838tbL1oim3QJkfO0BnzGM/negEdk5BbbiJ9tDoPM2pWeIFiHZXEzatfMrjmPXzXjimqU pIeZCduXjLhkB/Y2pgL7cIy+NYyIRY8= 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-516-46iU4v4GPkOENz-AOr_wng-1; Thu, 08 Feb 2024 11:10:27 -0500 X-MC-Unique: 46iU4v4GPkOENz-AOr_wng-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 09CA485A5A8; Thu, 8 Feb 2024 16:10:27 +0000 (UTC) Received: from llong.com (unknown [10.22.32.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id 88FD2492BC6; Thu, 8 Feb 2024 16:10:26 +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 v5 3/4] kernel/workqueue: Let rescuers follow unbound wq cpumask changes Date: Thu, 8 Feb 2024 11:10:13 -0500 Message-Id: <20240208161014.1084943-4-longman@redhat.com> In-Reply-To: <20240208161014.1084943-1-longman@redhat.com> References: <20240208161014.1084943-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.9 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790347795222556550 X-GMAIL-MSGID: 1790347795222556550 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 e261acf258b8..8df27c496b63 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -5054,6 +5054,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 Thu Feb 8 16:10:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waiman Long X-Patchwork-Id: 198460 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp277140dyd; Thu, 8 Feb 2024 08:12:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IGfsqiL0eAlFSfSicmqZ9QXOwa2HJYFDWwjWIECp4swCUSmOQjY/Vlo5fGapPdswfSTlto1 X-Received: by 2002:a05:620a:4144:b0:785:af71:be3f with SMTP id k4-20020a05620a414400b00785af71be3fmr583420qko.16.1707408742854; Thu, 08 Feb 2024 08:12:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707408742; cv=pass; d=google.com; s=arc-20160816; b=pFvmBr27XONHNVl5AlJfcBcfifrPwfQqNe5VcqFqN8iSM362tHgJ1gnTn+rGNObGks fbJcLPmGxHJmAnqs3++NAiY26vPk2cAYGB9WD+rIY6fV8MWqhUomXWguyh6VKPyP9ytn Y1ra1/0G+a3RLTSQ0r2c9nSRyoD+2B3ToiTB7LiY8gMruhrj/ANJ5tqKElqDEvXOcSDJ JEEFnqOGHUxYmXoiMjBvrukqNWutIIUmwQbZKrd+6ZpQL3ZzvizDBVLl+nm2dnX9w0vp 8vfHRThWnvjT6Rl1xEFRAlxTfq8I6HA4jtq1ZVP5GYeIMpqHwO23qB/mek5fEGVn3lR4 qGKg== 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=r7dYKKpjSbNzyLMoqiBagtQ1UbDE2BU0ecOQOmIBJIo=; fh=wzRQz+saGoHuXiGs2CmfQ6Y0+vU0W24gRhYico6HwO4=; b=TlHwpvQNDujp1A0uvTkZuK+0oLck279m1t/ACErou/oDeJ3Fuzm3V1RwDhN+NX+ZKP tk6sg5IrCu1krDvKomz6jYcOpccmyan94mfEtH0PhVujmPJqEDOBq8F9B0vQgeC0Mo4x JzRejkD/AbOro/RBdfNvykOheDq+FF7TJITxEFHp7HimqjETD1TXp+BplR4MzSr6axAY uJphLos/Zv8JgZreHpOzyisuLm5gCJQx51/yxrDfS1uY1BDq5bEC2c1VzmJXBQS3TOsz kaHopIn2z7fNovfyGA+d6CvWJ5+pjSJu2+8fyzeQra0IHgtyBt6GTQEmalcVktA90KCV LF3w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CKrepQkQ; 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-58331-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58331-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=2; AJvYcCX2NQ45csIAT1KCZ+oyk5ThbDhgqjRuhW83qEk3igk+5XGN2Ma53BmGBSn8EUbpns/39k0+Un6L11vMMOM7ETQ/T2DMuA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id vr14-20020a05620a55ae00b007853ec6951esi273666qkn.477.2024.02.08.08.12.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 08:12:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58331-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CKrepQkQ; 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-58331-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58331-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 BEF9A1C213D6 for ; Thu, 8 Feb 2024 16:11:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 21737823D2; Thu, 8 Feb 2024 16:10:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CKrepQkQ" 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 9E1597EF14 for ; Thu, 8 Feb 2024 16:10:34 +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=1707408636; cv=none; b=ozQy4NZ/Oi82xhcd9FRJle3NbobPXiugqEnA7BmGXlOAPv6lWTtAPlg3cRV1r+r0Q0ayk1zO7BOfIsyrWHiC8ey8Sl1L/g5+rIZQgvJba3CF5GP2X+OCnNa/A5/kchuTzwBFPAAIXYt/Xkgrr/1rZHNElHfgz5OYyrCVSBoVXmo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707408636; c=relaxed/simple; bh=+t7pmKjtDdwuTE5+NchSpHdkWOnMrrwVoYXVY+E/eCY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FEPxQ1TNb8nz27pf6TtEwYJKwWKfk+Af3LFSR48p3x+QMNFjWTX3ZKfk4HKlcRGksJLhitN6E29BlmdC+K0elmGI2x5kn5U1uQqAcbG3A+/HFp6mYRf2IKLwfU5mKXF4sDTdiYRyaV4Pf+3J/ofE+IX/w94w+SS+EO/iJZz4yIU= 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=CKrepQkQ; 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=1707408633; 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=r7dYKKpjSbNzyLMoqiBagtQ1UbDE2BU0ecOQOmIBJIo=; b=CKrepQkQqiGrjIPT4vGsLn0fXZNlaPgKwW3BGV0pihhQ1ae3/rvUZ4t5UVK1h0oRMDrbRD tk+jln6IS9jC0SO++g+OgO3LkeOnrG3p60ROEav6iaoWx6CBeJYWf8pRe+sZNCvfy91OU1 JBT1+Z3K41bT9R3mjYNZiqvanZX1DWg= 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-85-rzlhX5SBM5mWrxnbKQl8iQ-1; Thu, 08 Feb 2024 11:10:27 -0500 X-MC-Unique: rzlhX5SBM5mWrxnbKQl8iQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 8FD8D381645B; Thu, 8 Feb 2024 16:10:27 +0000 (UTC) Received: from llong.com (unknown [10.22.32.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id 19877492BC6; Thu, 8 Feb 2024 16:10:27 +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 v5 4/4] workqueue: Bind unbound workqueue rescuer to wq_unbound_cpumask Date: Thu, 8 Feb 2024 11:10:14 -0500 Message-Id: <20240208161014.1084943-5-longman@redhat.com> In-Reply-To: <20240208161014.1084943-1-longman@redhat.com> References: <20240208161014.1084943-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.9 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790347829510389028 X-GMAIL-MSGID: 1790347829510389028 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 8df27c496b63..ca53e1144f0a 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -5302,7 +5302,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);