[Make-wifi-fast] [PATCH RFC/RFT 4/4] mac80211: Apply Airtime-based Queue Limit (AQL) on packet dequeue

Yibo Zhao yiboz at codeaurora.org
Fri Sep 27 05:20:08 EDT 2019


On 2019-09-27 14:12, Toke Høiland-Jørgensen wrote:
> Kan Yan <kyan at google.com> writes:
> 
>>> No, but on tx_completion we could do something like this:
>>> airtime = CB(skb)->tx_time ?: CB(skb)->tx_time_est;
>>> ieee80211_report_airtime(sta, airtime);
>>> That way, if the driver sets the tx_time field to something the 
>>> firmware
>>> reports, we'll use that, and otherwise we'd fall back to the 
>>> estimate.
>>> Of course, there would need to be a way for the driver to opt out of
>>> this, for drivers that report out of band airtime like ath10k does :)
>> 
>> I doubt that will work, unless firmware can do per frame airtime
>> update in the skb. It is more likely that firmware provides out of
>> band airtime update for a period of time, like an aggregation. That's
>> the case for ath10k: https://patchwork.kernel.org/patch/10684689
> 
> No, ath10k would continue to do what it was always doing. Drivers that
> can report after-the-fact airtime usage per-frame (like ath9k) will
> continue to do that. In both of those cases, the airtime estimate is
> only used to throttle the queue, not to schedule for fairness.
> 
> My point is just that for drivers that have *no* mechanism to report
> airtime usage after-the-fact, we can add a flag that will allow the
> values estimated by mac80211 to also be used for the fairness
> scheduler...
> 
>> Regarding handling frame for station enters power saving mode:
>>> 
>>> >> Oh, right. Didn't know that could happen (I assumed those would be
>>> >> flushed out or something). But if we're going to go with Kan's
>>> >> suggestion of having per-station accounting as well as a global
>>> >> accounting for the device, we could just subtract the station's
>>> >> outstanding balance from the device total when it goes into powersave
>>> >> mode, and add it back once it wakes up again. At least I think that
>>> >> would work, no?
>>> >Yes, I think that would work.
>>> Great! Will incorporate that, then.
>> 
>> I think that could work but things could be a bit more complicated.
>> Not sure I fully understand the usage of airtime_weight_sum in  [PATCH
>> V3 1/4] mac80211: Switch to a virtual time-based airtime scheduler:
>> 
>> in ieee80211_schedule_txq():
>>    local->airtime_weight_sum[ac] += sta->airtime_weight;
>> 
>> in ieee80211_sta_register_airtime():
>>    weight_sum = local->airtime_weight_sum[ac] ?: sta->airtime_weight;
>>    local->airtime_v_t[ac] += airtime / weight_sum;
>>    sta->airtime[ac].v_t += airtime / sta->airtime_weight;
>> 
>> in  __ieee80211_unschedule_txq
>>  local->airtime_weight_sum[ac] -= sta->airtime_weight;
>> 
>> I assume the purpose of airtime_weight_sum is to count station's
>> virtual airtime proportional to the number of active stations for
>> fairness.
> 
> Yup, the proportion between the station's airtime weight and the total
> scheduled airtime weight indicates the station's fair share.
> 
>> My concern is the per interface local->airtime_weight_sum[ac] get
>> updated when packets are released from a txq to lower layer, but it
>> doesn't mean the airtime will be consumed (packets get transmitted)
>> shortly, due to events like station enter power save mode, so the
>> weight_sum used in ieee80211_sta_register_airtime() maybe inaccurate.
>> For architects using firmware/hardware offloading, firmware ultimately
>> controls packet scheduling and has quite a lot of autonomy. The host
>> driver's airtime_weight_sum may get out of sync with the number of
>> active stations actually scheduled by firmware even without power
>> saving events.
>> 
>> Is this a correct understanding? I kind of think the original method
>> of airtime accounting using deficit maybe more robust in this regard.
> 
> You are right that this could happen, yes. However, the station is only
> unscheduled when its mac80211 queue runs completely empty. So the
> assumption is that stations that transmit continuously (which are 
> really
> the ones we care about for fairness purposes), would keep being
> scheduled most of the time.
> 
> Now, you're quite right that this assumption might be wrong, which 
> would
> lead to bad results. I think the other (queue throttling) patch set
> would help, though; that should push the queues up into mac80211 and
> give the stations a higher probability of being scheduled when they are
> in fact backlogged. I've only tested the virtual time scheduler on
> ath9k, which inherently has shallow buffers in the hardware.
> 
> So yeah, it may be that the virtual time-thing turns out to not work
> well. But the results looked encouraging on ath9k, and since it will

I am not familiar with ath9k but SFAIK, ath9k is fine with virtual 
time-thing because it does not have firmware/hardware offloading. Thus 
host can see the packets backlogged in host queue and TXQs stay on 
rbtree for the most of time if there is continuous transmission. As a 
result, the algo fully works. While for ath10k like Kan said, it has 
firmware/hardware offloading and host cannot see the packets backlogged 
in host queue because they are already sent to FW queue as long as the 
ingress load less than PHY rate. Then TXQs are removed from the rbtree 
which leads to the algo not working so well. For driver that has 
firmware/hardware offloading, I think the key is to keep some of the 
packets buffered in the host even if FW queue is not full at that time. 
Also I believe DRR may have the same issue since only TXQs in the list 
contend for Tx chance.

> make it easier to schedule multiple stations, I think it has some merit
> that makes it worth trying out. We should probably get the AQL stuff
> done first, though, and try the virtual time scheduler on top of that.

Agree that we should get the AQL stuff done first since I believe it 
will help to fix the issue mentioned above.

> 
> BTW, I think Felix' concern about powersave was in relation to AQL: If
> we don't handle power save in that, we can end up in a situation where
> the budget for packets allowed to be queued in the firmware is taken up
> entirely by stations that are currently in powersave mode; which would
> throttle the device completely. So we should take that into account for
> AQL; for the fairness scheduler, stations in powersave are already
> unscheduled, so that should be fine.
> 
> -Toke

-- 
Yibo


More information about the Make-wifi-fast mailing list