aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-04-01 13:16:10 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-04-01 13:16:10 -0400
commita21e40877ad130de837b0394583e4f68dc2ab6c5 (patch)
treec990fba6ef5f2ed464c906615c5c327f2d02b318
parentb9b16a792241e304834f43e2a5f02e6e43576f09 (diff)
parent073d8224d299528778e90773becd1e890953443c (diff)
Merge branch 'timers-nohz-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull timer updates from Ingo Molnar: "The main purpose is to fix a full dynticks bug related to virtualization, where steal time accounting appears to be zero in /proc/stat even after a few seconds of competing guests running busy loops in a same host CPU. It's not a regression though as it was there since the beginning. The other commits are preparatory work to fix the bug and various cleanups" * 'timers-nohz-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: arch: Remove stub cputime.h headers sched: Remove needless round trip nsecs <-> tick conversion of steal time cputime: Fix jiffies based cputime assumption on steal accounting cputime: Bring cputime -> nsecs conversion cputime: Default implementation of nsecs -> cputime conversion cputime: Fix nsecs_to_cputime() return type cast
-rw-r--r--arch/alpha/include/asm/Kbuild1
-rw-r--r--arch/alpha/include/asm/cputime.h6
-rw-r--r--arch/cris/include/asm/Kbuild1
-rw-r--r--arch/cris/include/asm/cputime.h6
-rw-r--r--arch/frv/include/asm/Kbuild1
-rw-r--r--arch/frv/include/asm/cputime.h6
-rw-r--r--arch/m32r/include/asm/Kbuild1
-rw-r--r--arch/m32r/include/asm/cputime.h6
-rw-r--r--arch/microblaze/include/asm/Kbuild1
-rw-r--r--arch/microblaze/include/asm/cputime.h1
-rw-r--r--arch/mn10300/include/asm/Kbuild1
-rw-r--r--arch/mn10300/include/asm/cputime.h1
-rw-r--r--arch/score/include/asm/Kbuild1
-rw-r--r--arch/score/include/asm/cputime.h6
-rw-r--r--arch/x86/include/asm/Kbuild1
-rw-r--r--arch/x86/include/asm/cputime.h1
-rw-r--r--drivers/cpufreq/cpufreq_stats.c2
-rw-r--r--drivers/s390/cio/cio.c2
-rw-r--r--fs/proc/stat.c2
-rw-r--r--fs/proc/uptime.c2
-rw-r--r--include/asm-generic/cputime_jiffies.h4
-rw-r--r--include/asm-generic/cputime_nsecs.h5
-rw-r--r--include/linux/cputime.h16
-rw-r--r--include/linux/kernel_stat.h2
-rw-r--r--include/linux/sched.h2
-rw-r--r--kernel/sched/core.c6
-rw-r--r--kernel/sched/cputime.c16
-rw-r--r--kernel/sched/sched.h10
28 files changed, 48 insertions, 62 deletions
diff --git a/arch/alpha/include/asm/Kbuild b/arch/alpha/include/asm/Kbuild
index 7736f426ff3b..96e54bed5088 100644
--- a/arch/alpha/include/asm/Kbuild
+++ b/arch/alpha/include/asm/Kbuild
@@ -1,6 +1,7 @@
1 1
2 2
3generic-y += clkdev.h 3generic-y += clkdev.h
4generic-y += cputime.h
4generic-y += exec.h 5generic-y += exec.h
5generic-y += hash.h 6generic-y += hash.h
6generic-y += mcs_spinlock.h 7generic-y += mcs_spinlock.h
diff --git a/arch/alpha/include/asm/cputime.h b/arch/alpha/include/asm/cputime.h
deleted file mode 100644
index 19577fd93230..000000000000
--- a/arch/alpha/include/asm/cputime.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef __ALPHA_CPUTIME_H
2#define __ALPHA_CPUTIME_H
3
4#include <asm-generic/cputime.h>
5
6#endif /* __ALPHA_CPUTIME_H */
diff --git a/arch/cris/include/asm/Kbuild b/arch/cris/include/asm/Kbuild
index 056027f38351..afff5105909d 100644
--- a/arch/cris/include/asm/Kbuild
+++ b/arch/cris/include/asm/Kbuild
@@ -5,6 +5,7 @@ header-y += arch-v32/
5 5
6generic-y += barrier.h 6generic-y += barrier.h
7generic-y += clkdev.h 7generic-y += clkdev.h
8generic-y += cputime.h
8generic-y += exec.h 9generic-y += exec.h
9generic-y += hash.h 10generic-y += hash.h
10generic-y += kvm_para.h 11generic-y += kvm_para.h
diff --git a/arch/cris/include/asm/cputime.h b/arch/cris/include/asm/cputime.h
deleted file mode 100644
index 4446a65656fa..000000000000
--- a/arch/cris/include/asm/cputime.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef __CRIS_CPUTIME_H
2#define __CRIS_CPUTIME_H
3
4#include <asm-generic/cputime.h>
5
6#endif /* __CRIS_CPUTIME_H */
diff --git a/arch/frv/include/asm/Kbuild b/arch/frv/include/asm/Kbuild
index babb9338ebf8..87b95eb8aee5 100644
--- a/arch/frv/include/asm/Kbuild
+++ b/arch/frv/include/asm/Kbuild
@@ -1,5 +1,6 @@
1 1
2generic-y += clkdev.h 2generic-y += clkdev.h
3generic-y += cputime.h
3generic-y += exec.h 4generic-y += exec.h
4generic-y += hash.h 5generic-y += hash.h
5generic-y += mcs_spinlock.h 6generic-y += mcs_spinlock.h
diff --git a/arch/frv/include/asm/cputime.h b/arch/frv/include/asm/cputime.h
deleted file mode 100644
index f6c373ad2b80..000000000000
--- a/arch/frv/include/asm/cputime.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef _ASM_CPUTIME_H
2#define _ASM_CPUTIME_H
3
4#include <asm-generic/cputime.h>
5
6#endif /* _ASM_CPUTIME_H */
diff --git a/arch/m32r/include/asm/Kbuild b/arch/m32r/include/asm/Kbuild
index 5825a35b2c56..67779a74b62d 100644
--- a/arch/m32r/include/asm/Kbuild
+++ b/arch/m32r/include/asm/Kbuild
@@ -1,5 +1,6 @@
1 1
2generic-y += clkdev.h 2generic-y += clkdev.h
3generic-y += cputime.h
3generic-y += exec.h 4generic-y += exec.h
4generic-y += hash.h 5generic-y += hash.h
5generic-y += mcs_spinlock.h 6generic-y += mcs_spinlock.h
diff --git a/arch/m32r/include/asm/cputime.h b/arch/m32r/include/asm/cputime.h
deleted file mode 100644
index 0a47550df2b7..000000000000
--- a/arch/m32r/include/asm/cputime.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef __M32R_CPUTIME_H
2#define __M32R_CPUTIME_H
3
4#include <asm-generic/cputime.h>
5
6#endif /* __M32R_CPUTIME_H */
diff --git a/arch/microblaze/include/asm/Kbuild b/arch/microblaze/include/asm/Kbuild
index 1f590ab8f323..c98ed95c0541 100644
--- a/arch/microblaze/include/asm/Kbuild
+++ b/arch/microblaze/include/asm/Kbuild
@@ -1,6 +1,7 @@
1 1
2generic-y += barrier.h 2generic-y += barrier.h
3generic-y += clkdev.h 3generic-y += clkdev.h
4generic-y += cputime.h
4generic-y += exec.h 5generic-y += exec.h
5generic-y += hash.h 6generic-y += hash.h
6generic-y += mcs_spinlock.h 7generic-y += mcs_spinlock.h
diff --git a/arch/microblaze/include/asm/cputime.h b/arch/microblaze/include/asm/cputime.h
deleted file mode 100644
index 6d68ad7e0ea3..000000000000
--- a/arch/microblaze/include/asm/cputime.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/cputime.h>
diff --git a/arch/mn10300/include/asm/Kbuild b/arch/mn10300/include/asm/Kbuild
index cbc6b9bf45da..654d5ba6e310 100644
--- a/arch/mn10300/include/asm/Kbuild
+++ b/arch/mn10300/include/asm/Kbuild
@@ -1,6 +1,7 @@
1 1
2generic-y += barrier.h 2generic-y += barrier.h
3generic-y += clkdev.h 3generic-y += clkdev.h
4generic-y += cputime.h
4generic-y += exec.h 5generic-y += exec.h
5generic-y += hash.h 6generic-y += hash.h
6generic-y += mcs_spinlock.h 7generic-y += mcs_spinlock.h
diff --git a/arch/mn10300/include/asm/cputime.h b/arch/mn10300/include/asm/cputime.h
deleted file mode 100644
index 6d68ad7e0ea3..000000000000
--- a/arch/mn10300/include/asm/cputime.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/cputime.h>
diff --git a/arch/score/include/asm/Kbuild b/arch/score/include/asm/Kbuild
index 4630cf217b5b..2f947aba4bd4 100644
--- a/arch/score/include/asm/Kbuild
+++ b/arch/score/include/asm/Kbuild
@@ -4,6 +4,7 @@ header-y +=
4 4
5generic-y += barrier.h 5generic-y += barrier.h
6generic-y += clkdev.h 6generic-y += clkdev.h
7generic-y += cputime.h
7generic-y += hash.h 8generic-y += hash.h
8generic-y += mcs_spinlock.h 9generic-y += mcs_spinlock.h
9generic-y += preempt.h 10generic-y += preempt.h
diff --git a/arch/score/include/asm/cputime.h b/arch/score/include/asm/cputime.h
deleted file mode 100644
index 1fced99f0d67..000000000000
--- a/arch/score/include/asm/cputime.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef _ASM_SCORE_CPUTIME_H
2#define _ASM_SCORE_CPUTIME_H
3
4#include <asm-generic/cputime.h>
5
6#endif /* _ASM_SCORE_CPUTIME_H */
diff --git a/arch/x86/include/asm/Kbuild b/arch/x86/include/asm/Kbuild
index a8fee078b92f..4acddc43ee0c 100644
--- a/arch/x86/include/asm/Kbuild
+++ b/arch/x86/include/asm/Kbuild
@@ -5,4 +5,5 @@ genhdr-y += unistd_64.h
5genhdr-y += unistd_x32.h 5genhdr-y += unistd_x32.h
6 6
7generic-y += clkdev.h 7generic-y += clkdev.h
8generic-y += cputime.h
8generic-y += mcs_spinlock.h 9generic-y += mcs_spinlock.h
diff --git a/arch/x86/include/asm/cputime.h b/arch/x86/include/asm/cputime.h
deleted file mode 100644
index 6d68ad7e0ea3..000000000000
--- a/arch/x86/include/asm/cputime.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/cputime.h>
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
18static spinlock_t cpufreq_stats_lock; 18static spinlock_t cpufreq_stats_lock;
19 19
diff --git a/drivers/s390/cio/cio.c b/drivers/s390/cio/cio.c
index 97c48b38d67d..d691e6a13aae 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
10static int uptime_proc_show(struct seq_file *m, void *v) 10static int uptime_proc_show(struct seq_file *m, void *v)
11{ 11{
diff --git a/include/asm-generic/cputime_jiffies.h b/include/asm-generic/cputime_jiffies.h
index 272ecba9f588..d5cb78f53986 100644
--- a/include/asm-generic/cputime_jiffies.h
+++ b/include/asm-generic/cputime_jiffies.h
@@ -15,8 +15,10 @@ typedef u64 __nocast cputime64_t;
15 15
16 16
17/* 17/*
18 * Convert nanoseconds to cputime 18 * Convert nanoseconds <-> cputime
19 */ 19 */
20#define cputime_to_nsecs(__ct) \
21 jiffies_to_nsecs(cputime_to_jiffies(__ct))
20#define nsecs_to_cputime64(__nsec) \ 22#define nsecs_to_cputime64(__nsec) \
21 jiffies64_to_cputime64(nsecs_to_jiffies64(__nsec)) 23 jiffies64_to_cputime64(nsecs_to_jiffies64(__nsec))
22#define nsecs_to_cputime(__nsec) \ 24#define nsecs_to_cputime(__nsec) \
diff --git a/include/asm-generic/cputime_nsecs.h b/include/asm-generic/cputime_nsecs.h
index 2c9e62c2bfd0..4e817606c549 100644
--- a/include/asm-generic/cputime_nsecs.h
+++ b/include/asm-generic/cputime_nsecs.h
@@ -44,7 +44,10 @@ typedef u64 __nocast cputime64_t;
44/* 44/*
45 * Convert cputime <-> nanoseconds 45 * Convert cputime <-> nanoseconds
46 */ 46 */
47#define nsecs_to_cputime(__nsecs) ((__force u64)(__nsecs)) 47#define cputime_to_nsecs(__ct) \
48 (__force u64)(__ct)
49#define nsecs_to_cputime(__nsecs) \
50 (__force cputime_t)(__nsecs)
48 51
49 52
50/* 53/*
diff --git a/include/linux/cputime.h b/include/linux/cputime.h
new file mode 100644
index 000000000000..f2eb2ee535ca
--- /dev/null
+++ b/include/linux/cputime.h
@@ -0,0 +1,16 @@
1#ifndef __LINUX_CPUTIME_H
2#define __LINUX_CPUTIME_H
3
4#include <asm/cputime.h>
5
6#ifndef cputime_to_nsecs
7# define cputime_to_nsecs(__ct) \
8 (cputime_to_usecs(__ct) * NSEC_PER_USEC)
9#endif
10
11#ifndef nsecs_to_cputime
12# define nsecs_to_cputime(__nsecs) \
13 usecs_to_cputime((__nsecs) / NSEC_PER_USEC)
14#endif
15
16#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 825ed838d4b9..c399ed826648 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -29,7 +29,7 @@ struct sched_param {
29 29
30#include <asm/page.h> 30#include <asm/page.h>
31#include <asm/ptrace.h> 31#include <asm/ptrace.h>
32#include <asm/cputime.h> 32#include <linux/cputime.h>
33 33
34#include <linux/smp.h> 34#include <linux/smp.h>
35#include <linux/sem.h> 35#include <linux/sem.h>
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index a47902c687ae..d11a1768357d 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -823,19 +823,13 @@ static void update_rq_clock_task(struct rq *rq, s64 delta)
823#endif 823#endif
824#ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING 824#ifdef CONFIG_PARAVIRT_TIME_ACCOUNTING
825 if (static_key_false((&paravirt_steal_rq_enabled))) { 825 if (static_key_false((&paravirt_steal_rq_enabled))) {
826 u64 st;
827
828 steal = paravirt_steal_clock(cpu_of(rq)); 826 steal = paravirt_steal_clock(cpu_of(rq));
829 steal -= rq->prev_steal_time_rq; 827 steal -= rq->prev_steal_time_rq;
830 828
831 if (unlikely(steal > delta)) 829 if (unlikely(steal > delta))
832 steal = delta; 830 steal = delta;
833 831
834 st = steal_ticks(steal);
835 steal = st * TICK_NSEC;
836
837 rq->prev_steal_time_rq += steal; 832 rq->prev_steal_time_rq += steal;
838
839 delta -= steal; 833 delta -= steal;
840 } 834 }
841#endif 835#endif
diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index 58624a65f124..a95097cb4591 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -258,16 +258,22 @@ static __always_inline bool steal_account_process_tick(void)
258{ 258{
259#ifdef CONFIG_PARAVIRT 259#ifdef CONFIG_PARAVIRT
260 if (static_key_false(&paravirt_steal_enabled)) { 260 if (static_key_false(&paravirt_steal_enabled)) {
261 u64 steal, st = 0; 261 u64 steal;
262 cputime_t steal_ct;
262 263
263 steal = paravirt_steal_clock(smp_processor_id()); 264 steal = paravirt_steal_clock(smp_processor_id());
264 steal -= this_rq()->prev_steal_time; 265 steal -= this_rq()->prev_steal_time;
265 266
266 st = steal_ticks(steal); 267 /*
267 this_rq()->prev_steal_time += st * TICK_NSEC; 268 * cputime_t may be less precise than nsecs (eg: if it's
269 * based on jiffies). Lets cast the result to cputime
270 * granularity and account the rest on the next rounds.
271 */
272 steal_ct = nsecs_to_cputime(steal);
273 this_rq()->prev_steal_time += cputime_to_nsecs(steal_ct);
268 274
269 account_steal_time(st); 275 account_steal_time(steal_ct);
270 return st; 276 return steal_ct;
271 } 277 }
272#endif 278#endif
273 return false; 279 return false;
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index f2de7a175620..c9007f28d3a2 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -1216,16 +1216,6 @@ extern void update_idle_cpu_load(struct rq *this_rq);
1216 1216
1217extern void init_task_runnable_average(struct task_struct *p); 1217extern void init_task_runnable_average(struct task_struct *p);
1218 1218
1219#ifdef CONFIG_PARAVIRT
1220static inline u64 steal_ticks(u64 steal)
1221{
1222 if (unlikely(steal > NSEC_PER_SEC))
1223 return div_u64(steal, TICK_NSEC);
1224
1225 return __iter_div_u64_rem(steal, TICK_NSEC, &steal);
1226}
1227#endif
1228
1229static inline void inc_nr_running(struct rq *rq) 1219static inline void inc_nr_running(struct rq *rq)
1230{ 1220{
1231 rq->nr_running++; 1221 rq->nr_running++;