From patchwork Fri Apr 21 02:50:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 13219404 X-Patchwork-Delegate: kvalo@adurom.com 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04CC1C7618E for ; Fri, 21 Apr 2023 02:51:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233710AbjDUCvS (ORCPT ); Thu, 20 Apr 2023 22:51:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233728AbjDUCvN (ORCPT ); Thu, 20 Apr 2023 22:51:13 -0400 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32C8E7692; Thu, 20 Apr 2023 19:51:07 -0700 (PDT) Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-51f597c975fso1744062a12.0; Thu, 20 Apr 2023 19:51:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682045466; x=1684637466; 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=2OMa4H5B7cQ31o0iO4EHjR7g/GmtbQFAxNrqAS+m3rA=; b=ed6rzYNuCkWaolQBt1qf/IaUHcwfXxuC5SbNdlIaF08ctYw+9Z4paHRTmDAW4FtsAi N8RRJRPFzktovjo7fpVlYA/p6AaCY2AgPdiXX26Trrodn72gYdhzSan2w7mBlOMVDpUJ Tr6WoSC7BQ3lAtWHPpOrAcdMolmjkqZdiwhEkvWcfAyx5mxkKHBVpV29sanYgaENW+iB +qOzsE1CiFbnqXwPWFDS3+KT81w7mLwRl1srwhsJW8DNKiJeKXelf8/Y8MuXTaCSEATO 1sp3CO6Lcx7iYnFy96NZbqYOjwpuPOb4qGltDAHHFWPwW5qvBsQYFUJnI1/aDJL9yayh unVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682045466; x=1684637466; 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=2OMa4H5B7cQ31o0iO4EHjR7g/GmtbQFAxNrqAS+m3rA=; b=GEMcwc5ZnkdVqUCwhYmulVUNujuN8xZVGiU06LHJmc9GUc0B2oBYbs5xtgL0gm4QcS U2NIO7O3ZHRA+xFDq0tNwBk8s3xfa0i5mVjTQ82QaKmN53XOQRXJ3/8mxCLAItSwCBuQ 16v3jIuHc142Kos3kR7s0a8V/f6Errf2ouevAflZcqBDgMqTI/6lEjBCCnZtWxu4GDph 34hU23Xkn9ZQOeN0vFy1pNZXmSPoVgWz7jfThsPOAlLaD5/pUe+3nzL7bGwA/UZesiRs PPdiZMs9+rKmVSq2Vh+WIxBHGTfhYOzu68Tl/Rp8TlplvQRcfImLSixbyV3X8GUDieec tTAw== X-Gm-Message-State: AAQBX9cNaWqTcwL6PVXsLpnebGR7mDb47aPDAk8QXjYZE/29ysL6CF/k llvAAKU0GPvb2RQMYf0RRDD8Gs1HXuU= X-Google-Smtp-Source: AKy350YTA23CBRwccIcJyFzB9Mc/n2eh72ar0ILix9ZmPuI+GmvdpgvBas6cCJHx++m1HW0Azj8EOg== X-Received: by 2002:a17:90a:ea09:b0:23f:7d05:8762 with SMTP id w9-20020a17090aea0900b0023f7d058762mr3389480pjy.23.1682045465785; Thu, 20 Apr 2023 19:51:05 -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 jj2-20020a170903048200b001a6d08dc847sm1734028plb.173.2023.04.20.19.51.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Apr 2023 19:51:05 -0700 (PDT) Sender: Tejun Heo From: Tejun Heo To: jiangshanlai@gmail.com Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, Tejun Heo , Kalle Valo , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-wireless@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 08/22] wifi: ath10/11/12k: Use alloc_ordered_workqueue() to create ordered workqueues Date: Thu, 20 Apr 2023 16:50:32 -1000 Message-Id: <20230421025046.4008499-9-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 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@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: Kalle Valo Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org --- drivers/net/wireless/ath/ath10k/qmi.c | 3 +-- drivers/net/wireless/ath/ath11k/qmi.c | 3 +-- drivers/net/wireless/ath/ath12k/qmi.c | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/qmi.c b/drivers/net/wireless/ath/ath10k/qmi.c index 90f457b8e1fe..ebedef8767cd 100644 --- a/drivers/net/wireless/ath/ath10k/qmi.c +++ b/drivers/net/wireless/ath/ath10k/qmi.c @@ -1082,8 +1082,7 @@ int ath10k_qmi_init(struct ath10k *ar, u32 msa_size) if (ret) goto err; - qmi->event_wq = alloc_workqueue("ath10k_qmi_driver_event", - WQ_UNBOUND, 1); + qmi->event_wq = alloc_ordered_workqueue("ath10k_qmi_driver_event", 0); if (!qmi->event_wq) { ath10k_err(ar, "failed to allocate workqueue\n"); ret = -EFAULT; diff --git a/drivers/net/wireless/ath/ath11k/qmi.c b/drivers/net/wireless/ath/ath11k/qmi.c index ab923e24b0a9..26b252e62909 100644 --- a/drivers/net/wireless/ath/ath11k/qmi.c +++ b/drivers/net/wireless/ath/ath11k/qmi.c @@ -3256,8 +3256,7 @@ int ath11k_qmi_init_service(struct ath11k_base *ab) return ret; } - ab->qmi.event_wq = alloc_workqueue("ath11k_qmi_driver_event", - WQ_UNBOUND, 1); + ab->qmi.event_wq = alloc_ordered_workqueue("ath11k_qmi_driver_event", 0); if (!ab->qmi.event_wq) { ath11k_err(ab, "failed to allocate workqueue\n"); return -EFAULT; diff --git a/drivers/net/wireless/ath/ath12k/qmi.c b/drivers/net/wireless/ath/ath12k/qmi.c index 979a63f2e2ab..471810877eed 100644 --- a/drivers/net/wireless/ath/ath12k/qmi.c +++ b/drivers/net/wireless/ath/ath12k/qmi.c @@ -3054,8 +3054,7 @@ int ath12k_qmi_init_service(struct ath12k_base *ab) return ret; } - ab->qmi.event_wq = alloc_workqueue("ath12k_qmi_driver_event", - WQ_UNBOUND, 1); + ab->qmi.event_wq = alloc_ordered_workqueue("ath12k_qmi_driver_event", 0); if (!ab->qmi.event_wq) { ath12k_err(ab, "failed to allocate workqueue\n"); return -EFAULT; From patchwork Fri Apr 21 02:50:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 13219405 X-Patchwork-Delegate: johannes@sipsolutions.net 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63B9CC77B73 for ; Fri, 21 Apr 2023 02:51:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233841AbjDUCvm (ORCPT ); Thu, 20 Apr 2023 22:51:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233729AbjDUCvN (ORCPT ); Thu, 20 Apr 2023 22:51:13 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B45576B8; Thu, 20 Apr 2023 19:51:08 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-63b4dfead1bso1584816b3a.3; Thu, 20 Apr 2023 19:51:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682045468; x=1684637468; 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=vXy2LlryeqFYuG6VIcWnTi0Y22Hml5WbUl7g3QZBsxI=; b=DNXPUdu3So6Ly099msBkeS7QG2IIR0hElah4MDZwf8MWR1gh2Qq/qQbimHClsh938b 823fOETKFYsI5gKPXdc5lvyzkHjWyvJxTZM7XPzbXB8kMGcGMUJpUgIL0LfhkKobISuC OA5UP91DpFYekIyJbBQshJbMEeWYiJhA0onfRS4M+Y8wioMvq6Cx+cres2NEdLWHpDdr 8A9XAwa0cIu9GLFDCoRmnhNGnjNQJTgvHNQAAR9V8t1ZQomU3z7aYsnBlQSuk+QFicie YA64dM6wNqV6F4c3hHdtw1bllG2Zwd0XCD3/VoVVN+drc4zNkIsTdTgQXJ03D1fM5dCf usPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682045468; x=1684637468; 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=vXy2LlryeqFYuG6VIcWnTi0Y22Hml5WbUl7g3QZBsxI=; b=a2+60fq2LfuQvHrJsd3e9WDOhW6wLAdgABo4UVaboNY0IwZvWxZukHtXkgrFWxVbtr oTFgk/JPA3/MbWLEHkxW/YG17dc8biq6IohSRO79BwWqe5CuetfYZkexscuNnX2IIPXx qrpvBJgWx8IrN5Avzy4h2dyMQ65nX0CsKKQQ5MJtMhIL/+lF9pcV7uBMRA1dbqUGvtZX BCGgTopsVSw8wflk0DmP1F+6DPvN+Rb//+8foCORlDbJsyqTtSUZkNPgjmUeqVfPwjjn qI0jHWQyM49UBodvHaD1GyIxLlnDbQcZ7SKQJ7q0Zw9HoKRXkOxwP2cnKYvzg/lorDJJ cHPQ== X-Gm-Message-State: AAQBX9dXOgfv4ioUH96EZEcfyMrYwWIJ53j7ievMbYhnoqID7mnx1QOw /LZhndiZeaxDjjyoF40h8CU= X-Google-Smtp-Source: AKy350YiGBh1kzca9HUbkPPfun9iKHT605jECnArxYVlQeqJ+qB/AWk8NZ5gxhWAeNluLohvMkKHXw== X-Received: by 2002:a05:6a20:a1a0:b0:de:247e:d1fe with SMTP id r32-20020a056a20a1a000b000de247ed1femr3442160pzk.1.1682045467914; Thu, 20 Apr 2023 19:51:07 -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 o64-20020a62cd43000000b0063d642dcd12sm1972276pfg.16.2023.04.20.19.51.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Apr 2023 19:51:07 -0700 (PDT) Sender: Tejun Heo From: Tejun Heo To: jiangshanlai@gmail.com Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, Tejun Heo , Kalle Valo , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Gregory Greenman , Johannes Berg , Avraham Stern , Kees Cook , Mordechay Goodstein , "Haim, Dreyfuss" , linux-wireless@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 09/22] wifi: iwlwifi: Use alloc_ordered_workqueue() to create ordered workqueues Date: Thu, 20 Apr 2023 16:50:33 -1000 Message-Id: <20230421025046.4008499-10-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 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@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: Kalle Valo Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: Gregory Greenman Cc: Johannes Berg Cc: Avraham Stern Cc: Kees Cook Cc: Mordechay Goodstein Cc: "Haim, Dreyfuss" Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org --- drivers/net/wireless/intel/iwlwifi/pcie/trans.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c index 0a9af1ad1f20..cd17b601b172 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c @@ -3576,8 +3576,8 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev, init_waitqueue_head(&trans_pcie->fw_reset_waitq); init_waitqueue_head(&trans_pcie->imr_waitq); - trans_pcie->rba.alloc_wq = alloc_workqueue("rb_allocator", - WQ_HIGHPRI | WQ_UNBOUND, 1); + trans_pcie->rba.alloc_wq = alloc_ordered_workqueue("rb_allocator", + WQ_HIGHPRI); if (!trans_pcie->rba.alloc_wq) { ret = -ENOMEM; goto out_free_trans; From patchwork Fri Apr 21 02:50:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 13219406 X-Patchwork-Delegate: kvalo@adurom.com 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35F79C77B76 for ; Fri, 21 Apr 2023 02:51:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233745AbjDUCvs (ORCPT ); Thu, 20 Apr 2023 22:51:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233679AbjDUCvO (ORCPT ); Thu, 20 Apr 2023 22:51:14 -0400 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D015E75; Thu, 20 Apr 2023 19:51:10 -0700 (PDT) Received: by mail-pg1-x529.google.com with SMTP id 41be03b00d2f7-51f6461af24so1344912a12.2; Thu, 20 Apr 2023 19:51:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682045470; x=1684637470; 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=c3gqGXUpc3KYe5z+gS2RcAbeFyLxMU5SRbpmpf891/c=; b=Yck4T+vntovmXZEumLESoURloMmWy6Y7UkKFCg9sz/cHM75rWCU5t9hODeh8oadjov CKPRpKyymA3SnLOPT/xZuRVKtanfT1Mtz+/EtVwVlDldI92ZgCDt4h9bQ9jMVuCxvVp+ tBldXE72UozeUum3r1fb2CUH8xBtBxtoDX5o10FKWTPr9IKmmHmrYDj4otq73vcOrsqf tK3Q6CrE+2cZ9XMOKIz0+A6PRUhD25OgdNVNU2MZbmN8Iwdy9VouZV3PlTyRSmkJWbnv hod3xG7N5Qx4EZ+5j3ASi8ZwaA26ZWVTVyfG2PI1T4E/ceijMpoHnleheZE+SMw1Rfe6 4tvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682045470; x=1684637470; 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=c3gqGXUpc3KYe5z+gS2RcAbeFyLxMU5SRbpmpf891/c=; b=DITKoWvmLtWLrTsFpPHtNmHHPyxD3KjhfGxj2qK3geRgm37T9gdCizw4mpFP17fcDL 2AVLpX0yeVtDDtkFn5qQS91bgbN1rP2f8txX5+wKOFL5p+ZwEYVDP4i1BZKJrv+NXRdd sfPf1SixWRTNvXJS+lzrtSmlnjGnrCFR0U+ptVc698BjMzx7AGrFAS7ZjWI2xq7eBWSx IfBALChL4zeY/y6A6Zb6C3NLCaT9V+Yutw/85ej4DsmLcHgnexngfmsJ5eX06AvCqDx0 lIAR2VICup0hmt1lv15DZ9viIBNbF3xqg/6EPngyNdK8he2/P5dl5Qz3b0m8fdPUlUcv ojkw== X-Gm-Message-State: AAQBX9dxJmjpxNTvtBtJc+6nN1ta4uDzzEsqemoARXyGUfvkXARqxRNw n9BRZwn+v5wk/a3uQ67VE06BCsQWygI= X-Google-Smtp-Source: AKy350Z3JhT4mTro1Ifrc8y8dKWqiYXcJkAZQoBipxpDZ0HYwLQGZ1riYwHUljvTAJgiORv6QSmR1g== X-Received: by 2002:a17:902:d2ca:b0:1a2:71c1:c30f with SMTP id n10-20020a170902d2ca00b001a271c1c30fmr4160649plc.7.1682045469766; Thu, 20 Apr 2023 19:51:09 -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 j8-20020a170902690800b001a1b66af22fsm1741810plk.62.2023.04.20.19.51.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Apr 2023 19:51:09 -0700 (PDT) Sender: Tejun Heo From: Tejun Heo To: jiangshanlai@gmail.com Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, Tejun Heo , Amitkumar Karwar , Ganapathi Bhat , Sharvari Harisangam , Xinming Hu , Kalle Valo , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-wireless@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 10/22] wifi: mwifiex: Use alloc_ordered_workqueue() to create ordered workqueues Date: Thu, 20 Apr 2023 16:50:34 -1000 Message-Id: <20230421025046.4008499-11-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 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@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: Amitkumar Karwar Cc: Ganapathi Bhat Cc: Sharvari Harisangam Cc: Xinming Hu Cc: Kalle Valo Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org Reviewed-by: Brian Norris --- .../net/wireless/marvell/mwifiex/cfg80211.c | 13 +++++------ drivers/net/wireless/marvell/mwifiex/main.c | 22 +++++++++---------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c index bcd564dc3554..5a7be57ed78a 100644 --- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c +++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c @@ -3124,10 +3124,9 @@ struct wireless_dev *mwifiex_add_virtual_intf(struct wiphy *wiphy, SET_NETDEV_DEV(dev, adapter->dev); - priv->dfs_cac_workqueue = alloc_workqueue("MWIFIEX_DFS_CAC%s", - WQ_HIGHPRI | - WQ_MEM_RECLAIM | - WQ_UNBOUND, 1, name); + priv->dfs_cac_workqueue = + alloc_ordered_workqueue("MWIFIEX_DFS_CAC%s", + WQ_HIGHPRI | WQ_MEM_RECLAIM, name); if (!priv->dfs_cac_workqueue) { mwifiex_dbg(adapter, ERROR, "cannot alloc DFS CAC queue\n"); ret = -ENOMEM; @@ -3136,9 +3135,9 @@ struct wireless_dev *mwifiex_add_virtual_intf(struct wiphy *wiphy, INIT_DELAYED_WORK(&priv->dfs_cac_work, mwifiex_dfs_cac_work_queue); - priv->dfs_chan_sw_workqueue = alloc_workqueue("MWIFIEX_DFS_CHSW%s", - WQ_HIGHPRI | WQ_UNBOUND | - WQ_MEM_RECLAIM, 1, name); + priv->dfs_chan_sw_workqueue = + alloc_ordered_workqueue("MWIFIEX_DFS_CHSW%s", + WQ_HIGHPRI | WQ_MEM_RECLAIM, name); if (!priv->dfs_chan_sw_workqueue) { mwifiex_dbg(adapter, ERROR, "cannot alloc DFS channel sw queue\n"); ret = -ENOMEM; diff --git a/drivers/net/wireless/marvell/mwifiex/main.c b/drivers/net/wireless/marvell/mwifiex/main.c index ea22a08e6c08..19a6107d115c 100644 --- a/drivers/net/wireless/marvell/mwifiex/main.c +++ b/drivers/net/wireless/marvell/mwifiex/main.c @@ -1546,18 +1546,17 @@ mwifiex_reinit_sw(struct mwifiex_adapter *adapter) adapter->rx_work_enabled = true; adapter->workqueue = - alloc_workqueue("MWIFIEX_WORK_QUEUE", - WQ_HIGHPRI | WQ_MEM_RECLAIM | WQ_UNBOUND, 1); + alloc_ordered_workqueue("MWIFIEX_WORK_QUEUE", + WQ_HIGHPRI | WQ_MEM_RECLAIM); if (!adapter->workqueue) goto err_kmalloc; INIT_WORK(&adapter->main_work, mwifiex_main_work_queue); if (adapter->rx_work_enabled) { - adapter->rx_workqueue = alloc_workqueue("MWIFIEX_RX_WORK_QUEUE", - WQ_HIGHPRI | - WQ_MEM_RECLAIM | - WQ_UNBOUND, 1); + adapter->rx_workqueue = + alloc_ordered_workqueue("MWIFIEX_RX_WORK_QUEUE", + WQ_HIGHPRI | WQ_MEM_RECLAIM); if (!adapter->rx_workqueue) goto err_kmalloc; INIT_WORK(&adapter->rx_work, mwifiex_rx_work_queue); @@ -1701,18 +1700,17 @@ mwifiex_add_card(void *card, struct completion *fw_done, adapter->rx_work_enabled = true; adapter->workqueue = - alloc_workqueue("MWIFIEX_WORK_QUEUE", - WQ_HIGHPRI | WQ_MEM_RECLAIM | WQ_UNBOUND, 1); + alloc_ordered_workqueue("MWIFIEX_WORK_QUEUE", + WQ_HIGHPRI | WQ_MEM_RECLAIM); if (!adapter->workqueue) goto err_kmalloc; INIT_WORK(&adapter->main_work, mwifiex_main_work_queue); if (adapter->rx_work_enabled) { - adapter->rx_workqueue = alloc_workqueue("MWIFIEX_RX_WORK_QUEUE", - WQ_HIGHPRI | - WQ_MEM_RECLAIM | - WQ_UNBOUND, 1); + adapter->rx_workqueue = + alloc_ordered_workqueue("MWIFIEX_RX_WORK_QUEUE", + WQ_HIGHPRI | WQ_MEM_RECLAIM); if (!adapter->rx_workqueue) goto err_kmalloc;