Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp541662rdg; Tue, 10 Oct 2023 19:50:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFKZ2dJIw+kDz/QffDIy3VoYlIcIPuoTSHWBuEyG5DJxbzffBTmY2L5OqOb2CAPNbhhFb6D X-Received: by 2002:a17:903:32c1:b0:1c3:ae56:4594 with SMTP id i1-20020a17090332c100b001c3ae564594mr20375464plr.49.1696992618721; Tue, 10 Oct 2023 19:50:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696992618; cv=none; d=google.com; s=arc-20160816; b=EFxM8j5a5BfF4jlg8MCobWs1gIPtPt3MSQrFhzp5VqV3m/GLnvdKO3fiL5vbERxVuN H1WEuMdlvmMPONomHU6fRyd5eVsv6zhWzus6cnkBmoH7N4bKvjK1FZg8ss6RH4QnDDwY XabwGZXGXMOaOmPUsQab7PCacQg3te8f5u8wPAk6hlQtPQyftbZIA9it8UbtNdI/FaaO 6f7mJVwpG/NqrJyuEHNylYtXfxLb4ISgxh2LG0+m4nM0PKdbhUnQcYqdWwndixsziarE aPtxWmyuzqJ32OgL3lCR03YXs7Iqn4L1O0sjGxLFrnWT8KFQIlmMVHMUoWvux2VdrR08 aqQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=LKaaWjcSib4OYci1/rf1zY/JSkdOEw69OTsSHXb56OQ=; fh=oL49VTH3pOOlBZiIYfUA6Ve2pI5KXYe487w6HvKCIx8=; b=JonF8Tok9Lh8uF1dno/dpzqKm3sdfTm+7zLJQnhUjExprfiatOEhE8O0lClTNvPGUq chx5KKf0RH8RWs7/KudA/SlEyVhM8d22ZBFdGMH5Xf6fXRc9OwmAcWo/ZIbiaL9FVbw1 8P2a8cgJCyYSAbRgcmqd7gV7goZPCAFl8RyXZaleRK2Og2nzw7/Hn8gWIcCpMsvPVB9U CK19yYSihaD1H24uSFz3g3VhF4Wb9px4bFFiKDzqV7MGHPJf94uNySMXehjCmrE74R0U zHSpcb+WjalcwZNWLfzLn0rXCYkpwAaTppsvzTqYFXuswxQYg3oDgNYGTUEjX42rmK9M Nqgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SBbgmEGv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id ay6-20020a1709028b8600b001c383a64ebesi12445547plb.319.2023.10.10.19.50.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 19:50:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SBbgmEGv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id CC56A80F66A0; Tue, 10 Oct 2023 19:50:15 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344862AbjJKCuH (ORCPT + 99 others); Tue, 10 Oct 2023 22:50:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344822AbjJKCuG (ORCPT ); Tue, 10 Oct 2023 22:50:06 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 632AF8E for ; Tue, 10 Oct 2023 19:49:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696992558; 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; bh=LKaaWjcSib4OYci1/rf1zY/JSkdOEw69OTsSHXb56OQ=; b=SBbgmEGvQsnewnssLlN8AKGlI0lHsRKcRqQv9bw7FXsBTSiwaDBmDCURUH/Qkg0IupVHqu QMmzeYOqE2gACRpR+G3MU6HxbxMGVmwvFes260E3Bnp4jfeh05+qEu3y5Uj5LXKN0P10FL zjAHjaRurPUZsvx3eWuBOjJChEKSCaw= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-198-yZz7x6TqN9CQ3sL-S9fUZA-1; Tue, 10 Oct 2023 22:49:15 -0400 X-MC-Unique: yZz7x6TqN9CQ3sL-S9fUZA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B98263C0F662; Wed, 11 Oct 2023 02:49:14 +0000 (UTC) Received: from llong.com (unknown [10.22.9.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 731BB10EE859; Wed, 11 Oct 2023 02:49:14 +0000 (UTC) From: Waiman Long To: Tejun Heo , Lai Jiangshan Cc: linux-kernel@vger.kernel.org, Waiman Long Subject: [PATCH] workqueue: Override implicit ordered attribute in workqueue_apply_unbound_cpumask() Date: Tue, 10 Oct 2023 22:48:42 -0400 Message-Id: <20231011024842.3348767-1-longman@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 10 Oct 2023 19:50:16 -0700 (PDT) X-Spam-Level: ** Commit 5c0338c68706 ("workqueue: restore WQ_UNBOUND/max_active==1 to be ordered") enabled implicit ordered attribute to be added to WQ_UNBOUND workqueues with max_active of 1. This prevented the changing of attributes to these workqueues leading to fix commit 0a94efb5acbb ("workqueue: implicit ordered attribute should be overridable"). However, workqueue_apply_unbound_cpumask() was not updated at that time. So sysfs changes to wq_unbound_cpumask has no effect on WQ_UNBOUND workqueues with implicit ordered attribute. Since not all WQ_UNBOUND workqueues are visible on sysfs, we are not able to make all the necessary cpumask changes even if we iterates all the workqueue cpumasks in sysfs and changing them one by one. Fix this problem by applying the corresponding change made to apply_workqueue_attrs_locked() in the fix commit to workqueue_apply_unbound_cpumask(). Fixes: 5c0338c68706 ("workqueue: restore WQ_UNBOUND/max_active==1 to be ordered") Signed-off-by: Waiman Long --- kernel/workqueue.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index d141bd8eb2b7..19d403aa41b0 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -5785,9 +5785,13 @@ static int workqueue_apply_unbound_cpumask(const cpumask_var_t unbound_cpumask) list_for_each_entry(wq, &workqueues, list) { if (!(wq->flags & WQ_UNBOUND)) continue; + /* creating multiple pwqs breaks ordering guarantee */ - if (wq->flags & __WQ_ORDERED) - continue; + if (!list_empty(&wq->pwqs)) { + if (wq->flags & __WQ_ORDERED_EXPLICIT) + continue; + wq->flags &= ~__WQ_ORDERED; + } ctx = apply_wqattrs_prepare(wq, wq->unbound_attrs, unbound_cpumask); if (IS_ERR(ctx)) { -- 2.39.3