Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp2017794ybn; Thu, 26 Sep 2019 05:54:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqwTMMO56E9B0soOfIVmfcVAbW4u6Lu/T6FBzD9ikjhRA4GQOey4jljeLEuClvNuNdfG7CUC X-Received: by 2002:a17:906:32c2:: with SMTP id k2mr2985540ejk.140.1569502498792; Thu, 26 Sep 2019 05:54:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569502498; cv=none; d=google.com; s=arc-20160816; b=FjgS8Ajbt90VgQj9bBjhlMRoNTODqUkPEsq86XIvGjRmcReO2I3AZgbZDwPWHIdjel ovNd+2+cwn+rw/WFPwp7E7RkPYWe/OQ5AFTgeJ1UiTXCOxnIon3aUQYWchi49A9Gln1G VvtYlkwFpoc4FCKw4e5t8m2zl4CMI0XHG4NytAHwA+L14l0M/DMxb20u3MaqeF8fHixL uOwfQflIM8URytgBLi1bj+JYAUF8iu3RkkJfTkJNo2txvD+6dNdYxAxIowOPX1ZmXvfK gNVcFBq1Tquj8vxo8YaASopCafRO4wp0nYibxOeA+ecY+dzzeHUQX14bIi3mIq2+0L1N UE1w== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:from:references:cc:to:subject:dkim-signature; bh=PgfaL7kAdJ5065sz1aXBV1oyDb5cna3C7xcf4wBeMLw=; b=ArDNwyssKhsMeYrNATHgtbA3hBPekbikr5EaHQ35mvK27mBV4aB0H2GyKFJRN+/vd+ skyS5Y/InLg6+hNBgSOyAHosB7qjM4G7I5cxBJmHz8ntj+dy1x/3elUKSAlYGEJHdc/3 OLJc/65SLyFqNsPPJ9ozdNZYPufmYqggwAoIv1AVHX8ATuFvQ97vDyIsZqzUck4IVNvp fnH440+oRcrtwv9jInpX1Ptyf1ImIK1MeA4+RmgHFSBM1PjrFlMOHjKCpSOe3pdpP1Cw ofQbg+kWW1/idHqzNEyvOSAdqhzWIT0fzRAvctUaHuvY+3oBov/nMPA28HseqeEOkQD6 h3mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=cSQYQulK; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u8si938820ejt.219.2019.09.26.05.54.22; Thu, 26 Sep 2019 05:54:58 -0700 (PDT) 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=fail header.i=@nbd.name header.s=20160729 header.b=cSQYQulK; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726758AbfIZMxs (ORCPT + 99 others); Thu, 26 Sep 2019 08:53:48 -0400 Received: from nbd.name ([46.4.11.11]:37964 "EHLO nbd.name" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725768AbfIZMxr (ORCPT ); Thu, 26 Sep 2019 08:53:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=PgfaL7kAdJ5065sz1aXBV1oyDb5cna3C7xcf4wBeMLw=; b=cSQYQulKUjIwrKLwLdPPtwWbF0 VRxAESd0QXXzKUfBLUWClujUb+WwL65ELyMU6W2jtuac5CpC7SViICAGz9Jfbh9eh9r9dF7c2t/98 qkGeaalqWbtBK2NEje7OrV6BbpbhNippqRflkyjQYsRTzVKKE5WQvvghjQykoyoB2stU=; Received: from p54ae9b80.dip0.t-ipconnect.de ([84.174.155.128] helo=nf.local) by ds12 with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1iDTHE-0005oY-3G; Thu, 26 Sep 2019 14:53:44 +0200 Subject: Re: [PATCH RFC/RFT 4/4] mac80211: Apply Airtime-based Queue Limit (AQL) on packet dequeue To: =?UTF-8?Q?Toke_H=c3=b8iland-J=c3=b8rgensen?= , Johannes Berg Cc: linux-wireless@vger.kernel.org, make-wifi-fast@lists.bufferbloat.net, John Crispin , Lorenzo Bianconi References: <156889576422.191202.5906619710809654631.stgit@alrua-x1> <156889576869.191202.510507546538322707.stgit@alrua-x1> From: Felix Fietkau Autocrypt: addr=nbd@nbd.name; prefer-encrypt=mutual; keydata= xsDiBEah5CcRBADIY7pu4LIv3jBlyQ/2u87iIZGe6f0f8pyB4UjzfJNXhJb8JylYYRzIOSxh ExKsdLCnJqsG1PY1mqTtoG8sONpwsHr2oJ4itjcGHfn5NJSUGTbtbbxLro13tHkGFCoCr4Z5 Pv+XRgiANSpYlIigiMbOkide6wbggQK32tC20QxUIwCg4k6dtV/4kwEeiOUfErq00TVqIiEE AKcUi4taOuh/PQWx/Ujjl/P1LfJXqLKRPa8PwD4j2yjoc9l+7LptSxJThL9KSu6gtXQjcoR2 vCK0OeYJhgO4kYMI78h1TSaxmtImEAnjFPYJYVsxrhay92jisYc7z5R/76AaELfF6RCjjGeP wdalulG+erWju710Bif7E1yjYVWeA/9Wd1lsOmx6uwwYgNqoFtcAunDaMKi9xVQW18FsUusM TdRvTZLBpoUAy+MajAL+R73TwLq3LnKpIcCwftyQXK5pEDKq57OhxJVv1Q8XkA9Dn1SBOj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26 Sep 2019 14:53:43 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.1.0 MIME-Version: 1.0 In-Reply-To: <156889576869.191202.510507546538322707.stgit@alrua-x1> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On 2019-09-19 14:22, Toke Høiland-Jørgensen wrote: > From: Toke Høiland-Jørgensen > > Some devices have deep buffers in firmware and/or hardware which prevents > the FQ structure in mac80211 from effectively limiting bufferbloat on the > link. For Ethernet devices we have BQL to limit the lower-level queues, but > this cannot be applied to mac80211 because transmit rates can vary wildly > between packets depending on which station we are transmitting it to. > > To overcome this, we can use airtime-based queue limiting (AQL), where we > estimate the transmission time for each packet before dequeueing it, and > use that to limit the amount of data in-flight to the hardware. This idea > was originally implemented as part of the out-of-tree airtime fairness > patch to ath10k[0] in chromiumos. > > This patch ports that idea over to mac80211. The basic idea is simple > enough: Whenever we dequeue a packet from the TXQs and send it to the > driver, we estimate its airtime usage, based on the last recorded TX rate > of the station that packet is destined for. We keep a running per-AC total > of airtime queued for the whole device, and when that total climbs above 8 > ms' worth of data (corresponding to two maximum-sized aggregates), we > simply throttle the queues until it drops down again. > > The estimated airtime for each skb is stored in the tx_info, so we can > subtract the same amount from the running total when the skb is freed or > recycled. The throttling mechanism relies on this accounting to be > accurate (i.e., that we are not freeing skbs without subtracting any > airtime they were accounted for), so we put the subtraction into > ieee80211_report_used_skb(). > > This patch does *not* include any mechanism to wake a throttled TXQ again, > on the assumption that this will happen anyway as a side effect of whatever > freed the skb (most commonly a TX completion). > > The throttling mechanism only kicks in if the queued airtime total goes > above the limit. Since mac80211 calculates the time based on the reported > last_tx_time from the driver, the whole throttling mechanism only kicks in > for drivers that actually report this value. With the exception of > multicast, where we always calculate an estimated tx time on the assumption > that multicast is transmitted at the lowest (6 Mbps) rate. > > The throttling added in this patch is in addition to any throttling already > performed by the airtime fairness mechanism, and in principle the two > mechanisms are orthogonal (and currently also uses two different sources of > airtime). In the future, we could amend this, using the airtime estimates > calculated by this mechanism as a fallback input to the airtime fairness > scheduler, to enable airtime fairness even on drivers that don't have a > hardware source of airtime usage for each station. > > [0] https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/588190/13/drivers/net/wireless-4.2/ath/ath10k/mac.c#3845 One thing that might be missing here is dealing with airtime accounting of frames that remain queued in the driver/hardware because the station is in powersave mode. - Felix