From: Felix Fietkau <nbd@nbd.name>
To: Johannes Berg <johannes@sipsolutions.net>,
Benjamin Beichler <Benjamin.Beichler@uni-rostock.de>,
Karthik M <quic_karm@quicinc.com>
Cc: linux-wireless@vger.kernel.org,
Tamizh Chelvam Raja <quic_tamizhr@quicinc.com>
Subject: Re: [PATCH v1] wifi: mac80211: Initialize EWMA fail avg to 1
Date: Thu, 20 Apr 2023 14:22:36 +0200 [thread overview]
Message-ID: <6d97d1f3-9f77-a1c3-68b5-83065c87b4ba@nbd.name> (raw)
In-Reply-To: <e4dd26fa53ad2535f5a20be63a4b294d99306ffb.camel@sipsolutions.net>
On 20.04.23 12:27, Johannes Berg wrote:
> On Thu, 2023-04-20 at 11:30 +0200, Benjamin Beichler wrote:
>> > To me, basically, I see two ways to solve this:
>> >
>> > 1) we have DECLARE_EWMA_ZERO_VALID() or something like that which
>> > *doesn't* treat 0 as an uninitialized value, and either has a
>> > separate "not initialized yet" bit (but that's iffy storage wise),
>> > or simply has another argument to _init() for the initial value or
>> > so.
>> >
>> > 2) you don't just don't use 0 and 100 but say 1 and 100, that results in
>> > basically the same behaviour, but avoids the special 0.
>> >
>> > johannes
>>
>> I also ran into that problem in the past, and reviewing it again with a
>> college, I think, this is a real bug in the EWMA implementation. I try
>> to provide a proper patch in the next days, but actually the EWMA
>> handles the internal value zero, always like in the initialization,
>> which is wrong, e.g., for positive/negative averaged values.
>
> Yes, it's always wrong as long as you feed it something zero, or values
> with different sign.
>
> For a lot of use cases, however, that doesn't matter. Originally, it was
> used e.g. for signal strength averaging, average packet lengths, etc.
> where it really doesn't matter since you can never use 0 or values that
> have different sign.
>
>> A quick research shows, this bug is since the first implementation of
>> the ewma in the code ...
>>
>
> Yeah, I'm aware of that, I was around for it ;-)
>
> But see above, I'm not sure I'd even call it a bug, at least not
> originally with the users that we had intended.
>
> Hence I don't know if it's really good to fix this in general - for many
> of these cases zero can still be treated specially (and like I mentioned
> in my previous email, we can even here avoid 0), and then we don't spend
> an extra byte (or likely 4) to hold a "first time" flag.
>
> Dunno. Maybe it's not worth thinking about the extra memory space vs.
> the extra maintenance cost. But maybe at least on 64-bit we could steal
> a bit from the unsigned long? Not sure what all the users are..
We don't actually need a full bit. We can just add 1 to the internal
value for initialized values. How about this (completely untested):
https://nbd.name/p/69b00c5b
- Felix
next prev parent reply other threads:[~2023-04-20 12:22 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-17 10:02 [PATCH v1] wifi: mac80211: Initialize EWMA fail avg to 1 Karthik M
2023-04-18 13:04 ` Johannes Berg
2023-04-20 9:30 ` Benjamin Beichler
2023-04-20 10:27 ` Johannes Berg
2023-04-20 11:12 ` Benjamin Beichler
2023-04-20 12:22 ` Felix Fietkau [this message]
2023-04-20 13:00 ` Benjamin Beichler
2023-04-20 13:15 ` Felix Fietkau
2023-04-21 9:35 ` Johannes Berg
2023-04-21 9:53 ` Felix Fietkau
2023-04-21 10:34 ` Benjamin Beichler
2023-04-21 11:13 ` Johannes Berg
2023-04-21 11:51 ` Benjamin Beichler
2023-04-21 12:00 ` Felix Fietkau
2023-04-21 10:23 ` Benjamin Beichler
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=6d97d1f3-9f77-a1c3-68b5-83065c87b4ba@nbd.name \
--to=nbd@nbd.name \
--cc=Benjamin.Beichler@uni-rostock.de \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
--cc=quic_karm@quicinc.com \
--cc=quic_tamizhr@quicinc.com \
/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