Esempio n. 1
0
static cputime_t get_vtime_delta(struct task_struct *tsk)
{
    unsigned long long delta = vtime_delta(tsk);

    WARN_ON_ONCE(tsk->vtime_snap_whence == VTIME_SLEEPING);
    tsk->vtime_snap += delta;

    /* CHECKME: always safe to convert nsecs to cputime? */
    return nsecs_to_cputime(delta);
}
Esempio n. 2
0
void vtime_account_system(struct task_struct *tsk)
{
	struct thread_info *ti = task_thread_info(tsk);
	__u64 stime = vtime_delta(tsk);

	if ((tsk->flags & PF_VCPU) && !irq_count())
		ti->gtime += stime;
	else if (hardirq_count())
		ti->hardirq_time += stime;
	else if (in_serving_softirq())
		ti->softirq_time += stime;
	else
		ti->stime += stime;
}
Esempio n. 3
0
cputime_t task_gtime(struct task_struct *t)
{
    unsigned int seq;
    cputime_t gtime;

    do {
        seq = read_seqbegin(&t->vtime_seqlock);

        gtime = t->gtime;
        if (t->flags & PF_VCPU)
            gtime += vtime_delta(t);

    } while (read_seqretry(&t->vtime_seqlock, seq));

    return gtime;
}
Esempio n. 4
0
/*
 * Fetch cputime raw values from fields of task_struct and
 * add up the pending nohz execution time since the last
 * cputime snapshot.
 */
static void
fetch_task_cputime(struct task_struct *t,
                   cputime_t *u_dst, cputime_t *s_dst,
                   cputime_t *u_src, cputime_t *s_src,
                   cputime_t *udelta, cputime_t *sdelta)
{
    unsigned int seq;
    unsigned long long delta;

    do {
        *udelta = 0;
        *sdelta = 0;

        seq = read_seqbegin(&t->vtime_seqlock);

        if (u_dst)
            *u_dst = *u_src;
        if (s_dst)
            *s_dst = *s_src;

        /* Task is sleeping, nothing to add */
        if (t->vtime_snap_whence == VTIME_SLEEPING ||
                is_idle_task(t))
            continue;

        delta = vtime_delta(t);

        /*
         * Task runs either in user or kernel space, add pending nohz time to
         * the right place.
         */
        if (t->vtime_snap_whence == VTIME_USER || t->flags & PF_VCPU) {
            *udelta = delta;
        } else {
            if (t->vtime_snap_whence == VTIME_SYS)
                *sdelta = delta;
        }
    } while (read_seqretry(&t->vtime_seqlock, seq));
}
Esempio n. 5
0
void vtime_account_idle(struct task_struct *tsk)
{
	account_idle_time(vtime_delta(tsk));
}
Esempio n. 6
0
void vtime_account_system(struct task_struct *tsk)
{
	cputime_t delta = vtime_delta(tsk);

	account_system_time(tsk, 0, delta, delta);
}
Esempio n. 7
0
void vtime_account_idle(struct task_struct *tsk)
{
	struct thread_info *ti = task_thread_info(tsk);

	ti->idle_time += vtime_delta(tsk);
}