I would suggest just fixing zerodiv for now because IMO the patch fixing overflows properly on stddev path may or may not use macroconstants at all. Also ns^2 overflow will always happen first. I don't know in advance how this patch will look at the end and even not sure it's viable. Steps to consider: 0) Infer some assumptions from the rest of tracing code like `nanoseconds are stored in unsigned long, so on 32-bit machine function should not execute more than ~ 2 s anyway` 1) unsigned long -> u64 conversion 2) ns^2 -> us^2 if possible, inevitable precision loss (how much?) 3) Compute stddev using some numerical trick. Now comment about Welford's method is a bit misleading because its a plain variance formula. But maybe it's a hint that we should convert to that method and problems are gone? ;)
I'll send the patch fixing zero division and simplifying code a bit as a follow-up. It's up to you to choose what to apply. I'm Ok with any patch fixing zerodiv and will look into overflow problem. Again, thank you very much for the review and your time.
