Commit 1b0dd96d authored by Thomas Gleixner's avatar Thomas Gleixner

posix-cpu-timers: Simplify set_process_cpu_timer()

The expiry cache can now be accessed as an array. Replace the per clock
checks with a simple comparison of the clock indexed array member.
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Reviewed-by: default avatarFrederic Weisbecker <frederic@kernel.org>
Link: https://lkml.kernel.org/r/20190821192921.303316423@linutronix.de
parent 3b495b22
...@@ -1174,15 +1174,15 @@ void run_posix_cpu_timers(void) ...@@ -1174,15 +1174,15 @@ void run_posix_cpu_timers(void)
* Set one of the process-wide special case CPU timers or RLIMIT_CPU. * Set one of the process-wide special case CPU timers or RLIMIT_CPU.
* The tsk->sighand->siglock must be held by the caller. * The tsk->sighand->siglock must be held by the caller.
*/ */
void set_process_cpu_timer(struct task_struct *tsk, unsigned int clock_idx, void set_process_cpu_timer(struct task_struct *tsk, unsigned int clkid,
u64 *newval, u64 *oldval) u64 *newval, u64 *oldval)
{ {
u64 now; u64 now, *expiry = tsk->signal->posix_cputimers.expiries + clkid;
if (WARN_ON_ONCE(clock_idx >= CPUCLOCK_SCHED)) if (WARN_ON_ONCE(clkid >= CPUCLOCK_SCHED))
return; return;
now = cpu_clock_sample_group(clock_idx, tsk, true); now = cpu_clock_sample_group(clkid, tsk, true);
if (oldval) { if (oldval) {
/* /*
...@@ -1205,19 +1205,11 @@ void set_process_cpu_timer(struct task_struct *tsk, unsigned int clock_idx, ...@@ -1205,19 +1205,11 @@ void set_process_cpu_timer(struct task_struct *tsk, unsigned int clock_idx,
} }
/* /*
* Update expiration cache if we are the earliest timer, or eventually * Update expiration cache if this is the earliest timer. CPUCLOCK_PROF
* RLIMIT_CPU limit is earlier than prof_exp cpu timer expire. * expiry cache is also used by RLIMIT_CPU!.
*/ */
switch (clock_idx) { if (expires_gt(*expiry, *newval))
case CPUCLOCK_PROF: *expiry = *newval;
if (expires_gt(tsk->signal->posix_cputimers.cputime_expires.prof_exp, *newval))
tsk->signal->posix_cputimers.cputime_expires.prof_exp = *newval;
break;
case CPUCLOCK_VIRT:
if (expires_gt(tsk->signal->posix_cputimers.cputime_expires.virt_exp, *newval))
tsk->signal->posix_cputimers.cputime_expires.virt_exp = *newval;
break;
}
tick_dep_set_signal(tsk->signal, TICK_DEP_BIT_POSIX_TIMER); tick_dep_set_signal(tsk->signal, TICK_DEP_BIT_POSIX_TIMER);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment