diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2014-03-05 10:33:42 -0500 |
---|---|---|
committer | Frederic Weisbecker <fweisbec@gmail.com> | 2014-03-13 10:56:43 -0400 |
commit | bfc3f0281e08066fa8111c3972cff6edc1049864 (patch) | |
tree | 6050b264fecd05de99bdff0dd6c98e8594ed70a4 | |
parent | 69bb2600c9f8ca450fede9633edf9c2513c9ee6f (diff) |
cputime: Default implementation of nsecs -> cputime conversion
The architectures that override cputime_t (s390, ppc) don't provide
any version of nsecs_to_cputime(). Indeed this cputime_t implementation
by backend only happens when CONFIG_VIRT_CPU_ACCOUNTING_NATIVE=y under
which the core code doesn't make any use of nsecs_to_cputime().
At least for now.
We are going to make a broader use of it so lets provide a default
version with a per usecs granularity. It should be good enough for most
usecases.
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Rik van Riel <riel@redhat.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
-rw-r--r-- | drivers/cpufreq/cpufreq_stats.c | 2 | ||||
-rw-r--r-- | drivers/s390/cio/cio.c | 2 | ||||
-rw-r--r-- | fs/proc/stat.c | 2 | ||||
-rw-r--r-- | fs/proc/uptime.c | 2 | ||||
-rw-r--r-- | include/linux/cputime.h | 11 | ||||
-rw-r--r-- | include/linux/kernel_stat.h | 2 | ||||
-rw-r--r-- | include/linux/sched.h | 2 |
7 files changed, 17 insertions, 6 deletions
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index 5793e1447fb1..79911a27a48a 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c | |||
@@ -13,7 +13,7 @@ | |||
13 | #include <linux/cpufreq.h> | 13 | #include <linux/cpufreq.h> |
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/slab.h> | 15 | #include <linux/slab.h> |
16 | #include <asm/cputime.h> | 16 | #include <linux/cputime.h> |
17 | 17 | ||
18 | static spinlock_t cpufreq_stats_lock; | 18 | static spinlock_t cpufreq_stats_lock; |
19 | 19 | ||
diff --git a/drivers/s390/cio/cio.c b/drivers/s390/cio/cio.c index 88e35d85d205..5154513de112 100644 --- a/drivers/s390/cio/cio.c +++ b/drivers/s390/cio/cio.c | |||
@@ -28,7 +28,7 @@ | |||
28 | #include <asm/chpid.h> | 28 | #include <asm/chpid.h> |
29 | #include <asm/airq.h> | 29 | #include <asm/airq.h> |
30 | #include <asm/isc.h> | 30 | #include <asm/isc.h> |
31 | #include <asm/cputime.h> | 31 | #include <linux/cputime.h> |
32 | #include <asm/fcx.h> | 32 | #include <asm/fcx.h> |
33 | #include <asm/nmi.h> | 33 | #include <asm/nmi.h> |
34 | #include <asm/crw.h> | 34 | #include <asm/crw.h> |
diff --git a/fs/proc/stat.c b/fs/proc/stat.c index 6f599c62f0cc..9d231e9e5f0e 100644 --- a/fs/proc/stat.c +++ b/fs/proc/stat.c | |||
@@ -9,7 +9,7 @@ | |||
9 | #include <linux/slab.h> | 9 | #include <linux/slab.h> |
10 | #include <linux/time.h> | 10 | #include <linux/time.h> |
11 | #include <linux/irqnr.h> | 11 | #include <linux/irqnr.h> |
12 | #include <asm/cputime.h> | 12 | #include <linux/cputime.h> |
13 | #include <linux/tick.h> | 13 | #include <linux/tick.h> |
14 | 14 | ||
15 | #ifndef arch_irq_stat_cpu | 15 | #ifndef arch_irq_stat_cpu |
diff --git a/fs/proc/uptime.c b/fs/proc/uptime.c index 7141b8d0ca9e..33de567c25af 100644 --- a/fs/proc/uptime.c +++ b/fs/proc/uptime.c | |||
@@ -5,7 +5,7 @@ | |||
5 | #include <linux/seq_file.h> | 5 | #include <linux/seq_file.h> |
6 | #include <linux/time.h> | 6 | #include <linux/time.h> |
7 | #include <linux/kernel_stat.h> | 7 | #include <linux/kernel_stat.h> |
8 | #include <asm/cputime.h> | 8 | #include <linux/cputime.h> |
9 | 9 | ||
10 | static int uptime_proc_show(struct seq_file *m, void *v) | 10 | static int uptime_proc_show(struct seq_file *m, void *v) |
11 | { | 11 | { |
diff --git a/include/linux/cputime.h b/include/linux/cputime.h new file mode 100644 index 000000000000..2842ebe2844d --- /dev/null +++ b/include/linux/cputime.h | |||
@@ -0,0 +1,11 @@ | |||
1 | #ifndef __LINUX_CPUTIME_H | ||
2 | #define __LINUX_CPUTIME_H | ||
3 | |||
4 | #include <asm/cputime.h> | ||
5 | |||
6 | #ifndef nsecs_to_cputime | ||
7 | # define nsecs_to_cputime(__nsecs) \ | ||
8 | usecs_to_cputime((__nsecs) / NSEC_PER_USEC) | ||
9 | #endif | ||
10 | |||
11 | #endif /* __LINUX_CPUTIME_H */ | ||
diff --git a/include/linux/kernel_stat.h b/include/linux/kernel_stat.h index 51c72be4a7c3..d7c61317db86 100644 --- a/include/linux/kernel_stat.h +++ b/include/linux/kernel_stat.h | |||
@@ -9,7 +9,7 @@ | |||
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 <asm/cputime.h> | 12 | #include <linux/cputime.h> |
13 | 13 | ||
14 | /* | 14 | /* |
15 | * 'kernel_stat.h' contains the definitions needed for doing | 15 | * 'kernel_stat.h' contains the definitions needed for doing |
diff --git a/include/linux/sched.h b/include/linux/sched.h index 68a0e84463a0..1ac566c48d3d 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -27,7 +27,7 @@ struct sched_param { | |||
27 | 27 | ||
28 | #include <asm/page.h> | 28 | #include <asm/page.h> |
29 | #include <asm/ptrace.h> | 29 | #include <asm/ptrace.h> |
30 | #include <asm/cputime.h> | 30 | #include <linux/cputime.h> |
31 | 31 | ||
32 | #include <linux/smp.h> | 32 | #include <linux/smp.h> |
33 | #include <linux/sem.h> | 33 | #include <linux/sem.h> |