summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2017-01-30 22:09:40 -0500
committerIngo Molnar <mingo@kernel.org>2017-02-01 03:13:58 -0500
commitfb8b049c988f1ff460b063b8a41ea9a3c79921c2 (patch)
treea2aad5cdf6dca86c9ce41b39a5f78e15fe537b8b
parent18b43a9bd7ae91185e398dd983fb4fffb9e81b3a (diff)
sched/cputime: Push time to account_system_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-25-git-send-email-fweisbec@gmail.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--arch/ia64/kernel/time.c11
-rw-r--r--arch/powerpc/kernel/time.c15
-rw-r--r--arch/s390/kernel/idle.c2
-rw-r--r--arch/s390/kernel/vtime.c6
-rw-r--r--include/linux/kernel_stat.h7
-rw-r--r--kernel/sched/cputime.c39
6 files changed, 40 insertions, 40 deletions
diff --git a/arch/ia64/kernel/time.c b/arch/ia64/kernel/time.c
index 5dc801d97790..f15bca4776a7 100644
--- a/arch/ia64/kernel/time.c
+++ b/arch/ia64/kernel/time.c
@@ -21,6 +21,7 @@
21#include <linux/timex.h> 21#include <linux/timex.h>
22#include <linux/timekeeper_internal.h> 22#include <linux/timekeeper_internal.h>
23#include <linux/platform_device.h> 23#include <linux/platform_device.h>
24#include <linux/cputime.h>
24 25
25#include <asm/machvec.h> 26#include <asm/machvec.h>
26#include <asm/delay.h> 27#include <asm/delay.h>
@@ -64,29 +65,29 @@ extern cputime_t cycle_to_cputime(u64 cyc);
64void vtime_flush(struct task_struct *tsk) 65void vtime_flush(struct task_struct *tsk)
65{ 66{
66 struct thread_info *ti = task_thread_info(tsk); 67 struct thread_info *ti = task_thread_info(tsk);
67 cputime_t delta; 68 u64 delta;
68 69
69 if (ti->utime) 70 if (ti->utime)
70 account_user_time(tsk, cputime_to_nsecs(cycle_to_cputime(ti->utime))); 71 account_user_time(tsk, cputime_to_nsecs(cycle_to_cputime(ti->utime)));
71 72
72 if (ti->gtime) 73 if (ti->gtime)
73 account_guest_time(tsk, cycle_to_cputime(ti->gtime)); 74 account_guest_time(tsk, cputime_to_nsecs(cycle_to_cputime(ti->gtime)));
74 75
75 if (ti->idle_time) 76 if (ti->idle_time)
76 account_idle_time(cputime_to_nsecs(cycle_to_cputime(ti->idle_time))); 77 account_idle_time(cputime_to_nsecs(cycle_to_cputime(ti->idle_time)));
77 78
78 if (ti->stime) { 79 if (ti->stime) {
79 delta = cycle_to_cputime(ti->stime); 80 delta = cputime_to_nsecs(cycle_to_cputime(ti->stime));
80 account_system_index_time(tsk, delta, CPUTIME_SYSTEM); 81 account_system_index_time(tsk, delta, CPUTIME_SYSTEM);
81 } 82 }
82 83
83 if (ti->hardirq_time) { 84 if (ti->hardirq_time) {
84 delta = cycle_to_cputime(ti->hardirq_time); 85 delta = cputime_to_nsecs(cycle_to_cputime(ti->hardirq_time));
85 account_system_index_time(tsk, delta, CPUTIME_IRQ); 86 account_system_index_time(tsk, delta, CPUTIME_IRQ);
86 } 87 }
87 88
88 if (ti->softirq_time) { 89 if (ti->softirq_time) {
89 delta = cycle_to_cputime(ti->softirq_time); 90 delta = cputime_to_nsecs(cycle_to_cputime(ti->softirq_time));
90 account_system_index_time(tsk, delta, CPUTIME_SOFTIRQ); 91 account_system_index_time(tsk, delta, CPUTIME_SOFTIRQ);
91 } 92 }
92 93
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index 739897a10fd3..01f53bfe100b 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -57,6 +57,7 @@
57#include <linux/clk-provider.h> 57#include <linux/clk-provider.h>
58#include <linux/suspend.h> 58#include <linux/suspend.h>
59#include <linux/rtc.h> 59#include <linux/rtc.h>
60#include <linux/cputime.h>
60#include <asm/trace.h> 61#include <asm/trace.h>
61 62
62#include <asm/io.h> 63#include <asm/io.h>
@@ -72,7 +73,6 @@
72#include <asm/smp.h> 73#include <asm/smp.h>
73#include <asm/vdso_datapage.h> 74#include <asm/vdso_datapage.h>
74#include <asm/firmware.h> 75#include <asm/firmware.h>
75#include <asm/cputime.h>
76#include <asm/asm-prototypes.h> 76#include <asm/asm-prototypes.h>
77 77
78/* powerpc clocksource/clockevent code */ 78/* powerpc clocksource/clockevent code */
@@ -399,7 +399,7 @@ void vtime_flush(struct task_struct *tsk)
399 tsk->utimescaled += cputime_to_nsecs(acct->utime_scaled); 399 tsk->utimescaled += cputime_to_nsecs(acct->utime_scaled);
400 400
401 if (acct->gtime) 401 if (acct->gtime)
402 account_guest_time(tsk, acct->gtime); 402 account_guest_time(tsk, cputime_to_nsecs(acct->gtime));
403 403
404 if (acct->steal_time) 404 if (acct->steal_time)
405 account_steal_time(cputime_to_nsecs(acct->steal_time)); 405 account_steal_time(cputime_to_nsecs(acct->steal_time));
@@ -408,16 +408,17 @@ void vtime_flush(struct task_struct *tsk)
408 account_idle_time(cputime_to_nsecs(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, cputime_to_nsecs(acct->stime),
412 412 CPUTIME_SYSTEM);
413 if (acct->stime_scaled) 413 if (acct->stime_scaled)
414 tsk->stimescaled += cputime_to_nsecs(acct->stime_scaled); 414 tsk->stimescaled += cputime_to_nsecs(acct->stime_scaled);
415 415
416 if (acct->hardirq_time) 416 if (acct->hardirq_time)
417 account_system_index_time(tsk, acct->hardirq_time, CPUTIME_IRQ); 417 account_system_index_time(tsk, cputime_to_nsecs(acct->hardirq_time),
418 418 CPUTIME_IRQ);
419 if (acct->softirq_time) 419 if (acct->softirq_time)
420 account_system_index_time(tsk, acct->softirq_time, CPUTIME_SOFTIRQ); 420 account_system_index_time(tsk, cputime_to_nsecs(acct->softirq_time),
421 CPUTIME_SOFTIRQ);
421 422
422 acct->utime = 0; 423 acct->utime = 0;
423 acct->utime_scaled = 0; 424 acct->utime_scaled = 0;
diff --git a/arch/s390/kernel/idle.c b/arch/s390/kernel/idle.c
index 99f1d8185ae2..5c0e08e761c3 100644
--- a/arch/s390/kernel/idle.c
+++ b/arch/s390/kernel/idle.c
@@ -12,7 +12,7 @@
12#include <linux/notifier.h> 12#include <linux/notifier.h>
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/cpu.h> 14#include <linux/cpu.h>
15#include <asm/cputime.h> 15#include <linux/cputime.h>
16#include <asm/nmi.h> 16#include <asm/nmi.h>
17#include <asm/smp.h> 17#include <asm/smp.h>
18#include "entry.h" 18#include "entry.h"
diff --git a/arch/s390/kernel/vtime.c b/arch/s390/kernel/vtime.c
index 1e7023c6ef23..b4a3e9e06ef2 100644
--- a/arch/s390/kernel/vtime.c
+++ b/arch/s390/kernel/vtime.c
@@ -6,13 +6,13 @@
6 */ 6 */
7 7
8#include <linux/kernel_stat.h> 8#include <linux/kernel_stat.h>
9#include <linux/cputime.h>
9#include <linux/export.h> 10#include <linux/export.h>
10#include <linux/kernel.h> 11#include <linux/kernel.h>
11#include <linux/timex.h> 12#include <linux/timex.h>
12#include <linux/types.h> 13#include <linux/types.h>
13#include <linux/time.h> 14#include <linux/time.h>
14 15
15#include <asm/cputime.h>
16#include <asm/vtimer.h> 16#include <asm/vtimer.h>
17#include <asm/vtime.h> 17#include <asm/vtime.h>
18#include <asm/cpu_mf.h> 18#include <asm/cpu_mf.h>
@@ -115,7 +115,7 @@ static void account_system_index_scaled(struct task_struct *p,
115 enum cpu_usage_stat index) 115 enum cpu_usage_stat index)
116{ 116{
117 p->stimescaled += cputime_to_nsecs(scaled); 117 p->stimescaled += cputime_to_nsecs(scaled);
118 account_system_index_time(p, cputime, index); 118 account_system_index_time(p, cputime_to_nsecs(cputime), index);
119} 119}
120 120
121/* 121/*
@@ -171,7 +171,7 @@ static int do_account_vtime(struct task_struct *tsk)
171 } 171 }
172 172
173 if (guest) { 173 if (guest) {
174 account_guest_time(tsk, guest); 174 account_guest_time(tsk, cputime_to_nsecs(guest));
175 tsk->utimescaled += cputime_to_nsecs(scale_vtime(guest)); 175 tsk->utimescaled += cputime_to_nsecs(scale_vtime(guest));
176 } 176 }
177 177
diff --git a/include/linux/kernel_stat.h b/include/linux/kernel_stat.h
index e1cd8970e096..66be8b6beceb 100644
--- a/include/linux/kernel_stat.h
+++ b/include/linux/kernel_stat.h
@@ -9,7 +9,6 @@
9#include <linux/sched.h> 9#include <linux/sched.h>
10#include <linux/vtime.h> 10#include <linux/vtime.h>
11#include <asm/irq.h> 11#include <asm/irq.h>
12#include <linux/cputime.h>
13 12
14/* 13/*
15 * 'kernel_stat.h' contains the definitions needed for doing 14 * 'kernel_stat.h' contains the definitions needed for doing
@@ -79,9 +78,9 @@ static inline unsigned int kstat_cpu_irqs_sum(unsigned int cpu)
79} 78}
80 79
81extern void account_user_time(struct task_struct *, u64); 80extern void account_user_time(struct task_struct *, u64);
82extern void account_guest_time(struct task_struct *, cputime_t); 81extern void account_guest_time(struct task_struct *, u64);
83extern void account_system_time(struct task_struct *, int, cputime_t); 82extern void account_system_time(struct task_struct *, int, u64);
84extern void account_system_index_time(struct task_struct *, cputime_t, 83extern void account_system_index_time(struct task_struct *, u64,
85 enum cpu_usage_stat); 84 enum cpu_usage_stat);
86extern void account_steal_time(u64); 85extern void account_steal_time(u64);
87extern void account_idle_time(u64); 86extern void account_idle_time(u64);
diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index fd5375f956fe..d28e9c53727c 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -4,6 +4,7 @@
4#include <linux/kernel_stat.h> 4#include <linux/kernel_stat.h>
5#include <linux/static_key.h> 5#include <linux/static_key.h>
6#include <linux/context_tracking.h> 6#include <linux/context_tracking.h>
7#include <linux/cputime.h>
7#include "sched.h" 8#include "sched.h"
8#ifdef CONFIG_PARAVIRT 9#ifdef CONFIG_PARAVIRT
9#include <asm/paravirt.h> 10#include <asm/paravirt.h>
@@ -138,22 +139,22 @@ void account_user_time(struct task_struct *p, u64 cputime)
138 * @p: the process that the cpu time gets accounted to 139 * @p: the process that the cpu time gets accounted to
139 * @cputime: the cpu time spent in virtual machine since the last update 140 * @cputime: the cpu time spent in virtual machine since the last update
140 */ 141 */
141void account_guest_time(struct task_struct *p, cputime_t cputime) 142void account_guest_time(struct task_struct *p, u64 cputime)
142{ 143{
143 u64 *cpustat = kcpustat_this_cpu->cpustat; 144 u64 *cpustat = kcpustat_this_cpu->cpustat;
144 145
145 /* Add guest time to process. */ 146 /* Add guest time to process. */
146 p->utime += cputime_to_nsecs(cputime); 147 p->utime += cputime;
147 account_group_user_time(p, cputime_to_nsecs(cputime)); 148 account_group_user_time(p, cputime);
148 p->gtime += cputime_to_nsecs(cputime); 149 p->gtime += cputime;
149 150
150 /* Add guest time to cpustat. */ 151 /* Add guest time to cpustat. */
151 if (task_nice(p) > 0) { 152 if (task_nice(p) > 0) {
152 cpustat[CPUTIME_NICE] += cputime_to_nsecs(cputime); 153 cpustat[CPUTIME_NICE] += cputime;
153 cpustat[CPUTIME_GUEST_NICE] += cputime_to_nsecs(cputime); 154 cpustat[CPUTIME_GUEST_NICE] += cputime;
154 } else { 155 } else {
155 cpustat[CPUTIME_USER] += cputime_to_nsecs(cputime); 156 cpustat[CPUTIME_USER] += cputime;
156 cpustat[CPUTIME_GUEST] += cputime_to_nsecs(cputime); 157 cpustat[CPUTIME_GUEST] += cputime;
157 } 158 }
158} 159}
159 160
@@ -164,14 +165,14 @@ void account_guest_time(struct task_struct *p, cputime_t cputime)
164 * @index: pointer to cpustat field that has to be updated 165 * @index: pointer to cpustat field that has to be updated
165 */ 166 */
166void account_system_index_time(struct task_struct *p, 167void account_system_index_time(struct task_struct *p,
167 cputime_t cputime, enum cpu_usage_stat index) 168 u64 cputime, enum cpu_usage_stat index)
168{ 169{
169 /* Add system time to process. */ 170 /* Add system time to process. */
170 p->stime += cputime_to_nsecs(cputime); 171 p->stime += cputime;
171 account_group_system_time(p, cputime_to_nsecs(cputime)); 172 account_group_system_time(p, cputime);
172 173
173 /* Add system time to cpustat. */ 174 /* Add system time to cpustat. */
174 task_group_account_field(p, index, cputime_to_nsecs(cputime)); 175 task_group_account_field(p, index, cputime);
175 176
176 /* Account for system time used */ 177 /* Account for system time used */
177 acct_account_cputime(p); 178 acct_account_cputime(p);
@@ -183,8 +184,7 @@ void account_system_index_time(struct task_struct *p,
183 * @hardirq_offset: the offset to subtract from hardirq_count() 184 * @hardirq_offset: the offset to subtract from hardirq_count()
184 * @cputime: the cpu time spent in kernel space since the last update 185 * @cputime: the cpu time spent in kernel space since the last update
185 */ 186 */
186void account_system_time(struct task_struct *p, int hardirq_offset, 187void account_system_time(struct task_struct *p, int hardirq_offset, u64 cputime)
187 cputime_t cputime)
188{ 188{
189 int index; 189 int index;
190 190
@@ -388,16 +388,15 @@ static void irqtime_account_process_tick(struct task_struct *p, int user_tick,
388 * So, we have to handle it separately here. 388 * So, we have to handle it separately here.
389 * Also, p->stime needs to be updated for ksoftirqd. 389 * Also, p->stime needs to be updated for ksoftirqd.
390 */ 390 */
391 account_system_index_time(p, old_cputime, CPUTIME_SOFTIRQ); 391 account_system_index_time(p, cputime, CPUTIME_SOFTIRQ);
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(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 account_guest_time(p, cputime);
398 account_guest_time(p, old_cputime);
399 } else { 398 } else {
400 account_system_index_time(p, old_cputime, CPUTIME_SYSTEM); 399 account_system_index_time(p, cputime, CPUTIME_SYSTEM);
401 } 400 }
402} 401}
403 402
@@ -502,7 +501,7 @@ void account_process_tick(struct task_struct *p, int user_tick)
502 if (user_tick) 501 if (user_tick)
503 account_user_time(p, cputime); 502 account_user_time(p, cputime);
504 else if ((p != rq->idle) || (irq_count() != HARDIRQ_OFFSET)) 503 else if ((p != rq->idle) || (irq_count() != HARDIRQ_OFFSET))
505 account_system_time(p, HARDIRQ_OFFSET, old_cputime); 504 account_system_time(p, HARDIRQ_OFFSET, cputime);
506 else 505 else
507 account_idle_time(cputime); 506 account_idle_time(cputime);
508} 507}
@@ -722,7 +721,7 @@ static void __vtime_account_system(struct task_struct *tsk)
722{ 721{
723 cputime_t delta_cpu = get_vtime_delta(tsk); 722 cputime_t delta_cpu = get_vtime_delta(tsk);
724 723
725 account_system_time(tsk, irq_count(), delta_cpu); 724 account_system_time(tsk, irq_count(), cputime_to_nsecs(delta_cpu));
726} 725}
727 726
728void vtime_account_system(struct task_struct *tsk) 727void vtime_account_system(struct task_struct *tsk)