diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2017-01-30 22:09:39 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2017-02-01 03:13:57 -0500 |
commit | 18b43a9bd7ae91185e398dd983fb4fffb9e81b3a (patch) | |
tree | 6b7b4afb75cb9b6fe0d42ca61fe460ab5ed82e27 | |
parent | be9095ed4fb3cf69e9fdf64e28ff6b5bd0ec7215 (diff) |
sched/cputime: Push time to account_idle_time() in nsecs
This is one more step toward converting cputime accounting to pure nsecs.
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Stanislaw Gruszka <sgruszka@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Wanpeng Li <wanpeng.li@hotmail.com>
Link: http://lkml.kernel.org/r/1485832191-26889-24-git-send-email-fweisbec@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | arch/ia64/kernel/time.c | 2 | ||||
-rw-r--r-- | arch/powerpc/kernel/time.c | 2 | ||||
-rw-r--r-- | arch/s390/kernel/idle.c | 2 | ||||
-rw-r--r-- | include/linux/kernel_stat.h | 2 | ||||
-rw-r--r-- | kernel/sched/cputime.c | 18 |
5 files changed, 13 insertions, 13 deletions
diff --git a/arch/ia64/kernel/time.c b/arch/ia64/kernel/time.c index ed98b26047c2..5dc801d97790 100644 --- a/arch/ia64/kernel/time.c +++ b/arch/ia64/kernel/time.c | |||
@@ -73,7 +73,7 @@ void vtime_flush(struct task_struct *tsk) | |||
73 | account_guest_time(tsk, cycle_to_cputime(ti->gtime)); | 73 | account_guest_time(tsk, cycle_to_cputime(ti->gtime)); |
74 | 74 | ||
75 | if (ti->idle_time) | 75 | if (ti->idle_time) |
76 | account_idle_time(cycle_to_cputime(ti->idle_time)); | 76 | account_idle_time(cputime_to_nsecs(cycle_to_cputime(ti->idle_time))); |
77 | 77 | ||
78 | if (ti->stime) { | 78 | if (ti->stime) { |
79 | delta = cycle_to_cputime(ti->stime); | 79 | delta = cycle_to_cputime(ti->stime); |
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c index 53e5982edacf..739897a10fd3 100644 --- a/arch/powerpc/kernel/time.c +++ b/arch/powerpc/kernel/time.c | |||
@@ -405,7 +405,7 @@ void vtime_flush(struct task_struct *tsk) | |||
405 | account_steal_time(cputime_to_nsecs(acct->steal_time)); | 405 | account_steal_time(cputime_to_nsecs(acct->steal_time)); |
406 | 406 | ||
407 | if (acct->idle_time) | 407 | if (acct->idle_time) |
408 | account_idle_time(acct->idle_time); | 408 | account_idle_time(cputime_to_nsecs(acct->idle_time)); |
409 | 409 | ||
410 | if (acct->stime) | 410 | if (acct->stime) |
411 | account_system_index_time(tsk, acct->stime, CPUTIME_SYSTEM); | 411 | account_system_index_time(tsk, acct->stime, CPUTIME_SYSTEM); |
diff --git a/arch/s390/kernel/idle.c b/arch/s390/kernel/idle.c index 7a55c29b0b33..99f1d8185ae2 100644 --- a/arch/s390/kernel/idle.c +++ b/arch/s390/kernel/idle.c | |||
@@ -43,7 +43,7 @@ void enabled_wait(void) | |||
43 | idle->clock_idle_enter = idle->clock_idle_exit = 0ULL; | 43 | idle->clock_idle_enter = idle->clock_idle_exit = 0ULL; |
44 | idle->idle_time += idle_time; | 44 | idle->idle_time += idle_time; |
45 | idle->idle_count++; | 45 | idle->idle_count++; |
46 | account_idle_time(idle_time); | 46 | account_idle_time(cputime_to_nsecs(idle_time)); |
47 | write_seqcount_end(&idle->seqcount); | 47 | write_seqcount_end(&idle->seqcount); |
48 | } | 48 | } |
49 | NOKPROBE_SYMBOL(enabled_wait); | 49 | NOKPROBE_SYMBOL(enabled_wait); |
diff --git a/include/linux/kernel_stat.h b/include/linux/kernel_stat.h index 1d55d10abf9d..e1cd8970e096 100644 --- a/include/linux/kernel_stat.h +++ b/include/linux/kernel_stat.h | |||
@@ -84,7 +84,7 @@ extern void account_system_time(struct task_struct *, int, cputime_t); | |||
84 | extern void account_system_index_time(struct task_struct *, cputime_t, | 84 | extern void account_system_index_time(struct task_struct *, cputime_t, |
85 | enum cpu_usage_stat); | 85 | enum cpu_usage_stat); |
86 | extern void account_steal_time(u64); | 86 | extern void account_steal_time(u64); |
87 | extern void account_idle_time(cputime_t); | 87 | extern void account_idle_time(u64); |
88 | 88 | ||
89 | #ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE | 89 | #ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE |
90 | static inline void account_process_tick(struct task_struct *tsk, int user) | 90 | static inline void account_process_tick(struct task_struct *tsk, int user) |
diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c index 9a8028760930..fd5375f956fe 100644 --- a/kernel/sched/cputime.c +++ b/kernel/sched/cputime.c | |||
@@ -218,15 +218,15 @@ void account_steal_time(u64 cputime) | |||
218 | * Account for idle time. | 218 | * Account for idle time. |
219 | * @cputime: the cpu time spent in idle wait | 219 | * @cputime: the cpu time spent in idle wait |
220 | */ | 220 | */ |
221 | void account_idle_time(cputime_t cputime) | 221 | void account_idle_time(u64 cputime) |
222 | { | 222 | { |
223 | u64 *cpustat = kcpustat_this_cpu->cpustat; | 223 | u64 *cpustat = kcpustat_this_cpu->cpustat; |
224 | struct rq *rq = this_rq(); | 224 | struct rq *rq = this_rq(); |
225 | 225 | ||
226 | if (atomic_read(&rq->nr_iowait) > 0) | 226 | if (atomic_read(&rq->nr_iowait) > 0) |
227 | cpustat[CPUTIME_IOWAIT] += cputime_to_nsecs(cputime); | 227 | cpustat[CPUTIME_IOWAIT] += cputime; |
228 | else | 228 | else |
229 | cpustat[CPUTIME_IDLE] += cputime_to_nsecs(cputime); | 229 | cpustat[CPUTIME_IDLE] += cputime; |
230 | } | 230 | } |
231 | 231 | ||
232 | /* | 232 | /* |
@@ -392,7 +392,7 @@ static void irqtime_account_process_tick(struct task_struct *p, int user_tick, | |||
392 | } else if (user_tick) { | 392 | } else if (user_tick) { |
393 | account_user_time(p, cputime); | 393 | account_user_time(p, cputime); |
394 | } else if (p == rq->idle) { | 394 | } else if (p == rq->idle) { |
395 | account_idle_time(old_cputime); | 395 | account_idle_time(cputime); |
396 | } else if (p->flags & PF_VCPU) { /* System time or guest time */ | 396 | } else if (p->flags & PF_VCPU) { /* System time or guest time */ |
397 | 397 | ||
398 | account_guest_time(p, old_cputime); | 398 | account_guest_time(p, old_cputime); |
@@ -504,7 +504,7 @@ void account_process_tick(struct task_struct *p, int user_tick) | |||
504 | else if ((p != rq->idle) || (irq_count() != HARDIRQ_OFFSET)) | 504 | else if ((p != rq->idle) || (irq_count() != HARDIRQ_OFFSET)) |
505 | account_system_time(p, HARDIRQ_OFFSET, old_cputime); | 505 | account_system_time(p, HARDIRQ_OFFSET, old_cputime); |
506 | else | 506 | else |
507 | account_idle_time(old_cputime); | 507 | account_idle_time(cputime); |
508 | } | 508 | } |
509 | 509 | ||
510 | /* | 510 | /* |
@@ -513,15 +513,15 @@ void account_process_tick(struct task_struct *p, int user_tick) | |||
513 | */ | 513 | */ |
514 | void account_idle_ticks(unsigned long ticks) | 514 | void account_idle_ticks(unsigned long ticks) |
515 | { | 515 | { |
516 | cputime_t cputime, steal; | 516 | u64 cputime, steal; |
517 | 517 | ||
518 | if (sched_clock_irqtime) { | 518 | if (sched_clock_irqtime) { |
519 | irqtime_account_idle_ticks(ticks); | 519 | irqtime_account_idle_ticks(ticks); |
520 | return; | 520 | return; |
521 | } | 521 | } |
522 | 522 | ||
523 | cputime = jiffies_to_cputime(ticks); | 523 | cputime = ticks * TICK_NSEC; |
524 | steal = steal_account_process_time(ULONG_MAX); | 524 | steal = cputime_to_nsecs(steal_account_process_time(ULONG_MAX)); |
525 | 525 | ||
526 | if (steal >= cputime) | 526 | if (steal >= cputime) |
527 | return; | 527 | return; |
@@ -787,7 +787,7 @@ void vtime_account_idle(struct task_struct *tsk) | |||
787 | { | 787 | { |
788 | cputime_t delta_cpu = get_vtime_delta(tsk); | 788 | cputime_t delta_cpu = get_vtime_delta(tsk); |
789 | 789 | ||
790 | account_idle_time(delta_cpu); | 790 | account_idle_time(cputime_to_nsecs(delta_cpu)); |
791 | } | 791 | } |
792 | 792 | ||
793 | void arch_vtime_task_switch(struct task_struct *prev) | 793 | void arch_vtime_task_switch(struct task_struct *prev) |