diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2012-06-16 09:57:37 -0400 |
---|---|---|
committer | Frederic Weisbecker <fweisbec@gmail.com> | 2012-08-20 07:05:17 -0400 |
commit | 73fbec604432e1fbfeb1bc59a110dac1f98160f6 (patch) | |
tree | 1bcdf943945b61aa1b2d2193ebd72197bf788a33 /kernel/sched/sched.h | |
parent | b952741c80790d2dc9f17fac6f15d87d58dea2a1 (diff) |
sched: Move cputime code to its own file
Extract cputime code from the giant sched/core.c and
put it in its own file. This make it easier to deal with
this particular area and de-bloat a bit more core.c
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Diffstat (limited to 'kernel/sched/sched.h')
-rw-r--r-- | kernel/sched/sched.h | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index f6714d009e77..804c2e5e7872 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h | |||
@@ -891,6 +891,9 @@ struct cpuacct { | |||
891 | struct kernel_cpustat __percpu *cpustat; | 891 | struct kernel_cpustat __percpu *cpustat; |
892 | }; | 892 | }; |
893 | 893 | ||
894 | extern struct cgroup_subsys cpuacct_subsys; | ||
895 | extern struct cpuacct root_cpuacct; | ||
896 | |||
894 | /* return cpu accounting group corresponding to this container */ | 897 | /* return cpu accounting group corresponding to this container */ |
895 | static inline struct cpuacct *cgroup_ca(struct cgroup *cgrp) | 898 | static inline struct cpuacct *cgroup_ca(struct cgroup *cgrp) |
896 | { | 899 | { |
@@ -917,6 +920,16 @@ extern void cpuacct_charge(struct task_struct *tsk, u64 cputime); | |||
917 | static inline void cpuacct_charge(struct task_struct *tsk, u64 cputime) {} | 920 | static inline void cpuacct_charge(struct task_struct *tsk, u64 cputime) {} |
918 | #endif | 921 | #endif |
919 | 922 | ||
923 | #ifdef CONFIG_PARAVIRT | ||
924 | static inline u64 steal_ticks(u64 steal) | ||
925 | { | ||
926 | if (unlikely(steal > NSEC_PER_SEC)) | ||
927 | return div_u64(steal, TICK_NSEC); | ||
928 | |||
929 | return __iter_div_u64_rem(steal, TICK_NSEC, &steal); | ||
930 | } | ||
931 | #endif | ||
932 | |||
920 | static inline void inc_nr_running(struct rq *rq) | 933 | static inline void inc_nr_running(struct rq *rq) |
921 | { | 934 | { |
922 | rq->nr_running++; | 935 | rq->nr_running++; |
@@ -1157,3 +1170,53 @@ enum rq_nohz_flag_bits { | |||
1157 | 1170 | ||
1158 | #define nohz_flags(cpu) (&cpu_rq(cpu)->nohz_flags) | 1171 | #define nohz_flags(cpu) (&cpu_rq(cpu)->nohz_flags) |
1159 | #endif | 1172 | #endif |
1173 | |||
1174 | #ifdef CONFIG_IRQ_TIME_ACCOUNTING | ||
1175 | |||
1176 | DECLARE_PER_CPU(u64, cpu_hardirq_time); | ||
1177 | DECLARE_PER_CPU(u64, cpu_softirq_time); | ||
1178 | |||
1179 | #ifndef CONFIG_64BIT | ||
1180 | DECLARE_PER_CPU(seqcount_t, irq_time_seq); | ||
1181 | |||
1182 | static inline void irq_time_write_begin(void) | ||
1183 | { | ||
1184 | __this_cpu_inc(irq_time_seq.sequence); | ||
1185 | smp_wmb(); | ||
1186 | } | ||
1187 | |||
1188 | static inline void irq_time_write_end(void) | ||
1189 | { | ||
1190 | smp_wmb(); | ||
1191 | __this_cpu_inc(irq_time_seq.sequence); | ||
1192 | } | ||
1193 | |||
1194 | static inline u64 irq_time_read(int cpu) | ||
1195 | { | ||
1196 | u64 irq_time; | ||
1197 | unsigned seq; | ||
1198 | |||
1199 | do { | ||
1200 | seq = read_seqcount_begin(&per_cpu(irq_time_seq, cpu)); | ||
1201 | irq_time = per_cpu(cpu_softirq_time, cpu) + | ||
1202 | per_cpu(cpu_hardirq_time, cpu); | ||
1203 | } while (read_seqcount_retry(&per_cpu(irq_time_seq, cpu), seq)); | ||
1204 | |||
1205 | return irq_time; | ||
1206 | } | ||
1207 | #else /* CONFIG_64BIT */ | ||
1208 | static inline void irq_time_write_begin(void) | ||
1209 | { | ||
1210 | } | ||
1211 | |||
1212 | static inline void irq_time_write_end(void) | ||
1213 | { | ||
1214 | } | ||
1215 | |||
1216 | static inline u64 irq_time_read(int cpu) | ||
1217 | { | ||
1218 | return per_cpu(cpu_softirq_time, cpu) + per_cpu(cpu_hardirq_time, cpu); | ||
1219 | } | ||
1220 | #endif /* CONFIG_64BIT */ | ||
1221 | #endif /* CONFIG_IRQ_TIME_ACCOUNTING */ | ||
1222 | |||