Comment by pajko
15 days ago
Timestamps should NOT be compared like this. Exactly this is why time_before() or time_after() exist.
https://elixir.bootlin.com/linux/v6.15.7/source/include/linu...
15 days ago
Timestamps should NOT be compared like this. Exactly this is why time_before() or time_after() exist.
https://elixir.bootlin.com/linux/v6.15.7/source/include/linu...
Offtopic...
It's funny the love-hate relationship the Linux kernel has with GCC. It's the only supported compiler[1], and yet...
[1] can Clang fully compile Linux yet? I haven't followed the updates in a while.
To be fair this comment predates git history (before 2005) when GCC wasn't a very good compiler. The kernel developers at one point were sticking with a specific version of GCC because later versions would miscompile the kernel. Clang didn't exist then.
GCC is a different beast and far better nowadays.
Yes it can [1].
https://docs.kernel.org/kbuild/llvm.html
Do I understand it correctly that the logic is that if timestamp B is above timestamp A, but the difference is more than half of the unsigned range, B is considered to happen before A?
Yes. When the timestamps wrap it's fundamentally ambiguous, but this will be correct unless the timestamps are very far apart (and the failure mode is more benign: a really long time difference being considered shorter is better than all time differences being considered zero after the timestamp wraps).