2013-03-20 23:34:32

by Kevin Hilman

[permalink] [raw]
Subject: [PATCH 0/3] ARM: context tracking support prerequisites

This series is a set of prerequistes for getting the new context
tracking subsystem, and adaptive tickless support working on ARM.

Kevin Hilman (3):
cputime_nsecs: use math64.h for nsec resolution conversion helpers
init/Kconfig: virt CPU accounting: drop 64-bit requirment
ARM: Kconfig: allow virt CPU accounting

arch/arm/Kconfig | 1 +
include/asm-generic/cputime_nsecs.h | 28 +++++++++++++++++++---------
init/Kconfig | 2 +-
3 files changed, 21 insertions(+), 10 deletions(-)

--
1.8.2


2013-03-20 23:34:36

by Kevin Hilman

[permalink] [raw]
Subject: [PATCH 1/3] cputime_nsecs: use math64.h for nsec resolution conversion helpers

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())

Cc: Frederic Weisbecker <[email protected]>
Signed-off-by: Kevin Hilman <[email protected]>
---
include/asm-generic/cputime_nsecs.h | 28 +++++++++++++++++++---------
1 file 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.8.2

2013-03-20 23:34:45

by Kevin Hilman

[permalink] [raw]
Subject: [PATCH 3/3] ARM: Kconfig: allow virt CPU accounting

With the 64-bit requirement removed from virt CPU accounting,
allow ARM platforms to enable it.

Signed-off-by: Kevin Hilman <[email protected]>
---
arch/arm/Kconfig | 1 +
1 file changed, 1 insertion(+)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 5b71469..9473d55 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -59,6 +59,7 @@ config ARM
select CLONE_BACKWARDS
select OLD_SIGSUSPEND3
select OLD_SIGACTION
+ select HAVE_VIRT_CPU_ACCOUNTING
help
The ARM series is a line of low-power-consumption RISC chip designs
licensed by ARM Ltd and targeted at embedded applications and
--
1.8.2

2013-03-20 23:34:41

by Kevin Hilman

[permalink] [raw]
Subject: [PATCH 2/3] init/Kconfig: virt CPU accounting: drop 64-bit requirment

The 64-bit requirement can be removed after the conversion of
the conversion of the nsec granularity cputime to work on !64_BIT

Cc: Frederic Weisbecker <[email protected]>
Signed-off-by: Kevin Hilman <[email protected]>
---
init/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/init/Kconfig b/init/Kconfig
index 8a1dac2..1f1a328 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -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
select VIRT_CPU_ACCOUNTING
select CONTEXT_TRACKING
help
--
1.8.2

2013-04-11 17:10:57

by Frederic Weisbecker

[permalink] [raw]
Subject: Re: [PATCH 1/3] cputime_nsecs: use math64.h for nsec resolution conversion helpers

On Wed, Mar 20, 2013 at 04:34:25PM -0700, Kevin Hilman wrote:
> 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())
>
> Cc: Frederic Weisbecker <[email protected]>
> Signed-off-by: Kevin Hilman <[email protected]>

Ok the patch is nice!

I'm queuing it.

Thanks.

2013-04-15 14:02:45

by Kevin Hilman

[permalink] [raw]
Subject: Re: [PATCH 1/3] cputime_nsecs: use math64.h for nsec resolution conversion helpers

Frederic Weisbecker <[email protected]> writes:

> On Wed, Mar 20, 2013 at 04:34:25PM -0700, Kevin Hilman wrote:
>> 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())
>>
>> Cc: Frederic Weisbecker <[email protected]>
>> Signed-off-by: Kevin Hilman <[email protected]>
>
> Ok the patch is nice!
>
> I'm queuing it.

Thanks, did you queue PATCH 3/3 also to remove the 64-bit limitation
from VIRT_CPU_ACCOUNTING_GEN: https://lkml.org/lkml/2013/3/20/656

Kevin

2013-04-15 14:08:27

by Frederic Weisbecker

[permalink] [raw]
Subject: Re: [PATCH 1/3] cputime_nsecs: use math64.h for nsec resolution conversion helpers

2013/4/15 Kevin Hilman <[email protected]>:
> Frederic Weisbecker <[email protected]> writes:
>
>> On Wed, Mar 20, 2013 at 04:34:25PM -0700, Kevin Hilman wrote:
>>> 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())
>>>
>>> Cc: Frederic Weisbecker <[email protected]>
>>> Signed-off-by: Kevin Hilman <[email protected]>
>>
>> Ok the patch is nice!
>>
>> I'm queuing it.
>
> Thanks, did you queue PATCH 3/3 also to remove the 64-bit limitation
> from VIRT_CPU_ACCOUNTING_GEN: https://lkml.org/lkml/2013/3/20/656

Not yet, for this one I need to deeply check we haven't forgotten
anything concerning cputime_t operations in 32 bits archs.