Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1660080rwr; Thu, 20 Apr 2023 19:52:48 -0700 (PDT) X-Google-Smtp-Source: AKy350YyAFUdptYhsfXHCQPYa1kZjwoBoDeaOFY/RjgUkYBrVFleSe3m14Gpwdhq1xCV++g52VOH X-Received: by 2002:a17:903:22c9:b0:1a6:4541:73c with SMTP id y9-20020a17090322c900b001a64541073cmr4879379plg.33.1682045567809; Thu, 20 Apr 2023 19:52:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682045567; cv=none; d=google.com; s=arc-20160816; b=HjQTOcpiAVZf/xPZQr3lQJGos2fikEYDztxknnO4K4FHcxzC0i1XilrNHETX1D8gCA sbC6hmAKgC0DOl/M4tygKDlIahYraRuGaxGYXrnB7pfM6AFDDzT/SVsaul8aAfwSYA1r ZgrJ9LqWyyJoT+NKmUFmuX9F8Vh7ASpdGyq5jT4ojq1h3BNIeUAkPBoSVg9Y+HHWlhoO bgUNfyTS+24F0mHKHWPvvWUswQnZ9aWIDV+ZYlUzCAr/Gs1NJiiwtjSLYxe3QwGYt7bn g8doawVA7TSfwHHA9PbkTGT8O6aNL4hpUjeK1QpwuVe2SvqL48QXCTF/PYXgYBbL9naY qRhA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=qNxWNsNkiW6dC2MPWOAlJ0DZEAiQsjxz/0ttEihBSFM=; b=yz5DyVjdXjwAyYLLi1tFwrnZVqkNMVtgKySr6kYLCcEGfvm1zwGxcQZs9JpSwzgW1n BWU1igxjzscb6UDlR/B8bBY/EV3ttgJXl9lrMl2hadpGVvy1WZMdWujM0TFWcQH4wgdg Tr7GRc2JurdE6v4vZxap0CMvOXmQEIjCozx5EhtdbIJWjiyxrpbd0B92rxoMQl83KS+S HIIa8YH0KarhOf8CsWCYkrNkMSNE9QDLIsZOjehJGwZE10eCsL3BjsUMQ/EglGgh6GP2 6yD8EmRxSp0RxAAb1Fyz7nYLz0F9FMHjduJE0xFONt++t+lU2+Wg9pcHcCRScWfyO6hD NpjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=mk8IgkQX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g15-20020a17090a3c8f00b002478d3604aasi3546822pjc.110.2023.04.20.19.52.36; Thu, 20 Apr 2023 19:52:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=mk8IgkQX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233954AbjDUCv5 (ORCPT + 99 others); Thu, 20 Apr 2023 22:51:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233765AbjDUCvR (ORCPT ); Thu, 20 Apr 2023 22:51:17 -0400 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB9AF7681 for ; Thu, 20 Apr 2023 19:51:15 -0700 (PDT) Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1a677dffb37so16334345ad.2 for ; Thu, 20 Apr 2023 19:51:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682045475; x=1684637475; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=qNxWNsNkiW6dC2MPWOAlJ0DZEAiQsjxz/0ttEihBSFM=; b=mk8IgkQXApz1FaufEiZfvC15wekz3UMd4Nl3Mr2cB9VJ/qBecpD1Bpr+n5KabJWu6G cmrHDbaznnLLk6ScZLN/q0opj00Kkp0tiX9FxxwSaVFu7nOGXMg2aPYHHok0gmMBXZK7 /1D4K/5afm3qRf9oUoK5OWZlDM0Vk7G1EyqSMAdhIPMPDFXpHItCtLA9Jd0bSBnlCrFV ghN652WLJTDjKK1GjX7VkJEIbiKB887uO9up9rx/DVXUrW4BRmBBWfFAUVftAvZ/9Jgw LGYOmv7h/LLENqWfbT5qujjToajeflNFPmZN8wmNF4xr1voiRREWbW8VVrgPUq5UMcBI 2Spg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682045475; x=1684637475; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=qNxWNsNkiW6dC2MPWOAlJ0DZEAiQsjxz/0ttEihBSFM=; b=M1oY0hE6Bbe6KBnQzfjBCLCOVi6wpU4HngRqnRTJXHAh22JQ4fJKIYOfj20fsjPWYN /7Uk+siQ7XxA0AQfsgvzU+VzkKl0eZKd6Dg7QVGJO04G7mgBFfmQyDew0uebqVMrPplr CN+NC6eRWaPMcG4/pkWv6qNcnbWPtWlOtFb3xw2RNBhEOSWaQFNTzAsTO4d60tdfMVG7 Zlh4Cj+kRojSEF2DQT25x4rJjCobMLV9gRrkuwi2cDNUUK9sjSRT7qXlFcF2tic8tY9k SrF2buYHjE6j8yc3sLTca+fxJOzeESufla1TreDSmnQWzeXq7UFf6BTPwcXhbpJ/Y9SN woBQ== X-Gm-Message-State: AAQBX9fWrDEMk3gqUjkzNIdSvNgAxEjRhMayQOl7Zs7wVRHPFXXTz0Mm YmSyUnFI3Zae3xEfEuaYxBE= X-Received: by 2002:a17:902:ecc4:b0:1a6:9f85:9437 with SMTP id a4-20020a170902ecc400b001a69f859437mr4245549plh.67.1682045475058; Thu, 20 Apr 2023 19:51:15 -0700 (PDT) Received: from localhost (2603-800c-1a02-1bae-a7fa-157f-969a-4cde.res6.spectrum.com. [2603:800c:1a02:1bae:a7fa:157f:969a:4cde]) by smtp.gmail.com with ESMTPSA id x9-20020a1709029a4900b001a6388ce38bsm1724167plv.240.2023.04.20.19.51.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Apr 2023 19:51:14 -0700 (PDT) Sender: Tejun Heo From: Tejun Heo To: jiangshanlai@gmail.com Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, Tejun Heo , Fei Li , Greg Kroah-Hartman Subject: [PATCH 13/22] virt: acrn: Use alloc_ordered_workqueue() to create ordered workqueues Date: Thu, 20 Apr 2023 16:50:37 -1000 Message-Id: <20230421025046.4008499-14-tj@kernel.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230421025046.4008499-1-tj@kernel.org> References: <20230421025046.4008499-1-tj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org BACKGROUND ========== When multiple work items are queued to a workqueue, their execution order doesn't match the queueing order. They may get executed in any order and simultaneously. When fully serialized execution - one by one in the queueing order - is needed, an ordered workqueue should be used which can be created with alloc_ordered_workqueue(). However, alloc_ordered_workqueue() was a later addition. Before it, an ordered workqueue could be obtained by creating an UNBOUND workqueue with @max_active==1. This originally was an implementation side-effect which was broken by 4c16bd327c74 ("workqueue: restore WQ_UNBOUND/max_active==1 to be ordered"). Because there were users that depended on the ordered execution, 5c0338c68706 ("workqueue: restore WQ_UNBOUND/max_active==1 to be ordered") made workqueue allocation path to implicitly promote UNBOUND workqueues w/ @max_active==1 to ordered workqueues. While this has worked okay, overloading the UNBOUND allocation interface this way creates other issues. It's difficult to tell whether a given workqueue actually needs to be ordered and users that legitimately want a min concurrency level wq unexpectedly gets an ordered one instead. With planned UNBOUND workqueue updates to improve execution locality and more prevalence of chiplet designs which can benefit from such improvements, this isn't a state we wanna be in forever. This patch series audits all callsites that create an UNBOUND workqueue w/ @max_active==1 and converts them to alloc_ordered_workqueue() as necessary. WHAT TO LOOK FOR ================ The conversions are from alloc_workqueue(WQ_UNBOUND | flags, 1, args..) to alloc_ordered_workqueue(flags, args...) which don't cause any functional changes. If you know that fully ordered execution is not ncessary, please let me know. I'll drop the conversion and instead add a comment noting the fact to reduce confusion while conversion is in progress. If you aren't fully sure, it's completely fine to let the conversion through. The behavior will stay exactly the same and we can always reconsider later. As there are follow-up workqueue core changes, I'd really appreciate if the patch can be routed through the workqueue tree w/ your acks. Thanks. Signed-off-by: Tejun Heo Cc: Fei Li Cc: Greg Kroah-Hartman --- drivers/virt/acrn/ioreq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/virt/acrn/ioreq.c b/drivers/virt/acrn/ioreq.c index d75ab3f66da4..cecdc1c13af7 100644 --- a/drivers/virt/acrn/ioreq.c +++ b/drivers/virt/acrn/ioreq.c @@ -576,8 +576,8 @@ static void ioreq_resume(void) int acrn_ioreq_intr_setup(void) { acrn_setup_intr_handler(ioreq_intr_handler); - ioreq_wq = alloc_workqueue("ioreq_wq", - WQ_HIGHPRI | WQ_MEM_RECLAIM | WQ_UNBOUND, 1); + ioreq_wq = alloc_ordered_workqueue("ioreq_wq", + WQ_HIGHPRI | WQ_MEM_RECLAIM); if (!ioreq_wq) { dev_err(acrn_dev.this_device, "Failed to alloc workqueue!\n"); acrn_remove_intr_handler(); -- 2.40.0