From patchwork Fri Apr 21 02:50:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 13219420 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4E6C1C77B73 for ; Fri, 21 Apr 2023 02:52:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CS+NkSaywBWB72U7RdYVHTAVryrqhYwgTw8/bclnRq4=; b=OaHx0EedTw8EwK ImA/mC2ploBqKYsGdryLqAQsMuhnOzPKCXupDDORPGPp7Kvq2LvAhJrwZxgrXb9HHIk+rLAekL8cV sx8U9HPOtD+tWtr9/0FdHIETRtxkwp6zgcSU4gBLr2xoVVAB+uYHL0kYFyzxpxsulfOxi0A37DX5j 9/d9YKc8cnSP2iSycgvhTpGFYxCenagpnaAaieQ0jMzTAGy6/GvPGXiRUUbQoFIETAzPlXBiQKJhV 5zkFhNxUNQOIgJroqevJnBpMR/Ewxp6jJxlZU3EAQ9kF4eQ+W+Rv4g8avtN7HY86aXpixkFsViv5c 5TPC5kjlRaFGFRqL2RBg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1ppgrb-009Tj7-07; Fri, 21 Apr 2023 02:51:07 +0000 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1ppgrX-009Ti6-2C for linux-arm-kernel@lists.infradead.org; Fri, 21 Apr 2023 02:51:05 +0000 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-63b5fca48bcso1608198b3a.0 for ; Thu, 20 Apr 2023 19:51:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682045462; x=1684637462; 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=34/Qii7FhGNnTA9R8bpTQlpj4RZtJcqmBQ/JN/Zhs64=; b=rloF2mVAYBrDqM/6XuYQZv7gDt2EIV8lhLGgEEJ3aoXgc0Wvlus+anMCNBx6PUd0+k HQ/kOTFvj3/q6z85JtIlfUU1j5z/ZAJb1YnJW+JewjxZYuQ9kGRTHS0ZaV4/9UqSTjKI QLjvN+BgQzSGhKEztoAQ1YtgyBnLS5Wv1sOGtn0cPnlrfmm809JWs4QNV1B/DookEJq6 T9ZRYKVAVUELaRb+Bcp/Rx2wIDO8bd210XgXcNEYG9OV/dX2QvYlUyALg25HkejBfB3w bsGYcbipu6KkSio+dJCNrD0lXpUWNTwNW6g5iTJ4+ar3ZmOFXg72Yqbx5uUpF3uQrVEH vY9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682045462; x=1684637462; 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=34/Qii7FhGNnTA9R8bpTQlpj4RZtJcqmBQ/JN/Zhs64=; b=HyjJxBw0GE1g/HZqcgUVFIv8UBBRFDXcjKiuXcpm4RZxcaj1j+pBBwlAMymCbzN7XV otTNc8QqEm3xl8cgvfn4ShG3QVf5Gx13fb/2OmBE7mxg4n1dPIgIM0faYOgJ4VI22wjn aq1xYS7g9qrK3Iwagl7nXEBQVqRWLWjyp6iIJ93DZvmvWXGrolziz8a1+5nO+T0ufBN7 lo7Xuo+EwY6TH00cm9V2y4oTU0jjmztttuLLA05OfsSSLTbFE1WpwhAbMtSojl/fDA6v g8pOXDSAhJY2/Eilh9ZPgV65kWmaCY8oi3NLU5RkVd1flil9F8iG2RuQnwGsCWtxJ35M vDuw== X-Gm-Message-State: AAQBX9c6dBrMzLGqaQj8JAzYgVZwwrHEsS4Sv4+uZ9nOnjovap6hU3yv 6wFuVS/KeDMcib2YUAgulog= X-Google-Smtp-Source: AKy350Yn90TexflSL5xc7ZrsTa6Anc/kqV6Sh8SIc6wqmavXZKkrA+mOseiosddYVVGPcr8lUAoyRg== X-Received: by 2002:a05:6a21:6817:b0:f0:164b:fa5d with SMTP id wr23-20020a056a21681700b000f0164bfa5dmr4235235pzb.15.1682045462096; Thu, 20 Apr 2023 19:51:02 -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 z12-20020a63c04c000000b0050f74d435e6sm1676172pgi.18.2023.04.20.19.51.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Apr 2023 19:51:01 -0700 (PDT) From: Tejun Heo To: jiangshanlai@gmail.com Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, Tejun Heo , Sunil Goutham , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org Subject: [PATCH 06/22] net: thunderx: Use alloc_ordered_workqueue() to create ordered workqueues Date: Thu, 20 Apr 2023 16:50:30 -1000 Message-Id: <20230421025046.4008499-7-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230420_195103_725264_96584C76 X-CRM114-Status: GOOD ( 18.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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: Sunil Goutham Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: linux-arm-kernel@lists.infradead.org Cc: netdev@vger.kernel.org Reviewed-by: Sunil Goutham Acked-by: Jakub Kicinski --- drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c index 7eb2ddbe9bad..a317feb8decb 100644 --- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c +++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c @@ -1126,8 +1126,7 @@ static int bgx_lmac_enable(struct bgx *bgx, u8 lmacid) } poll: - lmac->check_link = alloc_workqueue("check_link", WQ_UNBOUND | - WQ_MEM_RECLAIM, 1); + lmac->check_link = alloc_ordered_workqueue("check_link", WQ_MEM_RECLAIM); if (!lmac->check_link) return -ENOMEM; INIT_DELAYED_WORK(&lmac->dwork, bgx_poll_for_link);