diff options
Diffstat (limited to 'lib/average.c')
-rw-r--r-- | lib/average.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/average.c b/lib/average.c index 99a67e662b3c..114d1beae0c7 100644 --- a/lib/average.c +++ b/lib/average.c | |||
@@ -53,8 +53,10 @@ EXPORT_SYMBOL(ewma_init); | |||
53 | */ | 53 | */ |
54 | struct ewma *ewma_add(struct ewma *avg, unsigned long val) | 54 | struct ewma *ewma_add(struct ewma *avg, unsigned long val) |
55 | { | 55 | { |
56 | avg->internal = avg->internal ? | 56 | unsigned long internal = ACCESS_ONCE(avg->internal); |
57 | (((avg->internal << avg->weight) - avg->internal) + | 57 | |
58 | ACCESS_ONCE(avg->internal) = internal ? | ||
59 | (((internal << avg->weight) - internal) + | ||
58 | (val << avg->factor)) >> avg->weight : | 60 | (val << avg->factor)) >> avg->weight : |
59 | (val << avg->factor); | 61 | (val << avg->factor); |
60 | return avg; | 62 | return avg; |