linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Is CLOCKS_MASK macro obsolete?
@ 2021-10-14 23:46 Elliott, Robert (Servers)
  2021-10-15  0:05 ` John Stultz
  0 siblings, 1 reply; 2+ messages in thread
From: Elliott, Robert (Servers) @ 2021-10-14 23:46 UTC (permalink / raw)
  To: 'Thomas Gleixner', 'john.stultz@linaro.org',
	'sboyd@kernel.org',
	linux-kernel
  Cc: Kani, Toshi

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?

Excerpt:
#define CLOCK_REALTIME                  0
#define CLOCK_MONOTONIC                 1
#define CLOCK_PROCESS_CPUTIME_ID        2
#define CLOCK_THREAD_CPUTIME_ID         3
#define CLOCK_MONOTONIC_RAW             4
#define CLOCK_REALTIME_COARSE           5
#define CLOCK_MONOTONIC_COARSE          6
#define CLOCK_BOOTTIME                  7
#define CLOCK_REALTIME_ALARM            8
#define CLOCK_BOOTTIME_ALARM            9
/*
 * The driver implementing this got removed. The clock ID is kept as a
 * place holder. Do not reuse!
 */
#define CLOCK_SGI_CYCLE                 10
#define CLOCK_TAI                       11

#define MAX_CLOCKS                      16
#define CLOCKS_MASK                     (CLOCK_REALTIME | CLOCK_MONOTONIC)
#define CLOCKS_MONO                     CLOCK_MONOTONIC



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Is CLOCKS_MASK macro obsolete?
  2021-10-14 23:46 Is CLOCKS_MASK macro obsolete? Elliott, Robert (Servers)
@ 2021-10-15  0:05 ` John Stultz
  0 siblings, 0 replies; 2+ messages in thread
From: John Stultz @ 2021-10-15  0:05 UTC (permalink / raw)
  To: Elliott, Robert (Servers)
  Cc: Thomas Gleixner, sboyd, linux-kernel, Kani, Toshi

On Thu, Oct 14, 2021 at 4:46 PM Elliott, Robert (Servers)
<elliott@hpe.com> 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@mvista.com/
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@elf.ucw.cz/

Then it took its current form with this:
  https://lore.kernel.org/lkml/20050919184842.2.patchmail@tglx.tec.linutronix.de/

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-15  0:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-14 23:46 Is CLOCKS_MASK macro obsolete? Elliott, Robert (Servers)
2021-10-15  0:05 ` John Stultz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).