posix-cpu-timers: Move expiry cache into struct posix_cputimers
The expiry cache belongs into the posix_cputimers container where the other cpu timers information is. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Frederic Weisbecker <frederic@kernel.org> Link: https://lkml.kernel.org/r/20190821192921.014444012@linutronix.de
This commit is contained in:
@@ -1527,12 +1527,9 @@ static void posix_cpu_timers_init_group(struct signal_struct *sig)
|
||||
unsigned long cpu_limit;
|
||||
|
||||
cpu_limit = READ_ONCE(sig->rlim[RLIMIT_CPU].rlim_cur);
|
||||
if (cpu_limit != RLIM_INFINITY) {
|
||||
sig->cputime_expires.prof_exp = cpu_limit * NSEC_PER_SEC;
|
||||
posix_cputimers_group_init(pct, cpu_limit);
|
||||
if (cpu_limit != RLIM_INFINITY)
|
||||
sig->cputimer.running = true;
|
||||
}
|
||||
|
||||
posix_cputimers_init(pct);
|
||||
}
|
||||
#else
|
||||
static inline void posix_cpu_timers_init_group(struct signal_struct *sig) { }
|
||||
@@ -1638,22 +1635,6 @@ static void rt_mutex_init_task(struct task_struct *p)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef CONFIG_POSIX_TIMERS
|
||||
/*
|
||||
* Initialize POSIX timer handling for a single task.
|
||||
*/
|
||||
static void posix_cpu_timers_init(struct task_struct *tsk)
|
||||
{
|
||||
tsk->cputime_expires.prof_exp = 0;
|
||||
tsk->cputime_expires.virt_exp = 0;
|
||||
tsk->cputime_expires.sched_exp = 0;
|
||||
|
||||
posix_cputimers_init(&tsk->posix_cputimers);
|
||||
}
|
||||
#else
|
||||
static inline void posix_cpu_timers_init(struct task_struct *tsk) { }
|
||||
#endif
|
||||
|
||||
static inline void init_task_pid_links(struct task_struct *task)
|
||||
{
|
||||
enum pid_type type;
|
||||
@@ -1932,7 +1913,7 @@ static __latent_entropy struct task_struct *copy_process(
|
||||
task_io_accounting_init(&p->ioac);
|
||||
acct_clear_integrals(p);
|
||||
|
||||
posix_cpu_timers_init(p);
|
||||
posix_cputimers_init(&p->posix_cputimers);
|
||||
|
||||
p->io_context = NULL;
|
||||
audit_set_context(p, NULL);
|
||||
|
||||
@@ -2305,8 +2305,10 @@ static void watchdog(struct rq *rq, struct task_struct *p)
|
||||
}
|
||||
|
||||
next = DIV_ROUND_UP(min(soft, hard), USEC_PER_SEC/HZ);
|
||||
if (p->rt.timeout > next)
|
||||
p->cputime_expires.sched_exp = p->se.sum_exec_runtime;
|
||||
if (p->rt.timeout > next) {
|
||||
posix_cputimers_rt_watchdog(&p->posix_cputimers,
|
||||
p->se.sum_exec_runtime);
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
||||
@@ -20,11 +20,18 @@
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
* Called after updating RLIMIT_CPU to run cpu timer and update
|
||||
* tsk->signal->cputime_expires expiration cache if necessary. Needs
|
||||
* siglock protection since other code may update expiration cache as
|
||||
* well.
|
||||
* tsk->signal->posix_cputimers.cputime_expires expiration cache if
|
||||
* necessary. Needs siglock protection since other code may update
|
||||
* expiration cache as well.
|
||||
*/
|
||||
void update_rlimit_cpu(struct task_struct *task, unsigned long rlim_new)
|
||||
{
|
||||
@@ -447,10 +454,10 @@ static void arm_timer(struct k_itimer *timer)
|
||||
|
||||
if (CPUCLOCK_PERTHREAD(timer->it_clock)) {
|
||||
head = p->posix_cputimers.cpu_timers;
|
||||
cputime_expires = &p->cputime_expires;
|
||||
cputime_expires = &p->posix_cputimers.cputime_expires;
|
||||
} else {
|
||||
head = p->signal->posix_cputimers.cpu_timers;
|
||||
cputime_expires = &p->signal->cputime_expires;
|
||||
cputime_expires = &p->signal->posix_cputimers.cputime_expires;
|
||||
}
|
||||
head += CPUCLOCK_WHICH(timer->it_clock);
|
||||
|
||||
@@ -774,7 +781,7 @@ static void check_thread_timers(struct task_struct *tsk,
|
||||
struct list_head *firing)
|
||||
{
|
||||
struct list_head *timers = tsk->posix_cputimers.cpu_timers;
|
||||
struct task_cputime *tsk_expires = &tsk->cputime_expires;
|
||||
struct task_cputime *tsk_expires = &tsk->posix_cputimers.cputime_expires;
|
||||
u64 expires, stime, utime;
|
||||
unsigned long soft;
|
||||
|
||||
@@ -785,7 +792,7 @@ static void check_thread_timers(struct task_struct *tsk,
|
||||
* If cputime_expires is zero, then there are no active
|
||||
* per thread CPU timers.
|
||||
*/
|
||||
if (task_cputime_zero(&tsk->cputime_expires))
|
||||
if (task_cputime_zero(tsk_expires))
|
||||
return;
|
||||
|
||||
task_cputime(tsk, &utime, &stime);
|
||||
@@ -954,10 +961,10 @@ static void check_process_timers(struct task_struct *tsk,
|
||||
prof_expires = x;
|
||||
}
|
||||
|
||||
sig->cputime_expires.prof_exp = prof_expires;
|
||||
sig->cputime_expires.virt_exp = virt_expires;
|
||||
sig->cputime_expires.sched_exp = sched_expires;
|
||||
if (task_cputime_zero(&sig->cputime_expires))
|
||||
sig->posix_cputimers.cputime_expires.prof_exp = prof_expires;
|
||||
sig->posix_cputimers.cputime_expires.virt_exp = virt_expires;
|
||||
sig->posix_cputimers.cputime_expires.sched_exp = sched_expires;
|
||||
if (task_cputime_zero(&sig->posix_cputimers.cputime_expires))
|
||||
stop_process_timers(sig);
|
||||
|
||||
sig->cputimer.checking_timer = false;
|
||||
@@ -1058,12 +1065,13 @@ static inline int fastpath_timer_check(struct task_struct *tsk)
|
||||
{
|
||||
struct signal_struct *sig;
|
||||
|
||||
if (!task_cputime_zero(&tsk->cputime_expires)) {
|
||||
if (!task_cputime_zero(&tsk->posix_cputimers.cputime_expires)) {
|
||||
struct task_cputime task_sample;
|
||||
|
||||
task_cputime(tsk, &task_sample.utime, &task_sample.stime);
|
||||
task_sample.sum_exec_runtime = tsk->se.sum_exec_runtime;
|
||||
if (task_cputime_expired(&task_sample, &tsk->cputime_expires))
|
||||
if (task_cputime_expired(&task_sample,
|
||||
&tsk->posix_cputimers.cputime_expires))
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1088,7 +1096,8 @@ static inline int fastpath_timer_check(struct task_struct *tsk)
|
||||
|
||||
sample_cputime_atomic(&group_sample, &sig->cputimer.cputime_atomic);
|
||||
|
||||
if (task_cputime_expired(&group_sample, &sig->cputime_expires))
|
||||
if (task_cputime_expired(&group_sample,
|
||||
&sig->posix_cputimers.cputime_expires))
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1204,12 +1213,12 @@ void set_process_cpu_timer(struct task_struct *tsk, unsigned int clock_idx,
|
||||
*/
|
||||
switch (clock_idx) {
|
||||
case CPUCLOCK_PROF:
|
||||
if (expires_gt(tsk->signal->cputime_expires.prof_exp, *newval))
|
||||
tsk->signal->cputime_expires.prof_exp = *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->cputime_expires.virt_exp, *newval))
|
||||
tsk->signal->cputime_expires.virt_exp = *newval;
|
||||
if (expires_gt(tsk->signal->posix_cputimers.cputime_expires.virt_exp, *newval))
|
||||
tsk->signal->posix_cputimers.cputime_expires.virt_exp = *newval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user