Re: [PATCH 0/7] proc/stat: Maintain monotonicity of "intr" and "softirq"

Alexei Lozovsky
2021-09-12T12:37:30Z

On Sun, Sep 12, 2021, at 18:30, Alexey Dobriyan wrote:
> How about making everything "unsigned long" or even "u64" like NIC
> drivers do?

I see some possible hurdles ahead:

- Not all architectures have atomic operations for 64-bit values

All those "unsigned int" counters are incremented with __this_cpu_inc()
which tries to use atomics if possible. Though, I'm not quite sure
how this works for read side which does not seem to use atomic reads
at all. I guess, just by the virtue of properly aligned 32-bit reads
being atomic everywhere? If that's so, I think widening counters to
64 bits will come with an asterisk.

- We'll need to update all counters to be 64-bit.

Like, *everyone*. Every field that gets summed up needs to be 64-bit
(or else wrap-arounds will be incorrect). Basically every counter in
every irq_cpustat_t will need to become twice as wide. If that's
a fine price to pay for accurate, full-width counters...

Previously I thought that some of these counters even come from
hardware, but now that I'm reviewing them, that does not seem to be
the case. Thankfully.

So right now I don't see why it shouldn't be doable in theory.
I'll give it a shot, I guess, and see how it works in practice,
at least as far as the patches go (since I can't really test on all
architectures).