diff options
| -rw-r--r-- | include/linux/sched.h | 1 | ||||
| -rw-r--r-- | kernel/sched.c | 25 |
2 files changed, 26 insertions, 0 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h index fefce22e4c16..228e0a8ce248 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
| @@ -1342,6 +1342,7 @@ static inline void put_task_struct(struct task_struct *t) | |||
| 1342 | #define PF_STARTING 0x00000002 /* being created */ | 1342 | #define PF_STARTING 0x00000002 /* being created */ |
| 1343 | #define PF_EXITING 0x00000004 /* getting shut down */ | 1343 | #define PF_EXITING 0x00000004 /* getting shut down */ |
| 1344 | #define PF_EXITPIDONE 0x00000008 /* pi exit done on shut down */ | 1344 | #define PF_EXITPIDONE 0x00000008 /* pi exit done on shut down */ |
| 1345 | #define PF_VCPU 0x00000010 /* I'm a virtual CPU */ | ||
| 1345 | #define PF_FORKNOEXEC 0x00000040 /* forked but didn't exec */ | 1346 | #define PF_FORKNOEXEC 0x00000040 /* forked but didn't exec */ |
| 1346 | #define PF_SUPERPRIV 0x00000100 /* used super-user privileges */ | 1347 | #define PF_SUPERPRIV 0x00000100 /* used super-user privileges */ |
| 1347 | #define PF_DUMPCORE 0x00000200 /* dumped core */ | 1348 | #define PF_DUMPCORE 0x00000200 /* dumped core */ |
diff --git a/kernel/sched.c b/kernel/sched.c index 9887ca005c50..5a91fe0b5de6 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
| @@ -3303,6 +3303,25 @@ void account_user_time(struct task_struct *p, cputime_t cputime) | |||
| 3303 | } | 3303 | } |
| 3304 | 3304 | ||
| 3305 | /* | 3305 | /* |
| 3306 | * Account guest cpu time to a process. | ||
| 3307 | * @p: the process that the cpu time gets accounted to | ||
| 3308 | * @cputime: the cpu time spent in virtual machine since the last update | ||
| 3309 | */ | ||
| 3310 | void account_guest_time(struct task_struct *p, cputime_t cputime) | ||
| 3311 | { | ||
| 3312 | cputime64_t tmp; | ||
| 3313 | struct cpu_usage_stat *cpustat = &kstat_this_cpu.cpustat; | ||
| 3314 | |||
| 3315 | tmp = cputime_to_cputime64(cputime); | ||
| 3316 | |||
| 3317 | p->utime = cputime_add(p->utime, cputime); | ||
| 3318 | p->gtime = cputime_add(p->gtime, cputime); | ||
| 3319 | |||
| 3320 | cpustat->user = cputime64_add(cpustat->user, tmp); | ||
| 3321 | cpustat->guest = cputime64_add(cpustat->guest, tmp); | ||
| 3322 | } | ||
| 3323 | |||
| 3324 | /* | ||
| 3306 | * Account system cpu time to a process. | 3325 | * Account system cpu time to a process. |
| 3307 | * @p: the process that the cpu time gets accounted to | 3326 | * @p: the process that the cpu time gets accounted to |
| 3308 | * @hardirq_offset: the offset to subtract from hardirq_count() | 3327 | * @hardirq_offset: the offset to subtract from hardirq_count() |
| @@ -3315,6 +3334,12 @@ void account_system_time(struct task_struct *p, int hardirq_offset, | |||
| 3315 | struct rq *rq = this_rq(); | 3334 | struct rq *rq = this_rq(); |
| 3316 | cputime64_t tmp; | 3335 | cputime64_t tmp; |
| 3317 | 3336 | ||
| 3337 | if (p->flags & PF_VCPU) { | ||
| 3338 | account_guest_time(p, cputime); | ||
| 3339 | p->flags &= ~PF_VCPU; | ||
| 3340 | return; | ||
| 3341 | } | ||
| 3342 | |||
| 3318 | p->stime = cputime_add(p->stime, cputime); | 3343 | p->stime = cputime_add(p->stime, cputime); |
| 3319 | 3344 | ||
| 3320 | /* Add system time to cpustat. */ | 3345 | /* Add system time to cpustat. */ |
