Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp840059ybf; Thu, 27 Feb 2020 00:25:41 -0800 (PST) X-Google-Smtp-Source: APXvYqwVeT2AhWf9f7RdxQC2BsLyUK9V8nNRszj665qPrwpCxREma1LfkUuPvorVkN2VNVZ/GK4V X-Received: by 2002:a9d:6548:: with SMTP id q8mr2364410otl.356.1582791941831; Thu, 27 Feb 2020 00:25:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582791941; cv=none; d=google.com; s=arc-20160816; b=DFbkDbfJOLEXtkn/cb6w5sTKd6bMgoBVkzkwscM5ZklEY9wAPILiDLkpjP6sFY8xDz JUNIL9Lmc21KAHYOQRXcaahitWMCZ3/RT7obJmV7Uas/TYp/XLPeESTGdoRODXwhmlGy p+gJK2pHZi94Amm0t8Dg8qqiiY2Z3CswPdTsm/1oO5eYwE7jHq1mm96x18eQRb13sftn IRda1TC8/mSi+Tv/QIpjuCYF9iUsFJbIVyRt469qiatIOVMlLPthzfT0u8jQ0cP+2MZq WlnvEQRXemZtc3NgLWD9k6qeznrHszkJQYdFLNHoZ6eddEo2YKf/KeGUYbk+6Mus6ds4 kuEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=KSdeGwYCtFLH7o7hPMmZuggWDg+clP+M0P4fendM5Ek=; b=L+N1HTT6tmpzYj8z6yt77cyOgzETZksOF1elgNzTwjFUqDcO1fzoo7Fd5haSidoAdH 1XA+uVwAmQT/SZTyHcMS+Pb5vguDliYCmEhxhwXgyC1Q/FqSMtZTYaCjTw5WJdGzxZLT TXdPBMdL61dkUbcQvy79IWXRALc0ZUsr41nQkMn57Dnx3E/IcwFbYfs1aGQxdUbMfvr/ oWdAC146O4kqKd26R3ZS3Dm5gBqDpgOBq5P+9z85BCkjOS03pR6FxjHdsMqsO8Q04rg7 7gBRQuBVIaj1R2now7nxtsXkPUf3hOJ0uj7QIklIcIYx355IlsKHh5qGEbVD8dv0T3IV oVsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Otj4hm6Q; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v10si1105455ote.275.2020.02.27.00.25.19; Thu, 27 Feb 2020 00:25:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Otj4hm6Q; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728588AbgB0IYf (ORCPT + 99 others); Thu, 27 Feb 2020 03:24:35 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:41627 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728539AbgB0IYe (ORCPT ); Thu, 27 Feb 2020 03:24:34 -0500 Received: by mail-lf1-f66.google.com with SMTP id y17so1393690lfe.8 for ; Thu, 27 Feb 2020 00:24:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=KSdeGwYCtFLH7o7hPMmZuggWDg+clP+M0P4fendM5Ek=; b=Otj4hm6QeTJRrfwkO76ykmE/ifE+MPb/dKDUprXwIR+u5G2q9EJGcnP4VkTDDnl1NA TmgSDWj7TWBoHS1sI2lm0xI3p5aJUqzM/iox4X3F7D68cT+dDg2s1eWTR0YaWjXODb6w +Rf11xo0nG6iRF+kammGW+zQvTUWNWSj5finoPLllDZX/Rn9NTNH5xAffyt26h0H+laJ JwheIY2VnqePSw1wEeAHn46GnvMoSfFZP794Aj7YbW0hNp7LiELlOkhN82LAY9jqSD4K et6pRlsMeyAQnNDI4xEwBpdXuPN58oCWCQcEhxXnz6WSODDwrR4MePqbKfx2sMdZRmUM yzLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=KSdeGwYCtFLH7o7hPMmZuggWDg+clP+M0P4fendM5Ek=; b=LJHPxckxvGO4MuUNwCszSR6sxr5/L4Wr8Z9T/CnRBnLCJOFpvIXkRSjFxNNJNFi6B2 cFDe35ZGZ30rkCpOruCXao0H5WMYrkg0K/QTIetSjyuIJByUjk3S8sholkrWH9hcTwVa BYui/bskq1/3DMUidSxZzgGwVE9iOtWr0sNedNvfdVp3Pf6UBknfRUN+HWE0pIZlNYYm /jcbbd9Y7V/Mtm7B/GsapsiYO/OPETAwhwBGvA+khg4440vveQrbcYoXzF4XTX5y8DN5 CiZ50ftNJBwBzOBbQJDJ46RYJByDIsmGvXyvphrl+ouoKK1a8jdarZCveDusmCheYDqe OfVg== X-Gm-Message-State: ANhLgQ3zN65dJLQEEDRu5MSgejhLDrpxWcW+6BYvleEwip9oDOQTr4lC XbSb/ZRawI9D28gz+2ICiWeRi2naBIrfFs10S932Kw== X-Received: by 2002:a19:c106:: with SMTP id r6mr1592136lff.10.1582791869902; Thu, 27 Feb 2020 00:24:29 -0800 (PST) MIME-Version: 1.0 References: <20191119060610.76681-1-kyan@google.com> <20191119060610.76681-5-kyan@google.com> <789d592c-5b1b-b785-6d9c-86b7cc7d57f4@nbd.name> <87k149xbb4.fsf@toke.dk> In-Reply-To: <87k149xbb4.fsf@toke.dk> From: Kan Yan Date: Thu, 27 Feb 2020 00:24:18 -0800 Message-ID: Subject: Re: [PATCH v11 4/4] mac80211: Use Airtime-based Queue Limits (AQL) on packet dequeue To: =?UTF-8?B?VG9rZSBIw7hpbGFuZC1Kw7hyZ2Vuc2Vu?= Cc: Felix Fietkau , Johannes Berg , linux-wireless , Make-Wifi-fast , Yibo Zhao , John Crispin , Lorenzo Bianconi , Rajkumar Manoharan , Kevin Hayes Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org > - AQL estimated airtime does not take into account A-MPDU, so it is > significantly overestimating airtime use for aggregated traffic, > especially on high rates. > My proposed solution would be to check for a running aggregation session > and set estimated tx time to something like: > expected_airtime(16 * skb->len) / 16. Yes, that's a known limitation that needs to be improved. I actually post a comment for this patch: "[PATCH v10 2/4] mac80211: Import airtime calculation code from mt76" > > When a txq is subjected to the queue limit, > there is usually a significant amount of frames being queued and those > frames are likely being sent out in large aggregations. So, in most > cases when AQL is active, the medium access overhead can be amortized > over many frames and the per frame overhead could be considerably > lower than 36, especially at higher data rate. As a result, the > pending airtime calculated this way could be higher than the actual > airtime. In my test, I have to compensate that by increasing > "aql_txq_limit" via debugfs to get the same peak throughput as without > AQL. > My proposed solution would be to check for a running aggregation session > and set estimated tx time to something like: > expected_airtime(16 * skb->len) / 16. I think that's a reasonable approximation, but doubts aggregation information is available in all architectures. In some architecture, firmware may only report aggregation information after the frame has been transmitted. In my earlier version of AQL for the out-of-tree ChromeOS kernel, A-MPDU is dealt this way: The the medium access overhead is only counted once for each TXQ for all frames released to the hardware over a 4ms period, assuming those frames are likely to be aggregated together. Instead of calculating the estimated airtime using the last known phy rate, then try to add some estimated overhead for medium access time, another potentially better approach is to use average data rate, which is byte_transmited/firmware_reported_actual_airtime. The average rate not only includes medium access overhead, but also takes retries into account. > - We need an API that allows the driver to change the pending airtime > values, e.g. subtract estimated tx time for a packet. > mt76 an ath9k can queue packets inside the driver that are not currently > in the hardware queues. Typically if the txqs have more data than what > gets put into the hardware queue, both drivers will pull an extra frame > and queue it in its private txq struct. This frame will get used on the > next txq scheduling round for that particular station. > If you have lots of stations doing traffic (or having driver buffered > frames in powersave mode), this could use up a sizable chunk of the AQL > budget. Not sure I fully understand your concerns here. The AQL budget is per STA, per TID, so frames queued in the driver's special queue for one station won't impact another station's budget. Those frames are counted towards the per interface pending airtime, which could trigger AQL to switch to use the lower queue limit. In this case, that could be the desirable behavior when there is heavy traffic. Regards, Kan On Wed, Feb 26, 2020 at 1:56 PM Toke H=C3=B8iland-J=C3=B8rgensen wrote: > > Felix Fietkau writes: > > > Hi, > > > > I've take a closer look at the AQL implementation, and I found some > > corner cases that need to be addressed soon: > > > > - AQL estimated airtime does not take into account A-MPDU, so it is > > significantly overestimating airtime use for aggregated traffic, > > especially on high rates. > > My proposed solution would be to check for a running aggregation sessio= n > > and set estimated tx time to something like: > > expected_airtime(16 * skb->len) / 16. > > This seems reasonable. Not sure if it'll do anything for ath10k (does > mac80211 know the aggregation state for that?), but maybe this is not > such a big issue on that hardware? > > > - We need an API that allows the driver to change the pending airtime > > values, e.g. subtract estimated tx time for a packet. > > mt76 an ath9k can queue packets inside the driver that are not currentl= y > > in the hardware queues. Typically if the txqs have more data than what > > gets put into the hardware queue, both drivers will pull an extra frame > > and queue it in its private txq struct. This frame will get used on the > > next txq scheduling round for that particular station. > > If you have lots of stations doing traffic (or having driver buffered > > frames in powersave mode), this could use up a sizable chunk of the AQL > > budget. > > I'm a bit more skeptical about this. If the driver buffers a bunch of > packets that are not accounted that will hurt that station due to extra > latency when it wakes up. For ath9k, this is the retry_q you're talking > about, right? The number of packets queued on that is fairly limited, > isn't it? What kind of powersave buffering is the driver doing, and why > can't it leave the packets on the TXQ? That would allow them to be > scheduled along with any new ones that might have arrived in the > meantime, which would be a benefit for latency. > > I can see how it can be a problem that many stations in powersave can > block transmissions for *other* stations, though. Maybe an alternative > to the driver subtracting airtime could be to have mac80211 do something > like this when a station is put into powersave mode: > > local->aql_total_pending_airtime -=3D sum(sta->airtime[ac].aql_tx_pending= ) > > (where sum is the summation over all ACs) > > and the reverse when the station wakes back up? That should keep the > whole device from throttling but still prevent a big queue building up > for that sta when it wakes back up. Would that work, do you think? > > -Toke >