Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1659463rwr; Thu, 20 Apr 2023 19:51:57 -0700 (PDT) X-Google-Smtp-Source: AKy350aFOEdLQ1QYW4YmytTnqzLZm6BD32VjihRMLC6Hr+cPzwwvME5KxtMMImWhaZnLv1j9odjP X-Received: by 2002:a17:902:d48c:b0:1a3:c8c2:c322 with SMTP id c12-20020a170902d48c00b001a3c8c2c322mr4622482plg.29.1682045516886; Thu, 20 Apr 2023 19:51:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682045516; cv=none; d=google.com; s=arc-20160816; b=c5r0D1n0yMUIwtzLX5LQe8hCdxnel2yrjQ4688r05QwqTd2ejHPvyZ6HV4ozlDsF70 Wv0vW2a9NBGJmB0MFqlKbUrZxnFaFC21apwqkMo/vdKIDhwZtVOwoKwCuCAzNiuyQ9fy lEkNCuYtM7daOD56XXH9ZctL4pxzb4xshOM5RqUZcxACAMcBQNIwfhbjNUwxixXqhgly QgM4Co+P761YQBYmywXpgt8ftkhth39GAGjFuA7FKQxFFMDHGgVXhc3+Ui+KvQ18a6ND sLmWoMThacJHkZvXr2XP8Ye17K0D9jirRpynpw6lPww5m9PAkwxgLwZZxOkMdU9gaIO7 XkrQ== 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=34/Qii7FhGNnTA9R8bpTQlpj4RZtJcqmBQ/JN/Zhs64=; b=iOfdHIeNDHZaLBFe7je5iJPtPLS3/sn87XnnLewj+kaeM1K6iooMRgCuPjOK95WYo0 tGdE7jNUvDNqEn+JZq0z69/5A1g0/BtFclX1SK7b9v1hWn0p2HTLZlofVqsf+GF6zed0 ++aBFspSokSo8TfYi8MHVE7EzpuLQe1Z62tZz3nNmFuW2MHJ41sESzgXleXdxCSWtYMB Ul+/ZeETMZmWowCa6bZF4tJJMfl5A3qt2c9MWDayXlZRQ7VS7aVbtBuLZaToXcSWtYEK +wmnN66X6So5ldhpa+kqwGFq8x3n7eeB2rWHIMbC51Gxl4ccNTFtKF0RwnIBTkjbJdE3 jXBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=rloF2mVA; 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 w13-20020a170902e88d00b001a687bb33f5si3698111plg.434.2023.04.20.19.51.44; Thu, 20 Apr 2023 19:51:56 -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=rloF2mVA; 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 S233777AbjDUCvT (ORCPT + 99 others); Thu, 20 Apr 2023 22:51:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233674AbjDUCvL (ORCPT ); Thu, 20 Apr 2023 22:51:11 -0400 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBF9A72B6; Thu, 20 Apr 2023 19:51:02 -0700 (PDT) Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-63b5c48ea09so1600864b3a.1; 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=MX1FnsfEI8JOCDxvS0Lggm7r6at/QHp2e1f1jZy8dXeorr9RX3H5CZp2+Dd9wBmRY5 Tm9/3tjfi+P5yYvujjIIbGBSIfuaMJnrArXkl/9INbnoVmCrt+tuKawluCxZZgGiIytc ypgzp/jQ9BeWGVJjD2S8EJhPPgtRHWVKbyzC8oBgSjSjEsDIsobaDlQhX+mgTWwBU5gk AFCLnVnzo2wzTR5IkmJD2bWzOZjxYn7wnZO/alAm8iBJCPgHjomQrcSO2TT0t02DXmV3 U47arc9tHdQFV1a4qtvznJfOKuqCAX4fEqNI8zu5PAAMrlza5fMzP0CmmX+8uJbnMWb+ 1T1Q== X-Gm-Message-State: AAQBX9dWFeRt+ljUfUyattLGMLiD3yNkevskQfN/toYMIfrjjZlxIGQ7 07Gq616o+QrvNPK0mM0FjCE= 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) Sender: Tejun Heo 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 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: 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 --- 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); -- 2.40.0