From: tip-bot for Peter Zijlstra <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, cl@linux.com,
tglx@linutronix.de, fweisbec@gmail.com, mingo@kernel.org,
hpa@zytor.com, kosaki.motohiro@jp.fujitsu.com, riel@redhat.com,
oleg@redhat.com, sgruszka@redhat.com, tj@kernel.org,
torvalds@linux-foundation.org
Subject: [tip:sched/urgent] sched/cputime: Fix cpu_timer_sample_group() double accounting
Date: Sun, 16 Nov 2014 01:50:31 -0800 [thread overview]
Message-ID: <tip-23cfa361f3e54a3e184a5e126bbbdd95f984881a@git.kernel.org> (raw)
In-Reply-To: <20141112113737.GI10476@twins.programming.kicks-ass.net>
Commit-ID: 23cfa361f3e54a3e184a5e126bbbdd95f984881a
Gitweb: http://git.kernel.org/tip/23cfa361f3e54a3e184a5e126bbbdd95f984881a
Author: Peter Zijlstra <peterz@infradead.org>
AuthorDate: Wed, 12 Nov 2014 12:37:37 +0100
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Sun, 16 Nov 2014 10:04:18 +0100
sched/cputime: Fix cpu_timer_sample_group() double accounting
While looking over the cpu-timer code I found that we appear to add
the delta for the calling task twice, through:
cpu_timer_sample_group()
thread_group_cputimer()
thread_group_cputime()
times->sum_exec_runtime += task_sched_runtime();
*sample = cputime.sum_exec_runtime + task_delta_exec();
Which would make the sample run ahead, making the sleep short.
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Stanislaw Gruszka <sgruszka@redhat.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Tejun Heo <tj@kernel.org>
Link: http://lkml.kernel.org/r/20141112113737.GI10476@twins.programming.kicks-ass.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
include/linux/kernel_stat.h | 5 -----
kernel/sched/core.c | 13 -------------
kernel/time/posix-cpu-timers.c | 2 +-
3 files changed, 1 insertion(+), 19 deletions(-)
diff --git a/include/linux/kernel_stat.h b/include/linux/kernel_stat.h
index 8422b4e..b9376cd 100644
--- a/include/linux/kernel_stat.h
+++ b/include/linux/kernel_stat.h
@@ -77,11 +77,6 @@ static inline unsigned int kstat_cpu_irqs_sum(unsigned int cpu)
return kstat_cpu(cpu).irqs_sum;
}
-/*
- * Lock/unlock the current runqueue - to extract task statistics:
- */
-extern unsigned long long task_delta_exec(struct task_struct *);
-
extern void account_user_time(struct task_struct *, cputime_t, cputime_t);
extern void account_system_time(struct task_struct *, int, cputime_t, cputime_t);
extern void account_steal_time(cputime_t);
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 5f12ca6..797a6c8 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2499,19 +2499,6 @@ static u64 do_task_delta_exec(struct task_struct *p, struct rq *rq)
return ns;
}
-unsigned long long task_delta_exec(struct task_struct *p)
-{
- unsigned long flags;
- struct rq *rq;
- u64 ns = 0;
-
- rq = task_rq_lock(p, &flags);
- ns = do_task_delta_exec(p, rq);
- task_rq_unlock(rq, p, &flags);
-
- return ns;
-}
-
/*
* Return accounted runtime for the task.
* In case the task is currently running, return the runtime plus current's
diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
index 492b986..a16b678 100644
--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -553,7 +553,7 @@ static int cpu_timer_sample_group(const clockid_t which_clock,
*sample = cputime_to_expires(cputime.utime);
break;
case CPUCLOCK_SCHED:
- *sample = cputime.sum_exec_runtime + task_delta_exec(p);
+ *sample = cputime.sum_exec_runtime;
break;
}
return 0;
next prev parent reply other threads:[~2014-11-16 9:51 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-12 10:29 [PATCH] sched/cputime: fix clock_nanosleep/clock_gettime inconsistency Stanislaw Gruszka
2014-11-12 11:15 ` Peter Zijlstra
2014-11-12 11:37 ` Peter Zijlstra
2014-11-12 11:45 ` Peter Zijlstra
2014-11-12 12:27 ` Stanislaw Gruszka
2014-11-12 12:52 ` Peter Zijlstra
2014-11-16 9:50 ` tip-bot for Peter Zijlstra [this message]
2014-11-12 12:21 ` Stanislaw Gruszka
2014-11-12 12:51 ` Peter Zijlstra
2014-11-12 15:58 ` [PATCH v2] " Stanislaw Gruszka
2014-11-12 16:06 ` Peter Zijlstra
2014-11-12 16:17 ` Stanislaw Gruszka
2014-11-12 17:12 ` Peter Zijlstra
2014-11-12 16:45 ` Peter Zijlstra
2014-11-12 16:53 ` Stanislaw Gruszka
2014-11-12 16:56 ` Peter Zijlstra
2014-11-16 9:50 ` [tip:sched/urgent] sched/cputime: Fix clock_nanosleep()/ clock_gettime() inconsistency tip-bot for Stanislaw Gruszka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-23cfa361f3e54a3e184a5e126bbbdd95f984881a@git.kernel.org \
--to=tipbot@zytor.com \
--cc=cl@linux.com \
--cc=fweisbec@gmail.com \
--cc=hpa@zytor.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=riel@redhat.com \
--cc=sgruszka@redhat.com \
--cc=tglx@linutronix.de \
--cc=tj@kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox