summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/linux/posix-timers.h24
-rw-r--r--include/linux/sched/types.h4
-rw-r--r--kernel/time/posix-cpu-timers.c12
3 files changed, 31 insertions, 9 deletions
diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
index a3731ba15bce..ed0f6ec30aa6 100644
--- a/include/linux/posix-timers.h
+++ b/include/linux/posix-timers.h
@@ -65,27 +65,39 @@ static inline int clockid_to_fd(const clockid_t clk)
/*
* Alternate field names for struct task_cputime when used on cache
* expirations. Will go away soon.
+ *
+ * stime corresponds to CLOCKCPU_PROF
+ * utime corresponds to CLOCKCPU_VIRT
+ * sum_exex_runtime corresponds to CLOCKCPU_SCHED
+ *
+ * The ordering is currently enforced so struct task_cputime and the
+ * expiries array in struct posix_cputimers are equivalent.
*/
-#define virt_exp utime
#define prof_exp stime
+#define virt_exp utime
#define sched_exp sum_exec_runtime
#ifdef CONFIG_POSIX_TIMERS
/**
* posix_cputimers - Container for posix CPU timer related data
- * @cputime_expires: Earliest-expiration cache
+ * @cputime_expires: Earliest-expiration cache task_cputime based
+ * @expiries: Earliest-expiration cache array based
* @cpu_timers: List heads to queue posix CPU timers
*
* Used in task_struct and signal_struct
*/
struct posix_cputimers {
- struct task_cputime cputime_expires;
- struct list_head cpu_timers[CPUCLOCK_MAX];
+ /* Temporary union until all users are cleaned up */
+ union {
+ struct task_cputime cputime_expires;
+ u64 expiries[CPUCLOCK_MAX];
+ };
+ struct list_head cpu_timers[CPUCLOCK_MAX];
};
static inline void posix_cputimers_init(struct posix_cputimers *pct)
{
- memset(&pct->cputime_expires, 0, sizeof(pct->cputime_expires));
+ memset(&pct->expiries, 0, sizeof(pct->expiries));
INIT_LIST_HEAD(&pct->cpu_timers[0]);
INIT_LIST_HEAD(&pct->cpu_timers[1]);
INIT_LIST_HEAD(&pct->cpu_timers[2]);
@@ -96,7 +108,7 @@ 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->expiries[CPUCLOCK_SCHED] = runtime;
}
/* Init task static initializer */
diff --git a/include/linux/sched/types.h b/include/linux/sched/types.h
index 2c5c28ddd9b2..3c3e049224ae 100644
--- a/include/linux/sched/types.h
+++ b/include/linux/sched/types.h
@@ -6,8 +6,8 @@
/**
* struct task_cputime - collected CPU time counts
- * @utime: time spent in user mode, in nanoseconds
* @stime: time spent in kernel mode, in nanoseconds
+ * @utime: time spent in user mode, in nanoseconds
* @sum_exec_runtime: total time spent on the CPU, in nanoseconds
*
* This structure groups together three kinds of CPU time that are tracked for
@@ -15,8 +15,8 @@
* these counts together and treat all three of them in parallel.
*/
struct task_cputime {
- u64 utime;
u64 stime;
+ u64 utime;
unsigned long long sum_exec_runtime;
};
diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
index 3e29d1692437..a38b6d04e8b5 100644
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -18,13 +18,23 @@
#include "posix-timers.h"
+static inline void temporary_check(void)
+{
+ BUILD_BUG_ON(offsetof(struct task_cputime, stime) !=
+ CPUCLOCK_PROF * sizeof(u64));
+ BUILD_BUG_ON(offsetof(struct task_cputime, utime) !=
+ CPUCLOCK_VIRT * sizeof(u64));
+ BUILD_BUG_ON(offsetof(struct task_cputime, sum_exec_runtime) !=
+ CPUCLOCK_SCHED * sizeof(u64));
+}
+
static void posix_cpu_timer_rearm(struct k_itimer *timer);
void posix_cputimers_group_init(struct posix_cputimers *pct, u64 cpu_limit)
{
posix_cputimers_init(pct);
if (cpu_limit != RLIM_INFINITY)
- pct->cputime_expires.prof_exp = cpu_limit * NSEC_PER_SEC;
+ pct->expiries[CPUCLOCK_PROF] = cpu_limit * NSEC_PER_SEC;
}
/*