···22#ifndef _linux_POSIX_TIMERS_H33#define _linux_POSIX_TIMERS_H4455-#include <linux/spinlock.h>55+#include <linux/alarmtimer.h>66#include <linux/list.h>77#include <linux/mutex.h>88-#include <linux/alarmtimer.h>88+#include <linux/posix-timers_types.h>99+#include <linux/spinlock.h>910#include <linux/timerqueue.h>10111112struct kernel_siginfo;1213struct task_struct;1313-1414-/*1515- * Bit fields within a clockid:1616- *1717- * The most significant 29 bits hold either a pid or a file descriptor.1818- *1919- * Bit 2 indicates whether a cpu clock refers to a thread or a process.2020- *2121- * Bits 1 and 0 give the type: PROF=0, VIRT=1, SCHED=2, or FD=3.2222- *2323- * A clockid is invalid if bits 2, 1, and 0 are all set.2424- */2525-#define CPUCLOCK_PID(clock) ((pid_t) ~((clock) >> 3))2626-#define CPUCLOCK_PERTHREAD(clock) \2727- (((clock) & (clockid_t) CPUCLOCK_PERTHREAD_MASK) != 0)2828-2929-#define CPUCLOCK_PERTHREAD_MASK 43030-#define CPUCLOCK_WHICH(clock) ((clock) & (clockid_t) CPUCLOCK_CLOCK_MASK)3131-#define CPUCLOCK_CLOCK_MASK 33232-#define CPUCLOCK_PROF 03333-#define CPUCLOCK_VIRT 13434-#define CPUCLOCK_SCHED 23535-#define CPUCLOCK_MAX 33636-#define CLOCKFD CPUCLOCK_MAX3737-#define CLOCKFD_MASK (CPUCLOCK_PERTHREAD_MASK|CPUCLOCK_CLOCK_MASK)38143915static inline clockid_t make_process_cpuclock(const unsigned int pid,4016 const clockid_t clock)···85109 ctmr->node.expires = exp;86110}871118888-/**8989- * posix_cputimer_base - Container per posix CPU clock9090- * @nextevt: Earliest-expiration cache9191- * @tqhead: timerqueue head for cpu_timers9292- */9393-struct posix_cputimer_base {9494- u64 nextevt;9595- struct timerqueue_head tqhead;9696-};9797-9898-/**9999- * posix_cputimers - Container for posix CPU timer related data100100- * @bases: Base container for posix CPU clocks101101- * @timers_active: Timers are queued.102102- * @expiry_active: Timer expiry is active. Used for103103- * process wide timers to avoid multiple104104- * task trying to handle expiry concurrently105105- *106106- * Used in task_struct and signal_struct107107- */108108-struct posix_cputimers {109109- struct posix_cputimer_base bases[CPUCLOCK_MAX];110110- unsigned int timers_active;111111- unsigned int expiry_active;112112-};113113-114114-/**115115- * posix_cputimers_work - Container for task work based posix CPU timer expiry116116- * @work: The task work to be scheduled117117- * @mutex: Mutex held around expiry in context of this task work118118- * @scheduled: @work has been scheduled already, no further processing119119- */120120-struct posix_cputimers_work {121121- struct callback_head work;122122- struct mutex mutex;123123- unsigned int scheduled;124124-};125125-126112static inline void posix_cputimers_init(struct posix_cputimers *pct)127113{128114 memset(pct, 0, sizeof(*pct));···117179 .bases = INIT_CPU_TIMERBASES(s.posix_cputimers.bases), \118180 },119181#else120120-struct posix_cputimers { };121182struct cpu_timer { };122183#define INIT_CPU_TIMERS(s)123184static inline void posix_cputimers_init(struct posix_cputimers *pct) { }
+80
include/linux/posix-timers_types.h
···11+/* SPDX-License-Identifier: GPL-2.0 */22+#ifndef _linux_POSIX_TIMERS_TYPES_H33+#define _linux_POSIX_TIMERS_TYPES_H44+55+#include <linux/mutex_types.h>66+#include <linux/timerqueue.h>77+#include <linux/types.h>88+99+/*1010+ * Bit fields within a clockid:1111+ *1212+ * The most significant 29 bits hold either a pid or a file descriptor.1313+ *1414+ * Bit 2 indicates whether a cpu clock refers to a thread or a process.1515+ *1616+ * Bits 1 and 0 give the type: PROF=0, VIRT=1, SCHED=2, or FD=3.1717+ *1818+ * A clockid is invalid if bits 2, 1, and 0 are all set.1919+ */2020+#define CPUCLOCK_PID(clock) ((pid_t) ~((clock) >> 3))2121+#define CPUCLOCK_PERTHREAD(clock) \2222+ (((clock) & (clockid_t) CPUCLOCK_PERTHREAD_MASK) != 0)2323+2424+#define CPUCLOCK_PERTHREAD_MASK 42525+#define CPUCLOCK_WHICH(clock) ((clock) & (clockid_t) CPUCLOCK_CLOCK_MASK)2626+#define CPUCLOCK_CLOCK_MASK 32727+#define CPUCLOCK_PROF 02828+#define CPUCLOCK_VIRT 12929+#define CPUCLOCK_SCHED 23030+#define CPUCLOCK_MAX 33131+#define CLOCKFD CPUCLOCK_MAX3232+#define CLOCKFD_MASK (CPUCLOCK_PERTHREAD_MASK|CPUCLOCK_CLOCK_MASK)3333+3434+#ifdef CONFIG_POSIX_TIMERS3535+3636+/**3737+ * posix_cputimer_base - Container per posix CPU clock3838+ * @nextevt: Earliest-expiration cache3939+ * @tqhead: timerqueue head for cpu_timers4040+ */4141+struct posix_cputimer_base {4242+ u64 nextevt;4343+ struct timerqueue_head tqhead;4444+};4545+4646+/**4747+ * posix_cputimers - Container for posix CPU timer related data4848+ * @bases: Base container for posix CPU clocks4949+ * @timers_active: Timers are queued.5050+ * @expiry_active: Timer expiry is active. Used for5151+ * process wide timers to avoid multiple5252+ * task trying to handle expiry concurrently5353+ *5454+ * Used in task_struct and signal_struct5555+ */5656+struct posix_cputimers {5757+ struct posix_cputimer_base bases[CPUCLOCK_MAX];5858+ unsigned int timers_active;5959+ unsigned int expiry_active;6060+};6161+6262+/**6363+ * posix_cputimers_work - Container for task work based posix CPU timer expiry6464+ * @work: The task work to be scheduled6565+ * @mutex: Mutex held around expiry in context of this task work6666+ * @scheduled: @work has been scheduled already, no further processing6767+ */6868+struct posix_cputimers_work {6969+ struct callback_head work;7070+ struct mutex mutex;7171+ unsigned int scheduled;7272+};7373+7474+#else /* CONFIG_POSIX_TIMERS */7575+7676+struct posix_cputimers { };7777+7878+#endif /* CONFIG_POSIX_TIMERS */7979+8080+#endif /* _linux_POSIX_TIMERS_TYPES_H */