memset(&r, 0, sizeof(r));
switch (who) {
case RUSAGE_SELF:
- task_cputime(current, &utime, &stime);
+ task_cputime_t(current, &utime, &stime);
utime_jiffies = cputime_to_jiffies(utime);
stime_jiffies = cputime_to_jiffies(stime);
jiffies_to_timeval32(utime_jiffies, &r.ru_utime);
unsigned int bucket;
recalc:
- task_cputime(current, &utime, &stime);
+ task_cputime_t(current, &utime, &stime);
if (jiffies_since_last_check > IDLE_CALC_LIMIT) {
use_apm_idle = 0;
} else if (jiffies_since_last_check > idle_period) {
"msg %d sleep %d stopped\n",
dev_name(&st->dev->dev), st->msg_cnt, st->sleep_cnt,
st->stopped_cnt);
- task_cputime(st->thread, &utime, &stime);
+ task_cputime_t(st->thread, &utime, &stime);
printk(KERN_DEBUG
"mISDNStackd daemon for %s utime(%ld) stime(%ld)\n",
dev_name(&st->dev->dev), utime, stime);
prstatus->pr_pgrp = task_pgrp_vnr(p);
prstatus->pr_sid = task_session_vnr(p);
if (thread_group_leader(p)) {
- struct task_cputime cputime;
+ struct task_cputime_t cputime;
/*
* This is the record for the group leader. It shows the
* group-wide total, not its individual thread total.
*/
- thread_group_cputime(p, &cputime);
+ thread_group_cputime_t(p, &cputime);
cputime_to_timeval(cputime.utime, &prstatus->pr_utime);
cputime_to_timeval(cputime.stime, &prstatus->pr_stime);
} else {
cputime_t utime, stime;
- task_cputime(p, &utime, &stime);
+ task_cputime_t(p, &utime, &stime);
cputime_to_timeval(utime, &prstatus->pr_utime);
cputime_to_timeval(stime, &prstatus->pr_stime);
}
prstatus->pr_pgrp = task_pgrp_vnr(p);
prstatus->pr_sid = task_session_vnr(p);
if (thread_group_leader(p)) {
- struct task_cputime cputime;
+ struct task_cputime_t cputime;
/*
* This is the record for the group leader. It shows the
* group-wide total, not its individual thread total.
*/
- thread_group_cputime(p, &cputime);
+ thread_group_cputime_t(p, &cputime);
cputime_to_timeval(cputime.utime, &prstatus->pr_utime);
cputime_to_timeval(cputime.stime, &prstatus->pr_stime);
} else {
cputime_t utime, stime;
- task_cputime(p, &utime, &stime);
+ task_cputime_t(p, &utime, &stime);
cputime_to_timeval(utime, &prstatus->pr_utime);
cputime_to_timeval(stime, &prstatus->pr_stime);
}
unsigned long long sum_exec_runtime;
};
+/* Temporary type to ease cputime_t to nsecs conversion */
+struct task_cputime_t {
+ cputime_t utime;
+ cputime_t stime;
+ unsigned long long sum_exec_runtime;
+};
+
/* Alternate field names when used to cache expirations. */
#define virt_exp utime
#define prof_exp stime
struct thread_group_cputimer cputimer;
/* Earliest-expiration cache. */
- struct task_cputime cputime_expires;
+ struct task_cputime_t cputime_expires;
#ifdef CONFIG_NO_HZ_FULL
atomic_t tick_dep_mask;
/* mm fault and swap info: this can arguably be seen as either mm-specific or thread-specific */
unsigned long min_flt, maj_flt;
- struct task_cputime cputime_expires;
+ struct task_cputime_t cputime_expires;
struct list_head cpu_timers[3];
/* process credentials */
}
#endif
+static inline void task_cputime_t(struct task_struct *t,
+ cputime_t *utime, cputime_t *stime)
+{
+ task_cputime(t, utime, stime);
+}
+
+static inline void task_cputime_t_scaled(struct task_struct *t,
+ cputime_t *utimescaled,
+ cputime_t *stimescaled)
+{
+ task_cputime_scaled(t, utimescaled, stimescaled);
+}
+
extern void task_cputime_adjusted(struct task_struct *p, cputime_t *ut, cputime_t *st);
extern void thread_group_cputime_adjusted(struct task_struct *p, cputime_t *ut, cputime_t *st);
* Thread group CPU time accounting.
*/
void thread_group_cputime(struct task_struct *tsk, struct task_cputime *times);
-void thread_group_cputimer(struct task_struct *tsk, struct task_cputime *times);
+void thread_group_cputimer(struct task_struct *tsk, struct task_cputime_t *times);
+
+static inline void thread_group_cputime_t(struct task_struct *tsk,
+ struct task_cputime_t *times)
+{
+ thread_group_cputime(tsk, (struct task_cputime *)times);
+}
/*
* Reevaluate whether the task has signals pending delivery.
pacct->ac_flag |= ACORE;
if (current->flags & PF_SIGNALED)
pacct->ac_flag |= AXSIG;
- task_cputime(current, &utime, &stime);
+ task_cputime_t(current, &utime, &stime);
pacct->ac_utime += utime;
pacct->ac_stime += stime;
pacct->ac_minflt += current->min_flt;
unsigned long flags, t1;
s64 tmp;
- task_cputime(tsk, &utime, &stime);
+ task_cputime_t(tsk, &utime, &stime);
tmp = (s64)d->cpu_run_real_total;
tmp += cputime_to_nsecs(utime + stime);
d->cpu_run_real_total = (tmp < (s64)d->cpu_run_real_total) ? 0 : tmp;
- task_cputime_scaled(tsk, &utimescaled, &stimescaled);
+ task_cputime_t_scaled(tsk, &utimescaled, &stimescaled);
tmp = (s64)d->cpu_scaled_run_real_total;
tmp += cputime_to_nsecs(utimescaled + stimescaled);
d->cpu_scaled_run_real_total =
task_uid(tsk));
rcu_read_unlock();
- task_cputime(tsk, &utime, &stime);
+ task_cputime_t(tsk, &utime, &stime);
info.si_utime = cputime_to_clock_t(utime + tsk->signal->utime);
info.si_stime = cputime_to_clock_t(stime + tsk->signal->stime);
info.si_uid = from_kuid_munged(task_cred_xxx(parent, user_ns), task_uid(tsk));
rcu_read_unlock();
- task_cputime(tsk, &utime, &stime);
+ task_cputime_t(tsk, &utime, &stime);
info.si_utime = cputime_to_clock_t(utime);
info.si_stime = cputime_to_clock_t(stime);
cval = it->expires;
cinterval = it->incr;
if (cval) {
- struct task_cputime cputime;
+ struct task_cputime_t cputime;
cputime_t t;
thread_group_cputimer(tsk, &cputime);
* Checks @cputime to see if all fields are zero. Returns true if all fields
* are zero, false if any field is nonzero.
*/
-static inline int task_cputime_zero(const struct task_cputime *cputime)
+static inline int task_cputime_zero(const struct task_cputime_t *cputime)
{
if (!cputime->utime && !cputime->stime && !cputime->sum_exec_runtime)
return 1;
{
cputime_t utime, stime;
- task_cputime(p, &utime, &stime);
+ task_cputime_t(p, &utime, &stime);
return cputime_to_expires(utime + stime);
}
{
cputime_t utime, stime;
- task_cputime(p, &utime, &stime);
+ task_cputime_t(p, &utime, &stime);
return cputime_to_expires(utime);
}
}
}
-static void update_gt_cputime(struct task_cputime_atomic *cputime_atomic, struct task_cputime *sum)
+static void update_gt_cputime(struct task_cputime_atomic *cputime_atomic, struct task_cputime_t *sum)
{
__update_gt_cputime(&cputime_atomic->utime, sum->utime);
__update_gt_cputime(&cputime_atomic->stime, sum->stime);
}
/* Sample task_cputime_atomic values in "atomic_timers", store results in "times". */
-static inline void sample_cputime_atomic(struct task_cputime *times,
+static inline void sample_cputime_atomic(struct task_cputime_t *times,
struct task_cputime_atomic *atomic_times)
{
times->utime = atomic64_read(&atomic_times->utime);
times->sum_exec_runtime = atomic64_read(&atomic_times->sum_exec_runtime);
}
-void thread_group_cputimer(struct task_struct *tsk, struct task_cputime *times)
+void thread_group_cputimer(struct task_struct *tsk, struct task_cputime_t *times)
{
struct thread_group_cputimer *cputimer = &tsk->signal->cputimer;
- struct task_cputime sum;
+ struct task_cputime_t sum;
/* Check if cputimer isn't running. This is accessed without locking. */
if (!READ_ONCE(cputimer->running)) {
* values through the TIMER_ABSTIME flag, therefore we have
* to synchronize the timer to the clock every time we start it.
*/
- thread_group_cputime(tsk, &sum);
+ thread_group_cputime_t(tsk, &sum);
update_gt_cputime(&cputimer->cputime_atomic, &sum);
/*
struct task_struct *p,
unsigned long long *sample)
{
- struct task_cputime cputime;
+ struct task_cputime_t cputime;
switch (CPUCLOCK_WHICH(which_clock)) {
default:
return -EINVAL;
case CPUCLOCK_PROF:
- thread_group_cputime(p, &cputime);
+ thread_group_cputime_t(p, &cputime);
*sample = cputime_to_expires(cputime.utime + cputime.stime);
break;
case CPUCLOCK_VIRT:
- thread_group_cputime(p, &cputime);
+ thread_group_cputime_t(p, &cputime);
*sample = cputime_to_expires(cputime.utime);
break;
case CPUCLOCK_SCHED:
- thread_group_cputime(p, &cputime);
+ thread_group_cputime_t(p, &cputime);
*sample = cputime.sum_exec_runtime;
break;
}
{
struct task_struct *p = timer->it.cpu.task;
struct list_head *head, *listpos;
- struct task_cputime *cputime_expires;
+ struct task_cputime_t *cputime_expires;
struct cpu_timer_list *const nt = &timer->it.cpu;
struct cpu_timer_list *next;
struct task_struct *p,
unsigned long long *sample)
{
- struct task_cputime cputime;
+ struct task_cputime_t cputime;
thread_group_cputimer(p, &cputime);
switch (CPUCLOCK_WHICH(which_clock)) {
/*
* Protect against sighand release/switch in exit/exec and
* also make timer sampling safe if it ends up calling
- * thread_group_cputime().
+ * thread_group_cputime_t().
*/
sighand = lock_task_sighand(p, &flags);
if (unlikely(sighand == NULL)) {
{
struct list_head *timers = tsk->cpu_timers;
struct signal_struct *const sig = tsk->signal;
- struct task_cputime *tsk_expires = &tsk->cputime_expires;
+ struct task_cputime_t *tsk_expires = &tsk->cputime_expires;
unsigned long long expires;
unsigned long soft;
unsigned long long utime, ptime, virt_expires, prof_expires;
unsigned long long sum_sched_runtime, sched_expires;
struct list_head *timers = sig->cpu_timers;
- struct task_cputime cputime;
+ struct task_cputime_t cputime;
unsigned long soft;
/*
} else {
/*
* Protect arm_timer() and timer sampling in case of call to
- * thread_group_cputime().
+ * thread_group_cputime_t().
*/
sighand = lock_task_sighand(p, &flags);
if (unlikely(sighand == NULL)) {
* Returns true if any field of the former is greater than the corresponding
* field of the latter if the latter field is set. Otherwise returns false.
*/
-static inline int task_cputime_expired(const struct task_cputime *sample,
- const struct task_cputime *expires)
+static inline int task_cputime_expired(const struct task_cputime_t *sample,
+ const struct task_cputime_t *expires)
{
if (expires->utime && sample->utime >= expires->utime)
return 1;
struct signal_struct *sig;
if (!task_cputime_zero(&tsk->cputime_expires)) {
- struct task_cputime task_sample;
+ struct task_cputime_t task_sample;
- task_cputime(tsk, &task_sample.utime, &task_sample.stime);
+ task_cputime_t(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))
return 1;
*/
if (READ_ONCE(sig->cputimer.running) &&
!READ_ONCE(sig->cputimer.checking_timer)) {
- struct task_cputime group_sample;
+ struct task_cputime_t group_sample;
sample_cputime_atomic(&group_sample, &sig->cputimer.cputime_atomic);
task_tgid_nr_ns(rcu_dereference(tsk->real_parent), pid_ns) : 0;
rcu_read_unlock();
- task_cputime(tsk, &utime, &stime);
+ task_cputime_t(tsk, &utime, &stime);
stats->ac_utime = cputime_to_usecs(utime);
stats->ac_stime = cputime_to_usecs(stime);
- task_cputime_scaled(tsk, &utimescaled, &stimescaled);
+ task_cputime_t_scaled(tsk, &utimescaled, &stimescaled);
stats->ac_utimescaled = cputime_to_usecs(utimescaled);
stats->ac_stimescaled = cputime_to_usecs(stimescaled);
unsigned long flags;
local_irq_save(flags);
- task_cputime(tsk, &utime, &stime);
+ task_cputime_t(tsk, &utime, &stime);
__acct_update_integrals(tsk, utime, stime);
local_irq_restore(flags);
}