* [PATCH 0/2] cputime: Fixes
@ 2013-02-23 16:28 Frederic Weisbecker
2013-02-23 16:28 ` [PATCH 1/2] cputime: fix compiler warning caused by timeval_to_cputime() Frederic Weisbecker
2013-02-23 16:28 ` [PATCH 2/2] cputime: Use local_clock() for full dynticks cputime accounting Frederic Weisbecker
0 siblings, 2 replies; 5+ messages in thread
From: Frederic Weisbecker @ 2013-02-23 16:28 UTC (permalink / raw)
To: Ingo Molnar
Cc: LKML, Frederic Weisbecker, Thomas Gleixner, Li Zhong,
Peter Zijlstra, Steven Rostedt, Kevin Hilman
Hi,
Just a couple of non-regression fixes on top of Linus tree.
Thanks.
Frederic Weisbecker (1):
cputime: Use local_clock() for full dynticks cputime accounting
Li Zhong (1):
cputime: fix compiler warning caused by timeval_to_cputime()
include/asm-generic/cputime_nsecs.h | 2 +-
kernel/sched/cputime.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
--
1.7.5.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] cputime: fix compiler warning caused by timeval_to_cputime()
2013-02-23 16:28 [PATCH 0/2] cputime: Fixes Frederic Weisbecker
@ 2013-02-23 16:28 ` Frederic Weisbecker
2013-02-24 12:21 ` [tip:sched/urgent] cputime: Constify timeval_to_cputime(timeval) argument tip-bot for Li Zhong
2013-02-23 16:28 ` [PATCH 2/2] cputime: Use local_clock() for full dynticks cputime accounting Frederic Weisbecker
1 sibling, 1 reply; 5+ messages in thread
From: Frederic Weisbecker @ 2013-02-23 16:28 UTC (permalink / raw)
To: Ingo Molnar
Cc: LKML, Li Zhong, Frederic Weisbecker, Steven Rostedt,
Thomas Gleixner, Kevin Hilman
From: Li Zhong <zhong@linux.vnet.ibm.com>
Saw the following compiler warning on next tree:
kernel/itimer.c: In function 'set_cpu_itimer':
kernel/itimer.c:152:2: warning: passing argument 1 of
'timeval_to_cputime' discards 'const' qualifier from pointer target type
[enabled by default]
...
timeval_to_cputime() is always passed a constant timeval in
argument, we need to teach the nsecs based cputime implementation
about that.
Signed-off-by: Li Zhong <zhong@linux.vnet.ibm.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Kevin Hilman <khilman@linaro.org>
---
include/asm-generic/cputime_nsecs.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/include/asm-generic/cputime_nsecs.h b/include/asm-generic/cputime_nsecs.h
index b6485ca..a8ece9a 100644
--- a/include/asm-generic/cputime_nsecs.h
+++ b/include/asm-generic/cputime_nsecs.h
@@ -76,7 +76,7 @@ static inline void cputime_to_timespec(const cputime_t ct, struct timespec *val)
/*
* Convert cputime <-> timeval (msec)
*/
-static inline cputime_t timeval_to_cputime(struct timeval *val)
+static inline cputime_t timeval_to_cputime(const struct timeval *val)
{
u64 ret = val->tv_sec * NSEC_PER_SEC + val->tv_usec * NSEC_PER_USEC;
return (__force cputime_t) ret;
--
1.7.5.4
^ permalink raw reply [flat|nested] 5+ messages in thread* [tip:sched/urgent] cputime: Constify timeval_to_cputime(timeval) argument
2013-02-23 16:28 ` [PATCH 1/2] cputime: fix compiler warning caused by timeval_to_cputime() Frederic Weisbecker
@ 2013-02-24 12:21 ` tip-bot for Li Zhong
0 siblings, 0 replies; 5+ messages in thread
From: tip-bot for Li Zhong @ 2013-02-24 12:21 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, hpa, mingo, zhong, fweisbec, rostedt, tglx, khilman
Commit-ID: c78a4bcd1a879b39fb7646c887b0c195f1018909
Gitweb: http://git.kernel.org/tip/c78a4bcd1a879b39fb7646c887b0c195f1018909
Author: Li Zhong <zhong@linux.vnet.ibm.com>
AuthorDate: Sat, 23 Feb 2013 17:28:44 +0100
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Sun, 24 Feb 2013 12:57:15 +0100
cputime: Constify timeval_to_cputime(timeval) argument
Saw the following compiler warning on the linux-next tree:
kernel/itimer.c: In function 'set_cpu_itimer':
kernel/itimer.c:152:2: warning: passing argument 1 of 'timeval_to_cputime' discards 'const' qualifier from pointer target type [enabled by default]
...
timeval_to_cputime() is always passed a constant timeval in
argument, we need to teach the nsecs based cputime
implementation about that.
Signed-off-by: Li Zhong <zhong@linux.vnet.ibm.com>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Kevin Hilman <khilman@linaro.org>
Link: http://lkml.kernel.org/r/1361636925-22288-2-git-send-email-fweisbec@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Kevin Hilman <khilman@linaro.org>
---
include/asm-generic/cputime_nsecs.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/asm-generic/cputime_nsecs.h b/include/asm-generic/cputime_nsecs.h
index b6485ca..a8ece9a 100644
--- a/include/asm-generic/cputime_nsecs.h
+++ b/include/asm-generic/cputime_nsecs.h
@@ -76,7 +76,7 @@ static inline void cputime_to_timespec(const cputime_t ct, struct timespec *val)
/*
* Convert cputime <-> timeval (msec)
*/
-static inline cputime_t timeval_to_cputime(struct timeval *val)
+static inline cputime_t timeval_to_cputime(const struct timeval *val)
{
u64 ret = val->tv_sec * NSEC_PER_SEC + val->tv_usec * NSEC_PER_USEC;
return (__force cputime_t) ret;
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] cputime: Use local_clock() for full dynticks cputime accounting
2013-02-23 16:28 [PATCH 0/2] cputime: Fixes Frederic Weisbecker
2013-02-23 16:28 ` [PATCH 1/2] cputime: fix compiler warning caused by timeval_to_cputime() Frederic Weisbecker
@ 2013-02-23 16:28 ` Frederic Weisbecker
2013-02-24 12:22 ` [tip:sched/urgent] " tip-bot for Frederic Weisbecker
1 sibling, 1 reply; 5+ messages in thread
From: Frederic Weisbecker @ 2013-02-23 16:28 UTC (permalink / raw)
To: Ingo Molnar
Cc: LKML, Frederic Weisbecker, Li Zhong, Peter Zijlstra,
Steven Rostedt, Thomas Gleixner, Kevin Hilman
Running the full dynticks cputime accounting with preemptible
kernel debugging trigger the following warning:
[ 4.488303] BUG: using smp_processor_id() in preemptible [00000000] code: init/1
[ 4.490971] caller is native_sched_clock+0x22/0x80
[ 4.493663] Pid: 1, comm: init Not tainted 3.8.0+ #13
[ 4.496376] Call Trace:
[ 4.498996] [<ffffffff813410eb>] debug_smp_processor_id+0xdb/0xf0
[ 4.501716] [<ffffffff8101e642>] native_sched_clock+0x22/0x80
[ 4.504434] [<ffffffff8101db99>] sched_clock+0x9/0x10
[ 4.507185] [<ffffffff81096ccd>] fetch_task_cputime+0xad/0x120
[ 4.509916] [<ffffffff81096dd5>] task_cputime+0x35/0x60
[ 4.512622] [<ffffffff810f146e>] acct_update_integrals+0x1e/0x40
[ 4.515372] [<ffffffff8117d2cf>] do_execve_common+0x4ff/0x5c0
[ 4.518117] [<ffffffff8117cf14>] ? do_execve_common+0x144/0x5c0
[ 4.520844] [<ffffffff81867a10>] ? rest_init+0x160/0x160
[ 4.523554] [<ffffffff8117d457>] do_execve+0x37/0x40
[ 4.526276] [<ffffffff810021a3>] run_init_process+0x23/0x30
[ 4.528953] [<ffffffff81867aac>] kernel_init+0x9c/0xf0
[ 4.531608] [<ffffffff8188356c>] ret_from_fork+0x7c/0xb0
We use sched_clock() to perform and fixup the cputime accounting.
However we are calling it with preemption enabled from the read side,
which trigger the bug above.
To fix this up, use local_clock() instead. It takes care of preemption
and also provide a more reliable clock source. This is welcome for
this kind of statistic that is widely relied on in userspace.
Reported-by: Thomas Gleixner <tglx@linutronix.de>
Reported-by: Ingo Molnar <mingo@kernel.org>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Li Zhong <zhong@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Kevin Hilman <khilman@linaro.org>
---
kernel/sched/cputime.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index 9857329..ed12cbb 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -604,7 +604,7 @@ static unsigned long long vtime_delta(struct task_struct *tsk)
{
unsigned long long clock;
- clock = sched_clock();
+ clock = local_clock();
if (clock < tsk->vtime_snap)
return 0;
--
1.7.5.4
^ permalink raw reply [flat|nested] 5+ messages in thread* [tip:sched/urgent] cputime: Use local_clock() for full dynticks cputime accounting
2013-02-23 16:28 ` [PATCH 2/2] cputime: Use local_clock() for full dynticks cputime accounting Frederic Weisbecker
@ 2013-02-24 12:22 ` tip-bot for Frederic Weisbecker
0 siblings, 0 replies; 5+ messages in thread
From: tip-bot for Frederic Weisbecker @ 2013-02-24 12:22 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, hpa, mingo, peterz, zhong, fweisbec, rostedt, tglx,
khilman
Commit-ID: 7f6575f1fb963d5231afbceecd3feadb6ab58cd3
Gitweb: http://git.kernel.org/tip/7f6575f1fb963d5231afbceecd3feadb6ab58cd3
Author: Frederic Weisbecker <fweisbec@gmail.com>
AuthorDate: Sat, 23 Feb 2013 17:28:45 +0100
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Sun, 24 Feb 2013 12:57:16 +0100
cputime: Use local_clock() for full dynticks cputime accounting
Running the full dynticks cputime accounting with preemptible
kernel debugging trigger the following warning:
[ 4.488303] BUG: using smp_processor_id() in preemptible [00000000] code: init/1
[ 4.490971] caller is native_sched_clock+0x22/0x80
[ 4.493663] Pid: 1, comm: init Not tainted 3.8.0+ #13
[ 4.496376] Call Trace:
[ 4.498996] [<ffffffff813410eb>] debug_smp_processor_id+0xdb/0xf0
[ 4.501716] [<ffffffff8101e642>] native_sched_clock+0x22/0x80
[ 4.504434] [<ffffffff8101db99>] sched_clock+0x9/0x10
[ 4.507185] [<ffffffff81096ccd>] fetch_task_cputime+0xad/0x120
[ 4.509916] [<ffffffff81096dd5>] task_cputime+0x35/0x60
[ 4.512622] [<ffffffff810f146e>] acct_update_integrals+0x1e/0x40
[ 4.515372] [<ffffffff8117d2cf>] do_execve_common+0x4ff/0x5c0
[ 4.518117] [<ffffffff8117cf14>] ? do_execve_common+0x144/0x5c0
[ 4.520844] [<ffffffff81867a10>] ? rest_init+0x160/0x160
[ 4.523554] [<ffffffff8117d457>] do_execve+0x37/0x40
[ 4.526276] [<ffffffff810021a3>] run_init_process+0x23/0x30
[ 4.528953] [<ffffffff81867aac>] kernel_init+0x9c/0xf0
[ 4.531608] [<ffffffff8188356c>] ret_from_fork+0x7c/0xb0
We use sched_clock() to perform and fixup the cputime
accounting. However we are calling it with preemption enabled
from the read side, which trigger the bug above.
To fix this up, use local_clock() instead. It takes care of
preemption and also provide a more reliable clock source. This
is welcome for this kind of statistic that is widely relied on
in userspace.
Reported-by: Thomas Gleixner <tglx@linutronix.de>
Reported-by: Ingo Molnar <mingo@kernel.org>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Li Zhong <zhong@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Kevin Hilman <khilman@linaro.org>
Link: http://lkml.kernel.org/r/1361636925-22288-3-git-send-email-fweisbec@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
kernel/sched/cputime.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c
index 9857329..ed12cbb 100644
--- a/kernel/sched/cputime.c
+++ b/kernel/sched/cputime.c
@@ -604,7 +604,7 @@ static unsigned long long vtime_delta(struct task_struct *tsk)
{
unsigned long long clock;
- clock = sched_clock();
+ clock = local_clock();
if (clock < tsk->vtime_snap)
return 0;
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-02-24 12:24 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-23 16:28 [PATCH 0/2] cputime: Fixes Frederic Weisbecker
2013-02-23 16:28 ` [PATCH 1/2] cputime: fix compiler warning caused by timeval_to_cputime() Frederic Weisbecker
2013-02-24 12:21 ` [tip:sched/urgent] cputime: Constify timeval_to_cputime(timeval) argument tip-bot for Li Zhong
2013-02-23 16:28 ` [PATCH 2/2] cputime: Use local_clock() for full dynticks cputime accounting Frederic Weisbecker
2013-02-24 12:22 ` [tip:sched/urgent] " tip-bot for Frederic Weisbecker
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome