posix-cpu-timers: Move state tracking to struct posix_cputimers
[sfrench/cifs-2.6.git] / include / linux / posix-timers.h
index a3731ba15bce49f2f0e31514afbdcd00f0f0db74..a9e3f69d2db4d1c08d97b740f227ab1d31169cca 100644 (file)
@@ -62,33 +62,44 @@ static inline int clockid_to_fd(const clockid_t clk)
        return ~(clk >> 3);
 }
 
-/*
- * Alternate field names for struct task_cputime when used on cache
- * expirations. Will go away soon.
+#ifdef CONFIG_POSIX_TIMERS
+
+/**
+ * posix_cputimer_base - Container per posix CPU clock
+ * @nextevt:           Earliest-expiration cache
+ * @cpu_timers:                List heads to queue posix CPU timers
  */
-#define virt_exp                       utime
-#define prof_exp                       stime
-#define sched_exp                      sum_exec_runtime
+struct posix_cputimer_base {
+       u64                     nextevt;
+       struct list_head        cpu_timers;
+};
 
-#ifdef CONFIG_POSIX_TIMERS
 /**
  * posix_cputimers - Container for posix CPU timer related data
- * @cputime_expires:   Earliest-expiration cache
- * @cpu_timers:                List heads to queue posix CPU timers
+ * @bases:             Base container for posix CPU clocks
+ * @timers_active:     Timers are queued.
+ * @expiry_active:     Timer expiry is active. Used for
+ *                     process wide timers to avoid multiple
+ *                     task trying to handle expiry concurrently
  *
  * Used in task_struct and signal_struct
  */
 struct posix_cputimers {
-       struct task_cputime     cputime_expires;
-       struct list_head        cpu_timers[CPUCLOCK_MAX];
+       struct posix_cputimer_base      bases[CPUCLOCK_MAX];
+       unsigned int                    timers_active;
+       unsigned int                    expiry_active;
 };
 
 static inline void posix_cputimers_init(struct posix_cputimers *pct)
 {
-       memset(&pct->cputime_expires, 0, sizeof(pct->cputime_expires));
-       INIT_LIST_HEAD(&pct->cpu_timers[0]);
-       INIT_LIST_HEAD(&pct->cpu_timers[1]);
-       INIT_LIST_HEAD(&pct->cpu_timers[2]);
+       pct->timers_active = 0;
+       pct->expiry_active = 0;
+       pct->bases[0].nextevt = U64_MAX;
+       pct->bases[1].nextevt = U64_MAX;
+       pct->bases[2].nextevt = U64_MAX;
+       INIT_LIST_HEAD(&pct->bases[0].cpu_timers);
+       INIT_LIST_HEAD(&pct->bases[1].cpu_timers);
+       INIT_LIST_HEAD(&pct->bases[2].cpu_timers);
 }
 
 void posix_cputimers_group_init(struct posix_cputimers *pct, u64 cpu_limit);
@@ -96,19 +107,24 @@ void posix_cputimers_group_init(struct posix_cputimers *pct, u64 cpu_limit);
 static inline void posix_cputimers_rt_watchdog(struct posix_cputimers *pct,
                                               u64 runtime)
 {
-       pct->cputime_expires.sched_exp = runtime;
+       pct->bases[CPUCLOCK_SCHED].nextevt = runtime;
 }
 
 /* Init task static initializer */
-#define INIT_CPU_TIMERLISTS(c) {                                       \
-       LIST_HEAD_INIT(c.cpu_timers[0]),                                \
-       LIST_HEAD_INIT(c.cpu_timers[1]),                                \
-       LIST_HEAD_INIT(c.cpu_timers[2]),                                \
+#define INIT_CPU_TIMERBASE(b) {                                                \
+       .nextevt        = U64_MAX,                                      \
+       .cpu_timers     = LIST_HEAD_INIT(b.cpu_timers),                 \
+}
+
+#define INIT_CPU_TIMERBASES(b) {                                       \
+       INIT_CPU_TIMERBASE(b[0]),                                       \
+       INIT_CPU_TIMERBASE(b[1]),                                       \
+       INIT_CPU_TIMERBASE(b[2]),                                       \
 }
 
 #define INIT_CPU_TIMERS(s)                                             \
        .posix_cputimers = {                                            \
-               .cpu_timers = INIT_CPU_TIMERLISTS(s.posix_cputimers),   \
+               .bases = INIT_CPU_TIMERBASES(s.posix_cputimers.bases),  \
        },
 #else
 struct posix_cputimers { };