[RFC v2] mac80211: implement eBDP algorithm to fight bufferbloat
Nathaniel Smith
njs at pobox.com
Fri Feb 25 13:21:50 EST 2011
On Wed, Feb 23, 2011 at 2:28 PM, John W. Linville
<linville at tuxdriver.com> wrote:
> On Mon, Feb 21, 2011 at 03:26:32PM -0800, Nathaniel Smith wrote:
>> But for this calculation to make sense, we need T to be the time it
>> takes the card to transmit 1 fragment. In your patch, you're not
>> measuring that. You're measuring the total time between when a packet
>> is enqueued and when it is transmitted; if there were K packets in the
>> queue ahead of it, then this is the time to send *all* of them --
>> you're measuring (K+1)*T. That's why in my patch, I recorded the
>> current size of the queue when each packet is enqueued, so I could
>> compute T = total_time / (K+1).
>
> Thanks for the math! I think I see what you are saying now. Since the
> measured time is being used to determine the queue size, we need to
> factor-in the length of the queue that resulted in that measurment.
>
> Unfortunately, I'm not sure how to apply this with the technique I
> am using for the timing measurements. :-( I'll have to think about
> this some more...
I guess an ugly but effective approach would be to steal some bits
from the timestamp... something like (untested, and probably needs
some sign-extension bugs fixed):
#define LATENCY_BITS 8
#define ENQUEUED_BITS 24
BUILD_BUG_ON(LATENCY_BITS + ENQUEUED_BITS != 32);
static ktime_t _ktime_get_and_stash(int enqueued) {
timespec now = ktime_to_timespec(ktime_get());
now.sec &= (1 << LATENCY_BITS) - 1;
BUG_ON(enqueued > (1 << ENQUEUED_BITS));
now.sec |= enqueued << LATENCY_BITS;
return timespec_to_ktime(now);
}
static u64 _ktime_diff_to_now_and_unstash(ktime_t then, int * enqueued) {
timespec ts_then = ktime_to_timespec(then);
timespec ts_now = ktime_to_timespec(ktime_get());
*enqueued = ts_then.tv_sec >> LATENCY_BITS;
ts_then.tv_sec &= (1 << LATENCY_BITS) - 1;
ts_now.tv_sec &= (1 << LATENCY_BITS) - 1;
if (ts_now.tv_sec < ts_then.tv_sec)
ts_now.tv_sec += (1 << LATENCY_BITS);
timespec_sub(ts_now, ts_then);
}
More information about the Bloat-devel
mailing list