* [GIT PULL] nohz: A few improvements
@ 2013-04-26 14:53 Frederic Weisbecker
2013-04-26 14:53 ` [PATCH 1/2] nohz: Select VIRT_CPU_ACCOUNTING_GEN from full dynticks config Frederic Weisbecker
2013-04-26 14:53 ` [PATCH 2/2] cputime_nsecs: use math64.h for nsec resolution conversion helpers Frederic Weisbecker
0 siblings, 2 replies; 8+ messages in thread
From: Frederic Weisbecker @ 2013-04-26 14:53 UTC (permalink / raw)
To: Ingo Molnar
Cc: LKML, Frederic Weisbecker, Kevin Hilman, Christoph Lameter,
Hakan Akkan, Li Zhong, Paul E. McKenney, Paul Gortmaker,
Peter Zijlstra, Steven Rostedt, Thomas Gleixner
Ingo,
Please pull the timers/nohz branch that can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/frederic/linux-dynticks.git
timers/nohz
Changes:
* Get rid of the passive dependency on VIRT_CPU_ACCOUNTING_GEN (finally!)
* Preparation patch to remove the dependency on CONFIG_64BITS
Thanks,
Frederic
---
Frederic Weisbecker (1):
nohz: Select VIRT_CPU_ACCOUNTING_GEN from full dynticks config
Kevin Hilman (1):
cputime_nsecs: use math64.h for nsec resolution conversion helpers
include/asm-generic/cputime_nsecs.h | 28 +++++++++++++++++++---------
init/Kconfig | 8 ++++----
kernel/time/Kconfig | 4 +++-
3 files changed, 26 insertions(+), 14 deletions(-)
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH 1/2] nohz: Select VIRT_CPU_ACCOUNTING_GEN from full dynticks config 2013-04-26 14:53 [GIT PULL] nohz: A few improvements Frederic Weisbecker @ 2013-04-26 14:53 ` Frederic Weisbecker 2013-04-26 15:39 ` Paul E. McKenney 2013-05-13 21:16 ` Kevin Hilman 2013-04-26 14:53 ` [PATCH 2/2] cputime_nsecs: use math64.h for nsec resolution conversion helpers Frederic Weisbecker 1 sibling, 2 replies; 8+ messages in thread From: Frederic Weisbecker @ 2013-04-26 14:53 UTC (permalink / raw) To: Ingo Molnar Cc: LKML, Frederic Weisbecker, Christoph Lameter, Hakan Akkan, Kevin Hilman, Li Zhong, Paul E. McKenney, Paul Gortmaker, Peter Zijlstra, Steven Rostedt, Thomas Gleixner Turn the full dynticks passive dependency on VIRT_CPU_ACCOUNTING_GEN to an active one. The full dynticks Kconfig is currently hidden behind the full dynticks cputime accounting, which is an awkward and counter-intuitive layout: the user first has to select the dynticks cputime accounting in order to make the full dynticks feature to be visible. We definetly want it the other way around. The usual way to perform this kind of active dependency is use "select" on the depended target. Now we can't use the Kconfig "select" instruction when the target is a "choice". So this patch inspires on how the RCU subsystem Kconfig interact with its dependencies on SMP and PREEMPT: we make sure that cputime accounting can't propose another option than VIRT_CPU_ACCOUNTING_GEN when NO_HZ_FULL is selected by using the right "depends on" instruction for each cputime accounting choices. Reported-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Christoph Lameter <cl@linux.com> Cc: Hakan Akkan <hakanakkan@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Kevin Hilman <khilman@linaro.org> Cc: Li Zhong <zhong@linux.vnet.ibm.com> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: Paul Gortmaker <paul.gortmaker@windriver.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Thomas Gleixner <tglx@linutronix.de> --- init/Kconfig | 8 ++++---- kernel/time/Kconfig | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/init/Kconfig b/init/Kconfig index edc8132..572db53 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -306,7 +306,7 @@ choice # Kind of a stub config for the pure tick based cputime accounting config TICK_CPU_ACCOUNTING bool "Simple tick based cputime accounting" - depends on !S390 + depends on !S390 && !NO_HZ_FULL help This is the basic tick based cputime accounting that maintains statistics about user, system and idle time spent on per jiffies @@ -316,7 +316,7 @@ config TICK_CPU_ACCOUNTING config VIRT_CPU_ACCOUNTING_NATIVE bool "Deterministic task and CPU time accounting" - depends on HAVE_VIRT_CPU_ACCOUNTING + depends on HAVE_VIRT_CPU_ACCOUNTING && !NO_HZ_FULL select VIRT_CPU_ACCOUNTING help Select this option to enable more accurate task and CPU time @@ -329,7 +329,7 @@ config VIRT_CPU_ACCOUNTING_NATIVE config VIRT_CPU_ACCOUNTING_GEN bool "Full dynticks CPU time accounting" - depends on HAVE_CONTEXT_TRACKING && 64BIT + depends on HAVE_CONTEXT_TRACKING && 64BIT && NO_HZ_FULL select VIRT_CPU_ACCOUNTING select CONTEXT_TRACKING help @@ -346,7 +346,7 @@ config VIRT_CPU_ACCOUNTING_GEN config IRQ_TIME_ACCOUNTING bool "Fine granularity task level IRQ time accounting" - depends on HAVE_IRQ_TIME_ACCOUNTING + depends on HAVE_IRQ_TIME_ACCOUNTING && !NO_HZ_FULL help Select this option to enable fine granularity task irq time accounting. This is done by reading a timestamp on each diff --git a/kernel/time/Kconfig b/kernel/time/Kconfig index 1ea2bba..a2ddd65 100644 --- a/kernel/time/Kconfig +++ b/kernel/time/Kconfig @@ -104,11 +104,13 @@ config NO_HZ_FULL depends on SMP # RCU_USER_QS dependency depends on HAVE_CONTEXT_TRACKING - depends on VIRT_CPU_ACCOUNTING_GEN + # VIRT_CPU_ACCOUNTING_GEN dependency + depends on 64BIT select NO_HZ_COMMON select RCU_USER_QS select RCU_NOCB_CPU select RCU_NOCB_CPU_ALL + select VIRT_CPU_ACCOUNTING_GEN select CONTEXT_TRACKING_FORCE select IRQ_WORK help -- 1.7.5.4 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] nohz: Select VIRT_CPU_ACCOUNTING_GEN from full dynticks config 2013-04-26 14:53 ` [PATCH 1/2] nohz: Select VIRT_CPU_ACCOUNTING_GEN from full dynticks config Frederic Weisbecker @ 2013-04-26 15:39 ` Paul E. McKenney 2013-04-26 16:22 ` Frederic Weisbecker 2013-05-13 21:16 ` Kevin Hilman 1 sibling, 1 reply; 8+ messages in thread From: Paul E. McKenney @ 2013-04-26 15:39 UTC (permalink / raw) To: Frederic Weisbecker Cc: Ingo Molnar, LKML, Christoph Lameter, Hakan Akkan, Kevin Hilman, Li Zhong, Paul Gortmaker, Peter Zijlstra, Steven Rostedt, Thomas Gleixner On Fri, Apr 26, 2013 at 04:53:26PM +0200, Frederic Weisbecker wrote: > Turn the full dynticks passive dependency on VIRT_CPU_ACCOUNTING_GEN > to an active one. > > The full dynticks Kconfig is currently hidden behind the full dynticks > cputime accounting, which is an awkward and counter-intuitive layout: > the user first has to select the dynticks cputime accounting in order > to make the full dynticks feature to be visible. > > We definetly want it the other way around. The usual way to perform > this kind of active dependency is use "select" on the depended target. > Now we can't use the Kconfig "select" instruction when the target is > a "choice". > > So this patch inspires on how the RCU subsystem Kconfig interact > with its dependencies on SMP and PREEMPT: we make sure that cputime > accounting can't propose another option than VIRT_CPU_ACCOUNTING_GEN > when NO_HZ_FULL is selected by using the right "depends on" instruction > for each cputime accounting choices. Ah, putting it back onto VIRT_CPU_ACCOUNTING_GEN, cute! > Reported-by: Ingo Molnar <mingo@kernel.org> > Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> > Cc: Christoph Lameter <cl@linux.com> > Cc: Hakan Akkan <hakanakkan@gmail.com> > Cc: Ingo Molnar <mingo@kernel.org> > Cc: Kevin Hilman <khilman@linaro.org> > Cc: Li Zhong <zhong@linux.vnet.ibm.com> > Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com> > Cc: Paul Gortmaker <paul.gortmaker@windriver.com> > Cc: Peter Zijlstra <peterz@infradead.org> > Cc: Steven Rostedt <rostedt@goodmis.org> > Cc: Thomas Gleixner <tglx@linutronix.de> > --- > init/Kconfig | 8 ++++---- > kernel/time/Kconfig | 4 +++- > 2 files changed, 7 insertions(+), 5 deletions(-) > > diff --git a/init/Kconfig b/init/Kconfig > index edc8132..572db53 100644 > --- a/init/Kconfig > +++ b/init/Kconfig > @@ -306,7 +306,7 @@ choice > # Kind of a stub config for the pure tick based cputime accounting > config TICK_CPU_ACCOUNTING > bool "Simple tick based cputime accounting" > - depends on !S390 > + depends on !S390 && !NO_HZ_FULL > help > This is the basic tick based cputime accounting that maintains > statistics about user, system and idle time spent on per jiffies > @@ -316,7 +316,7 @@ config TICK_CPU_ACCOUNTING > > config VIRT_CPU_ACCOUNTING_NATIVE > bool "Deterministic task and CPU time accounting" > - depends on HAVE_VIRT_CPU_ACCOUNTING > + depends on HAVE_VIRT_CPU_ACCOUNTING && !NO_HZ_FULL > select VIRT_CPU_ACCOUNTING > help > Select this option to enable more accurate task and CPU time > @@ -329,7 +329,7 @@ config VIRT_CPU_ACCOUNTING_NATIVE > > config VIRT_CPU_ACCOUNTING_GEN > bool "Full dynticks CPU time accounting" > - depends on HAVE_CONTEXT_TRACKING && 64BIT > + depends on HAVE_CONTEXT_TRACKING && 64BIT && NO_HZ_FULL Do you really want this change? This prohibits VIRT_CPU_ACCOUNTING_GEN unless NO_HZ_FULL, which means that it can no longer be used in situations where it used to be usable. My guess is that you want to leave this particular line as it was. Thanx, Paul > select VIRT_CPU_ACCOUNTING > select CONTEXT_TRACKING > help > @@ -346,7 +346,7 @@ config VIRT_CPU_ACCOUNTING_GEN > > config IRQ_TIME_ACCOUNTING > bool "Fine granularity task level IRQ time accounting" > - depends on HAVE_IRQ_TIME_ACCOUNTING > + depends on HAVE_IRQ_TIME_ACCOUNTING && !NO_HZ_FULL > help > Select this option to enable fine granularity task irq time > accounting. This is done by reading a timestamp on each > diff --git a/kernel/time/Kconfig b/kernel/time/Kconfig > index 1ea2bba..a2ddd65 100644 > --- a/kernel/time/Kconfig > +++ b/kernel/time/Kconfig > @@ -104,11 +104,13 @@ config NO_HZ_FULL > depends on SMP > # RCU_USER_QS dependency > depends on HAVE_CONTEXT_TRACKING > - depends on VIRT_CPU_ACCOUNTING_GEN > + # VIRT_CPU_ACCOUNTING_GEN dependency > + depends on 64BIT > select NO_HZ_COMMON > select RCU_USER_QS > select RCU_NOCB_CPU > select RCU_NOCB_CPU_ALL > + select VIRT_CPU_ACCOUNTING_GEN > select CONTEXT_TRACKING_FORCE > select IRQ_WORK > help > -- > 1.7.5.4 > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] nohz: Select VIRT_CPU_ACCOUNTING_GEN from full dynticks config 2013-04-26 15:39 ` Paul E. McKenney @ 2013-04-26 16:22 ` Frederic Weisbecker 2013-04-26 23:01 ` Frederic Weisbecker 0 siblings, 1 reply; 8+ messages in thread From: Frederic Weisbecker @ 2013-04-26 16:22 UTC (permalink / raw) To: Paul E. McKenney Cc: Ingo Molnar, LKML, Christoph Lameter, Hakan Akkan, Kevin Hilman, Li Zhong, Paul Gortmaker, Peter Zijlstra, Steven Rostedt, Thomas Gleixner On Fri, Apr 26, 2013 at 08:39:56AM -0700, Paul E. McKenney wrote: > > config VIRT_CPU_ACCOUNTING_GEN > > bool "Full dynticks CPU time accounting" > > - depends on HAVE_CONTEXT_TRACKING && 64BIT > > + depends on HAVE_CONTEXT_TRACKING && 64BIT && NO_HZ_FULL > > Do you really want this change? This prohibits VIRT_CPU_ACCOUNTING_GEN > unless NO_HZ_FULL, which means that it can no longer be used in situations > where it used to be usable. My guess is that you want to leave this > particular line as it was. Hmm, this can make sense. This can be used to perform comparisons between tick-based and tickless cputime accounting easily. I'll respin. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] nohz: Select VIRT_CPU_ACCOUNTING_GEN from full dynticks config 2013-04-26 16:22 ` Frederic Weisbecker @ 2013-04-26 23:01 ` Frederic Weisbecker 2013-04-27 7:19 ` Ingo Molnar 0 siblings, 1 reply; 8+ messages in thread From: Frederic Weisbecker @ 2013-04-26 23:01 UTC (permalink / raw) To: Paul E. McKenney, Ingo Molnar Cc: LKML, Christoph Lameter, Hakan Akkan, Kevin Hilman, Li Zhong, Paul Gortmaker, Peter Zijlstra, Steven Rostedt, Thomas Gleixner 2013/4/26 Frederic Weisbecker <fweisbec@gmail.com>: > On Fri, Apr 26, 2013 at 08:39:56AM -0700, Paul E. McKenney wrote: >> > config VIRT_CPU_ACCOUNTING_GEN >> > bool "Full dynticks CPU time accounting" >> > - depends on HAVE_CONTEXT_TRACKING && 64BIT >> > + depends on HAVE_CONTEXT_TRACKING && 64BIT && NO_HZ_FULL >> >> Do you really want this change? This prohibits VIRT_CPU_ACCOUNTING_GEN >> unless NO_HZ_FULL, which means that it can no longer be used in situations >> where it used to be usable. My guess is that you want to leave this >> particular line as it was. > > Hmm, this can make sense. This can be used to perform comparisons between > tick-based and tickless cputime accounting easily. > > I'll respin. So Ingo please pull "timers/nohz-v2" instead. It does the same but keeps VIRT_CPU_ACCOUNTING_GEN available even without full dynticks (could be useful when users need something more precise than tick based cputime accounting.) HEAD is 8c23b80ec7f1f5405f07bb56c2f8378800ecf401 If you've already pulled the previous branch I'll make a delta instead. Thanks. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] nohz: Select VIRT_CPU_ACCOUNTING_GEN from full dynticks config 2013-04-26 23:01 ` Frederic Weisbecker @ 2013-04-27 7:19 ` Ingo Molnar 0 siblings, 0 replies; 8+ messages in thread From: Ingo Molnar @ 2013-04-27 7:19 UTC (permalink / raw) To: Frederic Weisbecker Cc: Paul E. McKenney, LKML, Christoph Lameter, Hakan Akkan, Kevin Hilman, Li Zhong, Paul Gortmaker, Peter Zijlstra, Steven Rostedt, Thomas Gleixner * Frederic Weisbecker <fweisbec@gmail.com> wrote: > 2013/4/26 Frederic Weisbecker <fweisbec@gmail.com>: > > On Fri, Apr 26, 2013 at 08:39:56AM -0700, Paul E. McKenney wrote: > >> > config VIRT_CPU_ACCOUNTING_GEN > >> > bool "Full dynticks CPU time accounting" > >> > - depends on HAVE_CONTEXT_TRACKING && 64BIT > >> > + depends on HAVE_CONTEXT_TRACKING && 64BIT && NO_HZ_FULL > >> > >> Do you really want this change? This prohibits VIRT_CPU_ACCOUNTING_GEN > >> unless NO_HZ_FULL, which means that it can no longer be used in situations > >> where it used to be usable. My guess is that you want to leave this > >> particular line as it was. > > > > Hmm, this can make sense. This can be used to perform comparisons between > > tick-based and tickless cputime accounting easily. > > > > I'll respin. > > So Ingo please pull "timers/nohz-v2" instead. It does the same but > keeps VIRT_CPU_ACCOUNTING_GEN available even without full dynticks > (could be useful when users need something more precise than tick > based cputime accounting.) > > HEAD is 8c23b80ec7f1f5405f07bb56c2f8378800ecf401 > > If you've already pulled the previous branch I'll make a delta instead. > > Thanks. Pulled, thanks Frederic! Ingo ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] nohz: Select VIRT_CPU_ACCOUNTING_GEN from full dynticks config 2013-04-26 14:53 ` [PATCH 1/2] nohz: Select VIRT_CPU_ACCOUNTING_GEN from full dynticks config Frederic Weisbecker 2013-04-26 15:39 ` Paul E. McKenney @ 2013-05-13 21:16 ` Kevin Hilman 1 sibling, 0 replies; 8+ messages in thread From: Kevin Hilman @ 2013-05-13 21:16 UTC (permalink / raw) To: Frederic Weisbecker Cc: Ingo Molnar, LKML, Christoph Lameter, Hakan Akkan, Li Zhong, Paul E. McKenney, Paul Gortmaker, Peter Zijlstra, Steven Rostedt, Thomas Gleixner Frederic Weisbecker <fweisbec@gmail.com> writes: > Turn the full dynticks passive dependency on VIRT_CPU_ACCOUNTING_GEN > to an active one. [...] > @@ -329,7 +329,7 @@ config VIRT_CPU_ACCOUNTING_NATIVE > > config VIRT_CPU_ACCOUNTING_GEN > bool "Full dynticks CPU time accounting" > - depends on HAVE_CONTEXT_TRACKING && 64BIT > + depends on HAVE_CONTEXT_TRACKING && 64BIT && NO_HZ_FULL > select VIRT_CPU_ACCOUNTING > select CONTEXT_TRACKING > help Existing 64-bit dependency is here... > diff --git a/kernel/time/Kconfig b/kernel/time/Kconfig > index 1ea2bba..a2ddd65 100644 > --- a/kernel/time/Kconfig > +++ b/kernel/time/Kconfig > @@ -104,11 +104,13 @@ config NO_HZ_FULL > depends on SMP > # RCU_USER_QS dependency > depends on HAVE_CONTEXT_TRACKING > - depends on VIRT_CPU_ACCOUNTING_GEN > + # VIRT_CPU_ACCOUNTING_GEN dependency > + depends on 64BIT ...and another one added here? Is there a new 64-bit dependency in NO_HZ_FULL not covered by the one already in VIRT_CPU_ACCOUNTING_GEN? Or do you have reasons to be doubly paranoid about the non 64-bit usage? ;) Kevin ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/2] cputime_nsecs: use math64.h for nsec resolution conversion helpers 2013-04-26 14:53 [GIT PULL] nohz: A few improvements Frederic Weisbecker 2013-04-26 14:53 ` [PATCH 1/2] nohz: Select VIRT_CPU_ACCOUNTING_GEN from full dynticks config Frederic Weisbecker @ 2013-04-26 14:53 ` Frederic Weisbecker 1 sibling, 0 replies; 8+ messages in thread From: Frederic Weisbecker @ 2013-04-26 14:53 UTC (permalink / raw) To: Ingo Molnar Cc: LKML, Kevin Hilman, Christoph Lameter, Hakan Akkan, Li Zhong, Paul E. McKenney, Paul Gortmaker, Peter Zijlstra, Steven Rostedt, Thomas Gleixner, Frederic Weisbecker From: Kevin Hilman <khilman@linaro.org> For the nsec resolution conversions to be useable on non 64-bit architectures, the helpers in <linux/math64.h> need to be used so the right arch-specific 64-bit math helpers can be used (e.g. do_div()) Signed-off-by: Kevin Hilman <khilman@linaro.org> Cc: Christoph Lameter <cl@linux.com> Cc: Hakan Akkan <hakanakkan@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Kevin Hilman <khilman@linaro.org> Cc: Li Zhong <zhong@linux.vnet.ibm.com> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: Paul Gortmaker <paul.gortmaker@windriver.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> --- include/asm-generic/cputime_nsecs.h | 28 +++++++++++++++++++--------- 1 files changed, 19 insertions(+), 9 deletions(-) diff --git a/include/asm-generic/cputime_nsecs.h b/include/asm-generic/cputime_nsecs.h index a8ece9a..2c9e62c 100644 --- a/include/asm-generic/cputime_nsecs.h +++ b/include/asm-generic/cputime_nsecs.h @@ -16,21 +16,27 @@ #ifndef _ASM_GENERIC_CPUTIME_NSECS_H #define _ASM_GENERIC_CPUTIME_NSECS_H +#include <linux/math64.h> + typedef u64 __nocast cputime_t; typedef u64 __nocast cputime64_t; #define cputime_one_jiffy jiffies_to_cputime(1) +#define cputime_div(__ct, divisor) div_u64((__force u64)__ct, divisor) +#define cputime_div_rem(__ct, divisor, remainder) \ + div_u64_rem((__force u64)__ct, divisor, remainder); + /* * Convert cputime <-> jiffies (HZ) */ #define cputime_to_jiffies(__ct) \ - ((__force u64)(__ct) / (NSEC_PER_SEC / HZ)) + cputime_div(__ct, NSEC_PER_SEC / HZ) #define cputime_to_scaled(__ct) (__ct) #define jiffies_to_cputime(__jif) \ (__force cputime_t)((__jif) * (NSEC_PER_SEC / HZ)) #define cputime64_to_jiffies64(__ct) \ - ((__force u64)(__ct) / (NSEC_PER_SEC / HZ)) + cputime_div(__ct, NSEC_PER_SEC / HZ) #define jiffies64_to_cputime64(__jif) \ (__force cputime64_t)((__jif) * (NSEC_PER_SEC / HZ)) @@ -45,7 +51,7 @@ typedef u64 __nocast cputime64_t; * Convert cputime <-> microseconds */ #define cputime_to_usecs(__ct) \ - ((__force u64)(__ct) / NSEC_PER_USEC) + cputime_div(__ct, NSEC_PER_USEC) #define usecs_to_cputime(__usecs) \ (__force cputime_t)((__usecs) * NSEC_PER_USEC) #define usecs_to_cputime64(__usecs) \ @@ -55,7 +61,7 @@ typedef u64 __nocast cputime64_t; * Convert cputime <-> seconds */ #define cputime_to_secs(__ct) \ - ((__force u64)(__ct) / NSEC_PER_SEC) + cputime_div(__ct, NSEC_PER_SEC) #define secs_to_cputime(__secs) \ (__force cputime_t)((__secs) * NSEC_PER_SEC) @@ -69,8 +75,10 @@ static inline cputime_t timespec_to_cputime(const struct timespec *val) } static inline void cputime_to_timespec(const cputime_t ct, struct timespec *val) { - val->tv_sec = (__force u64) ct / NSEC_PER_SEC; - val->tv_nsec = (__force u64) ct % NSEC_PER_SEC; + u32 rem; + + val->tv_sec = cputime_div_rem(ct, NSEC_PER_SEC, &rem); + val->tv_nsec = rem; } /* @@ -83,15 +91,17 @@ static inline cputime_t timeval_to_cputime(const struct timeval *val) } static inline void cputime_to_timeval(const cputime_t ct, struct timeval *val) { - val->tv_sec = (__force u64) ct / NSEC_PER_SEC; - val->tv_usec = ((__force u64) ct % NSEC_PER_SEC) / NSEC_PER_USEC; + u32 rem; + + val->tv_sec = cputime_div_rem(ct, NSEC_PER_SEC, &rem); + val->tv_usec = rem / NSEC_PER_USEC; } /* * Convert cputime <-> clock (USER_HZ) */ #define cputime_to_clock_t(__ct) \ - ((__force u64)(__ct) / (NSEC_PER_SEC / USER_HZ)) + cputime_div(__ct, (NSEC_PER_SEC / USER_HZ)) #define clock_t_to_cputime(__x) \ (__force cputime_t)((__x) * (NSEC_PER_SEC / USER_HZ)) -- 1.7.5.4 ^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-05-13 21:16 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-04-26 14:53 [GIT PULL] nohz: A few improvements Frederic Weisbecker 2013-04-26 14:53 ` [PATCH 1/2] nohz: Select VIRT_CPU_ACCOUNTING_GEN from full dynticks config Frederic Weisbecker 2013-04-26 15:39 ` Paul E. McKenney 2013-04-26 16:22 ` Frederic Weisbecker 2013-04-26 23:01 ` Frederic Weisbecker 2013-04-27 7:19 ` Ingo Molnar 2013-05-13 21:16 ` Kevin Hilman 2013-04-26 14:53 ` [PATCH 2/2] cputime_nsecs: use math64.h for nsec resolution conversion helpers Frederic Weisbecker
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox