aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sched.c
diff options
context:
space:
mode:
authorFrank Mayhar <fmayhar@google.com>2008-09-12 12:54:39 -0400
committerIngo Molnar <mingo@elte.hu>2008-09-23 07:38:44 -0400
commitbb34d92f643086d546b49cef680f6f305ed84414 (patch)
tree275887040c96971e133fa20d99517c1fcea76415 /kernel/sched.c
parent5ce73a4a5a4893a1aa4cdeed1b1a5a6de42c43b6 (diff)
timers: fix itimer/many thread hang, v2
This is the second resubmission of the posix timer rework patch, posted a few days ago. This includes the changes from the previous resubmittion, which addressed Oleg Nesterov's comments, removing the RCU stuff from the patch and un-inlining the thread_group_cputime() function for SMP. In addition, per Ingo Molnar it simplifies the UP code, consolidating much of it with the SMP version and depending on lower-level SMP/UP handling to take care of the differences. It also cleans up some UP compile errors, moves the scheduler stats-related macros into kernel/sched_stats.h, cleans up a merge error in kernel/fork.c and has a few other minor fixes and cleanups as suggested by Oleg and Ingo. Thanks for the review, guys. Signed-off-by: Frank Mayhar <fmayhar@google.com> Cc: Roland McGrath <roland@redhat.com> Cc: Alexey Dobriyan <adobriyan@gmail.com> Cc: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/sched.c')
-rw-r--r--kernel/sched.c47
1 files changed, 7 insertions, 40 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index c51b5d276665..260c22cc530a 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -4039,55 +4039,22 @@ EXPORT_PER_CPU_SYMBOL(kstat);
4039/* 4039/*
4040 * Return any ns on the sched_clock that have not yet been banked in 4040 * Return any ns on the sched_clock that have not yet been banked in
4041 * @p in case that task is currently running. 4041 * @p in case that task is currently running.
4042 *
4043 * Called with task_rq_lock() held on @rq.
4044 */ 4042 */
4045static unsigned long long task_delta_exec(struct task_struct *p, struct rq *rq) 4043unsigned long long task_delta_exec(struct task_struct *p)
4046{ 4044{
4045 struct rq *rq;
4046 unsigned long flags;
4047 u64 ns = 0;
4048
4049 rq = task_rq_lock(p, &flags);
4047 if (task_current(rq, p)) { 4050 if (task_current(rq, p)) {
4048 u64 delta_exec; 4051 u64 delta_exec;
4049 4052
4050 update_rq_clock(rq); 4053 update_rq_clock(rq);
4051 delta_exec = rq->clock - p->se.exec_start; 4054 delta_exec = rq->clock - p->se.exec_start;
4052 if ((s64)delta_exec > 0) 4055 if ((s64)delta_exec > 0)
4053 return delta_exec; 4056 ns = delta_exec;
4054 } 4057 }
4055 return 0;
4056}
4057
4058/*
4059 * Return p->sum_exec_runtime plus any more ns on the sched_clock
4060 * that have not yet been banked in case the task is currently running.
4061 */
4062unsigned long long task_sched_runtime(struct task_struct *p)
4063{
4064 unsigned long flags;
4065 u64 ns;
4066 struct rq *rq;
4067
4068 rq = task_rq_lock(p, &flags);
4069 ns = p->se.sum_exec_runtime + task_delta_exec(p, rq);
4070 task_rq_unlock(rq, &flags);
4071
4072 return ns;
4073}
4074
4075/*
4076 * Return sum_exec_runtime for the thread group plus any more ns on the
4077 * sched_clock that have not yet been banked in case the task is currently
4078 * running.
4079 */
4080unsigned long long thread_group_sched_runtime(struct task_struct *p)
4081{
4082 unsigned long flags;
4083 u64 ns;
4084 struct rq *rq;
4085 struct task_cputime totals;
4086
4087 rq = task_rq_lock(p, &flags);
4088 thread_group_cputime(p, &totals);
4089 ns = totals.sum_exec_runtime + task_delta_exec(p, rq);
4090 task_rq_unlock(rq, &flags);
4091 4058
4092 return ns; 4059 return ns;
4093} 4060}