linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Felix Fietkau <nbd@nbd.name>, linux-wireless@vger.kernel.org
Subject: Re: [PATCH 2/2] mac80211: minstrel_ht: replace rate stats ewma with a better moving average
Date: Tue, 01 Oct 2019 13:06:18 +0200	[thread overview]
Message-ID: <8017042b74a05df72a7ebfb5ec21fc7cc088ed4e.camel@sipsolutions.net> (raw)
In-Reply-To: <017c1a59-edf2-0a1a-aa8c-3c32e57d6cd0@nbd.name>

On Tue, 2019-10-01 at 12:52 +0200, Felix Fietkau wrote:
> 
> Might be useful, yes. The main issue here is that the period / window
> size has to be hardcoded through the coefficient values, unless we find
> a way to do floating point math, including exp() and cos() at compile
> time, including conversion to fixed point.

Works fine for me?

#include <math.h>
#include <stdio.h>
#include <stdlib.h>

#define E(x) ((int)(exp(x) * (1<<20)))
#define C(x) ((int)(cos(x) * (1<<20)))

int main()
{
        int e2 = E(2);
        int c2 = C(2);

        printf("e2: %d\n", e2);
        printf("whole: %d frac: %d\n", e2 >> 20, e2 & ((1 << 20) - 1));
        printf("c2: %d\n", c2);
        printf("sign: %s whole: %d frac: %d\n", c2 < 0 ? "-" : "", abs(c2) >> 20, abs(c2) & ((1 << 20) - 1));
}

objdump -dr test:
[...]
0000000000401040 <main>:
  401040:	48 83 ec 08          	sub    $0x8,%rsp
  401044:	be 92 39 76 00       	mov    $0x763992,%esi		// exp(2) * (1<<20)
  401049:	bf 10 20 40 00       	mov    $0x402010,%edi
  40104e:	31 c0                	xor    %eax,%eax
  401050:	e8 db ff ff ff       	callq  401030 <printf@plt>
  401055:	ba 92 39 06 00       	mov    $0x63992,%edx
  40105a:	be 07 00 00 00       	mov    $0x7,%esi
  40105f:	31 c0                	xor    %eax,%eax
  401061:	bf 2b 20 40 00       	mov    $0x40202b,%edi
  401066:	e8 c5 ff ff ff       	callq  401030 <printf@plt>
  40106b:	be 77 57 f9 ff       	mov    $0xfff95777,%esi
  401070:	bf 18 20 40 00       	mov    $0x402018,%edi
  401075:	31 c0                	xor    %eax,%eax
  401077:	e8 b4 ff ff ff       	callq  401030 <printf@plt>
  40107c:	b9 89 a8 06 00       	mov    $0x6a889,%ecx		// cos(2) * (1<<20)
  401081:	31 d2                	xor    %edx,%edx
  401083:	31 c0                	xor    %eax,%eax
  401085:	be 20 20 40 00       	mov    $0x402020,%esi
  40108a:	bf 22 20 40 00       	mov    $0x402022,%edi
  40108f:	e8 9c ff ff ff       	callq  401030 <printf@plt>
[...]

johannes


  reply	other threads:[~2019-10-01 11:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-29 15:46 [PATCH 1/2] mac80211: minstrel: remove divisions in tx status path Felix Fietkau
2019-09-29 15:46 ` [PATCH 2/2] mac80211: minstrel_ht: replace rate stats ewma with a better moving average Felix Fietkau
2019-09-29 18:42   ` Toke Høiland-Jørgensen
2019-09-29 19:18     ` Felix Fietkau
2019-09-29 19:46       ` Toke Høiland-Jørgensen
2019-10-01 10:17   ` Johannes Berg
2019-10-01 10:52     ` Felix Fietkau
2019-10-01 11:06       ` Johannes Berg [this message]
2019-10-01 11:11         ` Johannes Berg
2019-10-08  9:18   ` Koen Vandeputte

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8017042b74a05df72a7ebfb5ec21fc7cc088ed4e.camel@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    --cc=nbd@nbd.name \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).