summaryrefslogtreecommitdiff
path: root/kernel/time
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2019-08-21 21:09:07 +0200
committerThomas Gleixner <tglx@linutronix.de>2019-08-28 11:50:35 +0200
commit11b8462f7e1d25f639c88949a2746a9c2667a766 (patch)
tree5d811cd589e5ac6187a91f6773c8d4819dac5d0e /kernel/time
parent3a245c0f110e2bfcf7f2cd2248a29005c78999e3 (diff)
posix-cpu-timers: Provide array based access to expiry cache
Using struct task_cputime for the expiry cache is a pretty odd choice and comes with magic defines to rename the fields for usage in the expiry cache. struct task_cputime is basically a u64 array with 3 members, but it has distinct members. The expiry cache content is different than the content of task_cputime because expiry[PROF] = task_cputime.stime + task_cputime.utime expiry[VIRT] = task_cputime.utime expiry[SCHED] = task_cputime.sum_exec_runtime So there is no direct mapping between task_cputime and the expiry cache and the #define based remapping is just a horrible hack. Having the expiry cache array based allows further simplification of the expiry code. To avoid an all in one cleanup which is hard to review add a temporary anonymous union into struct task_cputime which allows array based access to it. That requires to reorder the members. Add a build time sanity check to validate that the members are at the same place. The union and the build time checks will be removed after conversion. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Frederic Weisbecker <frederic@kernel.org> Link: https://lkml.kernel.org/r/20190821192921.105793824@linutronix.de
Diffstat (limited to 'kernel/time')
-rw-r--r--kernel/time/posix-cpu-timers.c12
1 files changed, 11 insertions, 1 deletions
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;
}
/*