Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 234542
b: refs/heads/master
c: 70a89a6
h: refs/heads/master
v: v3
  • Loading branch information
Venkatesh Pallipadi authored and Ingo Molnar committed Jan 26, 2011
1 parent 2cb1080 commit 8c23ee9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a1dabb6bfffccb897eff3e1d102dacf2a4bedf3b
refs/heads/master: 70a89a6620f658d47a1488515bada4b8ee6291d8
46 changes: 31 additions & 15 deletions trunk/kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -3567,6 +3567,32 @@ static void account_guest_time(struct task_struct *p, cputime_t cputime,
}
}

/*
* Account system cpu time to a process and desired cpustat field
* @p: the process that the cpu time gets accounted to
* @cputime: the cpu time spent in kernel space since the last update
* @cputime_scaled: cputime scaled by cpu frequency
* @target_cputime64: pointer to cpustat field that has to be updated
*/
static inline
void __account_system_time(struct task_struct *p, cputime_t cputime,
cputime_t cputime_scaled, cputime64_t *target_cputime64)
{
cputime64_t tmp = cputime_to_cputime64(cputime);

/* Add system time to process. */
p->stime = cputime_add(p->stime, cputime);
p->stimescaled = cputime_add(p->stimescaled, cputime_scaled);
account_group_system_time(p, cputime);

/* Add system time to cpustat. */
*target_cputime64 = cputime64_add(*target_cputime64, tmp);
cpuacct_update_stats(p, CPUACCT_STAT_SYSTEM, cputime);

/* Account for system time used */
acct_update_integrals(p);
}

/*
* Account system cpu time to a process.
* @p: the process that the cpu time gets accounted to
Expand All @@ -3578,31 +3604,21 @@ void account_system_time(struct task_struct *p, int hardirq_offset,
cputime_t cputime, cputime_t cputime_scaled)
{
struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat;
cputime64_t tmp;
cputime64_t *target_cputime64;

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

/* Add system time to process. */
p->stime = cputime_add(p->stime, cputime);
p->stimescaled = cputime_add(p->stimescaled, cputime_scaled);
account_group_system_time(p, cputime);

/* Add system time to cpustat. */
tmp = cputime_to_cputime64(cputime);
if (hardirq_count() - hardirq_offset)
cpustat->irq = cputime64_add(cpustat->irq, tmp);
target_cputime64 = &cpustat->irq;
else if (in_serving_softirq())
cpustat->softirq = cputime64_add(cpustat->softirq, tmp);
target_cputime64 = &cpustat->softirq;
else
cpustat->system = cputime64_add(cpustat->system, tmp);
target_cputime64 = &cpustat->system;

cpuacct_update_stats(p, CPUACCT_STAT_SYSTEM, cputime);

/* Account for system time used */
acct_update_integrals(p);
__account_system_time(p, cputime, cputime_scaled, target_cputime64);
}

/*
Expand Down

0 comments on commit 8c23ee9

Please sign in to comment.