Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * sched_clock.h: support for extending counters to full 64-bit ns counter
0004  */
0005 #ifndef LINUX_SCHED_CLOCK
0006 #define LINUX_SCHED_CLOCK
0007 
0008 #include <linux/types.h>
0009 
0010 #ifdef CONFIG_GENERIC_SCHED_CLOCK
0011 /**
0012  * struct clock_read_data - data required to read from sched_clock()
0013  *
0014  * @epoch_ns:       sched_clock() value at last update
0015  * @epoch_cyc:      Clock cycle value at last update.
0016  * @sched_clock_mask:   Bitmask for two's complement subtraction of non 64bit
0017  *          clocks.
0018  * @read_sched_clock:   Current clock source (or dummy source when suspended).
0019  * @mult:       Multiplier for scaled math conversion.
0020  * @shift:      Shift value for scaled math conversion.
0021  *
0022  * Care must be taken when updating this structure; it is read by
0023  * some very hot code paths. It occupies <=40 bytes and, when combined
0024  * with the seqcount used to synchronize access, comfortably fits into
0025  * a 64 byte cache line.
0026  */
0027 struct clock_read_data {
0028     u64 epoch_ns;
0029     u64 epoch_cyc;
0030     u64 sched_clock_mask;
0031     u64 (*read_sched_clock)(void);
0032     u32 mult;
0033     u32 shift;
0034 };
0035 
0036 extern struct clock_read_data *sched_clock_read_begin(unsigned int *seq);
0037 extern int sched_clock_read_retry(unsigned int seq);
0038 
0039 extern void generic_sched_clock_init(void);
0040 
0041 extern void sched_clock_register(u64 (*read)(void), int bits,
0042                  unsigned long rate);
0043 #else
0044 static inline void generic_sched_clock_init(void) { }
0045 
0046 static inline void sched_clock_register(u64 (*read)(void), int bits,
0047                     unsigned long rate)
0048 {
0049 }
0050 #endif
0051 
0052 #endif