Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp165211rwd; Tue, 30 May 2023 18:06:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ677j/B6Jlmim613QtfMVl/4xxYb6RG9CM8drUWkN1OwDJPlTr5A5o7riiMyZWN3e3Wrc8X X-Received: by 2002:a05:6a20:9146:b0:10d:8f40:6454 with SMTP id x6-20020a056a20914600b0010d8f406454mr4822529pzc.36.1685495196119; Tue, 30 May 2023 18:06:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685495196; cv=none; d=google.com; s=arc-20160816; b=Uvnv+bS07N58rbRYyIO2fVfo2Mg3WFjPtHeGv7SzZzXgKgBJuvPUMld07qVzyJU4Ei C4xRiCueJmwiAkRRYOsaQz4uCYVAXu34CXLkHuSOnlVUNtY0+FBgiA8JfUlPpDPYbn2P pG41Z9HXeHMJFyEVI4vHwLsKQggYgcpHZoZ1Peh/KBuZllufEJ0Qu+FQ/G7+9QEJR4+f bvW+t1vc7uHLoCe99F9LXvk8oWGLbNLjmbTFaHNIYmuiPsTBUxnTmHqd3zWWJYc3GTiW q8Jq+pX2Ei6QObxrMCU98je3uz9GN+dBvG7J4uI6V8mNbVyrYhXowMFiFlo46wfZfzIR ltkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:authenticated-by; bh=oRS2kRYsQh+8+ii+2I92ZhrEUu4FHkoZdg8qqJOk8RU=; b=BfMw+yLs9+6fzV3pezEil5Iqh+iq+aY+Deulg3J1OjpIhUGwTW/fBUPlRaXGoVy3KA 81VxbAYE8EbgkFEZ9IvNyShBWLv4pSI+9gMIBeHAMpYuf1xxrvMNNgzcbeWM4R0rc6tU wLlVz9/T007+YnfOf0HMd9RQM6Bge6SKyjiKsW6UacnBSVpa7eZ6ekg5x+DJ/QCSiW3T tSbtbKHc1ykXWYlMaUfUKDHX7+rEjAeFPMXDdG3sWAhANlKHDgC4FSurWBiz99LcYs6Y nCsoVmcC4agf3CJIKTkRCDtyYfc9AZbSOY7KspkDVEFPi+awFYGJAkFwhwOk96G+wg+V xDBA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 34-20020a631062000000b0053b0da378edsi11195633pgq.789.2023.05.30.18.06.24; Tue, 30 May 2023 18:06:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233724AbjEaAqV convert rfc822-to-8bit (ORCPT + 63 others); Tue, 30 May 2023 20:46:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231534AbjEaAqU (ORCPT ); Tue, 30 May 2023 20:46:20 -0400 Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95A9DE8 for ; Tue, 30 May 2023 17:46:15 -0700 (PDT) Authenticated-By: X-SpamFilter-By: ArmorX SpamTrap 5.77 with qID 34V0ifa97025976, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtexh36506.realtek.com.tw[172.21.6.27]) by rtits2.realtek.com.tw (8.15.2/2.81/5.90) with ESMTPS id 34V0ifa97025976 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=OK); Wed, 31 May 2023 08:44:41 +0800 Received: from RTEXMBS04.realtek.com.tw (172.21.6.97) by RTEXH36506.realtek.com.tw (172.21.6.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.17; Wed, 31 May 2023 08:44:54 +0800 Received: from RTEXMBS04.realtek.com.tw (172.21.6.97) by RTEXMBS04.realtek.com.tw (172.21.6.97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 31 May 2023 08:44:54 +0800 Received: from RTEXMBS04.realtek.com.tw ([fe80::e138:e7f1:4709:ff4d]) by RTEXMBS04.realtek.com.tw ([fe80::e138:e7f1:4709:ff4d%5]) with mapi id 15.01.2375.007; Wed, 31 May 2023 08:44:54 +0800 From: Ping-Ke Shih To: "petter@technux.se" , "kvalo@kernel.org" CC: "Larry.Finger@lwfinger.net" , "andreas@fatal.se" , "iam@valdikss.org.ru" , "kernel@pengutronix.de" , "linux-wireless@vger.kernel.org" , "linux@ulli-kroll.de" , "petter.mabacker@esab.se" , "s.hauer@pengutronix.de" Subject: RE: [PATCH] wifi: rtw88: usb: Make work queues high prio Thread-Topic: [PATCH] wifi: rtw88: usb: Make work queues high prio Thread-Index: AQHZktdSd7H9r3V3PEuOOEkQppWIDa9ynIlG//+njICAAUS58A== Date: Wed, 31 May 2023 00:44:54 +0000 Message-ID: <96e0b705b5a64679a14ce5440674f4b0@realtek.com> References: <87zg5mjeu4.fsf@kernel.org> <20230530130917.2716182-1-petter@technux.se> In-Reply-To: <20230530130917.2716182-1-petter@technux.se> Accept-Language: en-US, zh-TW Content-Language: zh-TW X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.21.69.188] x-kse-serverinfo: RTEXMBS04.realtek.com.tw, 9 x-kse-antispam-interceptor-info: fallback x-kse-antivirus-interceptor-info: fallback Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-KSE-AntiSpam-Interceptor-Info: fallback X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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-wireless@vger.kernel.org > -----Original Message----- > From: petter@technux.se > Sent: Tuesday, May 30, 2023 9:09 PM > To: kvalo@kernel.org > Cc: Larry.Finger@lwfinger.net; andreas@fatal.se; iam@valdikss.org.ru; kernel@pengutronix.de; > linux-wireless@vger.kernel.org; linux@ulli-kroll.de; petter.mabacker@esab.se; petter@technux.se; Ping-Ke > Shih ; s.hauer@pengutronix.de > Subject: Re: [PATCH] wifi: rtw88: usb: Make work queues high prio > > petter@technux.se writes: > > >> From: Petter Mabacker > >> > >> The rtw8822cu driver have problem to handle high rx or tx rates compared > >> with high load (such as high I/O) on slower systems, such as for example > >> i.MX6 SoloX and similar platforms. > >> > >> The problems are more frequent when having the access point close to the > >> device. On slower systems it's often enough to download a large file, > >> combined with generating I/O load to trigger: > >> > >> [ 374.763424] rtw_8822cu 1-1.2:1.2: failed to get tx report from firmware > >> [ 377.771790] rtw_8822cu 1-1.2:1.2: failed to send h2c command > >> [ 407.813460] rtw_8822cu 1-1.2:1.2: firmware failed to report density after scan > >> [ 414.965826] rtw_8822cu 1-1.2:1.2: failed to send h2c command > >> [ 444.993462] rtw_8822cu 1-1.2:1.2: firmware failed to report density after scan > >> [ 452.144551] rtw_8822cu 1-1.2:1.2: failed to send h2c command > >> [ 482.183445] rtw_8822cu 1-1.2:1.2: firmware failed to report density after scan > >> [ 489.426263] rtw_8822cu 1-1.2:1.2: failed to send h2c command > >> > >> Another way is to simply perform a wifi rescan. > >> > >> Benchmarking shows that setting a high prio workqueue for tx/rx will > >> significally improve things. Also compared alloc_workqueue with > >> alloc_ordered_workqueue, but even thou the later seems to slightly > >> improve things it's still quite easy to reproduce the above issues. So > >> that leads to the decision to go for alloc_workqueue. > >> > >> Thanks to Ping-Ke Shih that came up with the idea > >> of exploring tweaking of the work queue's within a similar discussion. > >> > >> Fixes: a82dfd33d1237 ("wifi: rtw88: Add common USB chip support") > >> Signed-off-by: Petter Mabacker > >> --- > >> drivers/net/wireless/realtek/rtw88/usb.c | 4 ++-- > >> 1 file changed, 2 insertions(+), 2 deletions(-) > >> > >> diff --git a/drivers/net/wireless/realtek/rtw88/usb.c b/drivers/net/wireless/realtek/rtw88/usb.c > >> index 44a5fafb9905..bfe0845528ec 100644 > >> --- a/drivers/net/wireless/realtek/rtw88/usb.c > >> +++ b/drivers/net/wireless/realtek/rtw88/usb.c > >> @@ -716,7 +716,7 @@ static int rtw_usb_init_rx(struct rtw_dev *rtwdev) > >> struct rtw_usb *rtwusb = rtw_get_usb_priv(rtwdev); > >> int i; > >> > >> - rtwusb->rxwq = create_singlethread_workqueue("rtw88_usb: rx wq"); > >> + rtwusb->rxwq = alloc_workqueue("rtw88_usb: rx wq", WQ_UNBOUND | WQ_HIGHPRI, 0); > >> if (!rtwusb->rxwq) { > >> rtw_err(rtwdev, "failed to create RX work queue\n"); > >> return -ENOMEM; > >> @@ -750,7 +750,7 @@ static int rtw_usb_init_tx(struct rtw_dev *rtwdev) > >> struct rtw_usb *rtwusb = rtw_get_usb_priv(rtwdev); > >> int i; > >> > >> - rtwusb->txwq = create_singlethread_workqueue("rtw88_usb: tx wq"); > >> + rtwusb->txwq = alloc_workqueue("rtw88_usb: tx wq", WQ_UNBOUND | WQ_HIGHPRI, 0); > >> if (!rtwusb->txwq) { > >> rtw_err(rtwdev, "failed to create TX work queue\n"); > >> return -ENOMEM; > > >Should this workqueue be ordered or not? Please check Tejun's patchset > >about using ordered queues: > > >https://lore.kernel.org/lkml/20230421025046.4008499-1-tj@kernel.org/ > > Thanks for pointing out this interesting patchset. As described in the > commit msg, I did play around with alloc_ordered_workqueue. But at least > on the slower systems I tested it on (i.MX6 SoloX and BCM2835) it worked > a bit better, but I was still able to reproduce the above mention issue. > So I tried to instead use alloc_workqueue and set max_active=0 and that > seems to be enough to make things a lot more stable. > > However after reading Tejun's patchet I'm very intersted of feedback if > you or someone else have comments about using alloc_workqueue with > max_active=0 , or if this can give some other issues? It seems to work > fine for me when running it also on a i.MX8 multicore system. > Both rtwusb->rxwq and rtwusb->txwq are only queued single one work respectively, so I thought alloc_workqueue() and alloc_ordered_workqueue() would get the same results, but it seems not. That is a little weird to me. I'm not familiar with workqueue, but I think we can bisect arguments to address what impact the results. First we can expand macro alloc_ordered_workqueue() below rtwusb->txwq = alloc_ordered_workqueue("rtw88_usb: tx wq", WQ_HIGHPRI); into rtwusb->txwq = alloc_workqueue("rtw88_usb: tx wq", WQ_UNBOUND | __WQ_ORDERED | __WQ_ORDERED_EXPLICIT | WQ_HIGHPRI, 1); Secondly, compare the one you are using: rtwusb->txwq = alloc_workqueue("rtw88_usb: tx wq", WQ_UNBOUND | WQ_HIGHPRI, 0); Then, we can align the arguments one-by-one to know which argument dominates the result. Ping-Ke