예제 #1
0
파일: time.c 프로젝트: OpenChannelSSD/linux
void vtime_flush(struct task_struct *tsk)
{
	struct thread_info *ti = task_thread_info(tsk);
	u64 delta;

	if (ti->utime)
		account_user_time(tsk, cycle_to_nsec(ti->utime));

	if (ti->gtime)
		account_guest_time(tsk, cycle_to_nsec(ti->gtime));

	if (ti->idle_time)
		account_idle_time(cycle_to_nsec(ti->idle_time));

	if (ti->stime) {
		delta = cycle_to_nsec(ti->stime);
		account_system_index_time(tsk, delta, CPUTIME_SYSTEM);
	}

	if (ti->hardirq_time) {
		delta = cycle_to_nsec(ti->hardirq_time);
		account_system_index_time(tsk, delta, CPUTIME_IRQ);
	}

	if (ti->softirq_time) {
		delta = cycle_to_nsec(ti->softirq_time);
		account_system_index_time(tsk, delta, CPUTIME_SOFTIRQ);
	}

	ti->utime = 0;
	ti->gtime = 0;
	ti->idle_time = 0;
	ti->stime = 0;
	ti->hardirq_time = 0;
	ti->softirq_time = 0;
}
예제 #2
0
/*
 * Account system cpu time to a process.
 * @p: the process that the cpu time gets accounted to
 * @hardirq_offset: the offset to subtract from hardirq_count()
 * @cputime: the cpu time spent in kernel space since the last update
 */
void account_system_time(struct task_struct *p, int hardirq_offset, u64 cputime)
{
	int index;

	if ((p->flags & PF_VCPU) && (irq_count() - hardirq_offset == 0)) {
		account_guest_time(p, cputime);
		return;
	}

	if (hardirq_count() - hardirq_offset)
		index = CPUTIME_IRQ;
	else if (in_serving_softirq())
		index = CPUTIME_SOFTIRQ;
	else
		index = CPUTIME_SYSTEM;

	account_system_index_time(p, cputime, index);
}