Re: Is CLOCKS_MASK macro obsolete?

From: John Stultz
Date: Thu Oct 14 2021 - 20:05:26 EST


On Thu, Oct 14, 2021 at 4:46 PM Elliott, Robert (Servers)
<elliott@xxxxxxx> wrote:
>
> The CLOCKS_MASK macro in include/uapi/linux/time.h seems broken; it's ORing together
> two numbered values, one of which is 0. Perhaps these clock IDs started as a bitmask?
> CLOCKS_MASK doesn't appear to be used anywhere in the kernel; nor does the adjacent
> CLOCKS_MONO.
>
> Should those macros be deleted?

As for CLOCKS_MASK, the earliest reference I can find is here:
https://elixir.bootlin.com/linux/v2.5.69/source/include/linux/time.h#L246

Right before the 2.6 release. Seems to have come in with this patch:
https://lore.kernel.org/lkml/3E9B4DCD.3070204@xxxxxxxxxx/
But even there, it doesn't make sense as a mask.

There was even a patch to remove it:
https://lore.kernel.org/lkml/20050113132641.GA4380@xxxxxxxxxx/

Then it took its current form with this:
https://lore.kernel.org/lkml/20050919184842.2.patchmail@xxxxxxxxxxxxxxxxxxxxxx/

So, yea, I suspect it can be dropped as it really doesn't make much
sense, so I don't think it's likely used anywhere in a useful way.
(Though it is referenced in some docs -
https://github.com/Abdullah-Younus/E-Project/blob/35e2d915dd17d7cd14618af8d727b2874c4cae37/doc-html/doc/rtl/linux/clocks_mask.html)

For CLOCKS_MONO, the main risk is breaking existing userland code that
uses it at build time. But as the fix changing to CLOCK_MONOTONIC
seems not too difficult, it's probably ok.

thanks
-john