* [PATCH] x86: tsc: get rid of custom DIV_ROUND
@ 2014-06-19 1:58 Michal Nazarewicz
2014-06-19 2:19 ` David Rientjes
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Michal Nazarewicz @ 2014-06-19 1:58 UTC (permalink / raw)
To: Peter Zijlstra, Thomas Gleixner; +Cc: x86, linux-kernel, Michal Nazarewicz
When invoced for positive values, DIV_ROUND macro defined in
arch/x86/kernel/tsc.c behaves exactly like DIV_ROUND_CLOSEST from
include/linux/kernel.h file, so remove the custom macro in favour
of the shared one.
Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
---
arch/x86/kernel/tsc.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
No changes after compilation:
$ ll tsc.o.*
-rw------- 1 mpn eng 46497 Jun 19 03:54 tsc.o.after
-rw------- 1 mpn eng 46497 Jun 19 03:55 tsc.o.before
$ objdump -d tsc.o.before >tsc.s.before
$ objdump -d tsc.o.after >tsc.s.after
$ diff -u tsc.s.before tsc.s.after
--- tsc.s.before 2014-06-19 03:56:54.880545041 +0200
+++ tsc.s.after 2014-06-19 03:56:54.884545079 +0200
@@ -1,5 +1,5 @@
-tsc.o.before: file format elf64-x86-64
+tsc.o.after: file format elf64-x86-64
Disassembly of section .text:
$
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 57e5ce1..02f21c0 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -234,9 +234,6 @@ static inline unsigned long long cycles_2_ns(unsigned long long cyc)
return ns;
}
-/* XXX surely we already have this someplace in the kernel?! */
-#define DIV_ROUND(n, d) (((n) + ((d) / 2)) / (d))
-
static void set_cyc2ns_scale(unsigned long cpu_khz, int cpu)
{
unsigned long long tsc_now, ns_now;
@@ -259,7 +256,8 @@ static void set_cyc2ns_scale(unsigned long cpu_khz, int cpu)
* time function is continuous; see the comment near struct
* cyc2ns_data.
*/
- data->cyc2ns_mul = DIV_ROUND(NSEC_PER_MSEC << CYC2NS_SCALE_FACTOR, cpu_khz);
+ data->cyc2ns_mul = DIV_ROUND_CLOSEST(
+ NSEC_PER_MSEC << CYC2NS_SCALE_FACTOR, cpu_khz);
data->cyc2ns_shift = CYC2NS_SCALE_FACTOR;
data->cyc2ns_offset = ns_now -
mul_u64_u32_shr(tsc_now, data->cyc2ns_mul, CYC2NS_SCALE_FACTOR);
--
2.0.0.526.g5318336
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] x86: tsc: get rid of custom DIV_ROUND
2014-06-19 1:58 [PATCH] x86: tsc: get rid of custom DIV_ROUND Michal Nazarewicz
@ 2014-06-19 2:19 ` David Rientjes
2014-06-20 5:12 ` [tip:x86/cleanups] x86/tsc: Get rid of custom DIV_ROUND() macro tip-bot for Michal Nazarewicz
2014-06-23 9:18 ` [PATCH] x86: tsc: get rid of custom DIV_ROUND Peter Zijlstra
2 siblings, 0 replies; 4+ messages in thread
From: David Rientjes @ 2014-06-19 2:19 UTC (permalink / raw)
To: Michal Nazarewicz; +Cc: Peter Zijlstra, Thomas Gleixner, x86, linux-kernel
On Thu, 19 Jun 2014, Michal Nazarewicz wrote:
> When invoced for positive values, DIV_ROUND macro defined in
> arch/x86/kernel/tsc.c behaves exactly like DIV_ROUND_CLOSEST from
> include/linux/kernel.h file, so remove the custom macro in favour
> of the shared one.
>
> Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
Acked-by: David Rientjes <rientjes@google.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [tip:x86/cleanups] x86/tsc: Get rid of custom DIV_ROUND() macro
2014-06-19 1:58 [PATCH] x86: tsc: get rid of custom DIV_ROUND Michal Nazarewicz
2014-06-19 2:19 ` David Rientjes
@ 2014-06-20 5:12 ` tip-bot for Michal Nazarewicz
2014-06-23 9:18 ` [PATCH] x86: tsc: get rid of custom DIV_ROUND Peter Zijlstra
2 siblings, 0 replies; 4+ messages in thread
From: tip-bot for Michal Nazarewicz @ 2014-06-20 5:12 UTC (permalink / raw)
To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, tglx, rientjes, mina86
Commit-ID: 891715793f0451e5114d200be932ac14ce8521a3
Gitweb: http://git.kernel.org/tip/891715793f0451e5114d200be932ac14ce8521a3
Author: Michal Nazarewicz <mina86@mina86.com>
AuthorDate: Thu, 19 Jun 2014 03:58:36 +0200
Committer: H. Peter Anvin <hpa@zytor.com>
CommitDate: Thu, 19 Jun 2014 22:04:50 -0700
x86/tsc: Get rid of custom DIV_ROUND() macro
When invoced for positive values, DIV_ROUND macro defined in
arch/x86/kernel/tsc.c behaves exactly like DIV_ROUND_CLOSEST from
include/linux/kernel.h file, so remove the custom macro in favour
of the shared one.
[ hpa: changed line breaks ]
Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
Link: http://lkml.kernel.org/r/1403143116-21755-1-git-send-email-mina86@mina86.com
Acked-by: David Rientjes <rientjes@google.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
---
arch/x86/kernel/tsc.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 57e5ce1..8764232 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -234,9 +234,6 @@ static inline unsigned long long cycles_2_ns(unsigned long long cyc)
return ns;
}
-/* XXX surely we already have this someplace in the kernel?! */
-#define DIV_ROUND(n, d) (((n) + ((d) / 2)) / (d))
-
static void set_cyc2ns_scale(unsigned long cpu_khz, int cpu)
{
unsigned long long tsc_now, ns_now;
@@ -259,7 +256,9 @@ static void set_cyc2ns_scale(unsigned long cpu_khz, int cpu)
* time function is continuous; see the comment near struct
* cyc2ns_data.
*/
- data->cyc2ns_mul = DIV_ROUND(NSEC_PER_MSEC << CYC2NS_SCALE_FACTOR, cpu_khz);
+ data->cyc2ns_mul =
+ DIV_ROUND_CLOSEST(NSEC_PER_MSEC << CYC2NS_SCALE_FACTOR,
+ cpu_khz);
data->cyc2ns_shift = CYC2NS_SCALE_FACTOR;
data->cyc2ns_offset = ns_now -
mul_u64_u32_shr(tsc_now, data->cyc2ns_mul, CYC2NS_SCALE_FACTOR);
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] x86: tsc: get rid of custom DIV_ROUND
2014-06-19 1:58 [PATCH] x86: tsc: get rid of custom DIV_ROUND Michal Nazarewicz
2014-06-19 2:19 ` David Rientjes
2014-06-20 5:12 ` [tip:x86/cleanups] x86/tsc: Get rid of custom DIV_ROUND() macro tip-bot for Michal Nazarewicz
@ 2014-06-23 9:18 ` Peter Zijlstra
2 siblings, 0 replies; 4+ messages in thread
From: Peter Zijlstra @ 2014-06-23 9:18 UTC (permalink / raw)
To: Michal Nazarewicz; +Cc: Thomas Gleixner, x86, linux-kernel
On Thu, Jun 19, 2014 at 03:58:36AM +0200, Michal Nazarewicz wrote:
> When invoced for positive values, DIV_ROUND macro defined in
> arch/x86/kernel/tsc.c behaves exactly like DIV_ROUND_CLOSEST from
> include/linux/kernel.h file, so remove the custom macro in favour
> of the shared one.
See, I knew we'd had one. _CLOSEST is a dumb postfix though, its the
default whenever people talk of rounding.
> Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
> ---
> arch/x86/kernel/tsc.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> No changes after compilation:
>
> $ ll tsc.o.*
> -rw------- 1 mpn eng 46497 Jun 19 03:54 tsc.o.after
> -rw------- 1 mpn eng 46497 Jun 19 03:55 tsc.o.before
> $ objdump -d tsc.o.before >tsc.s.before
> $ objdump -d tsc.o.after >tsc.s.after
> $ diff -u tsc.s.before tsc.s.after
> --- tsc.s.before 2014-06-19 03:56:54.880545041 +0200
> +++ tsc.s.after 2014-06-19 03:56:54.884545079 +0200
> @@ -1,5 +1,5 @@
>
> -tsc.o.before: file format elf64-x86-64
> +tsc.o.after: file format elf64-x86-64
>
>
> Disassembly of section .text:
> $
This diff in a diff totally confused patch.
Applies when I remove that.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-06-23 9:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-19 1:58 [PATCH] x86: tsc: get rid of custom DIV_ROUND Michal Nazarewicz
2014-06-19 2:19 ` David Rientjes
2014-06-20 5:12 ` [tip:x86/cleanups] x86/tsc: Get rid of custom DIV_ROUND() macro tip-bot for Michal Nazarewicz
2014-06-23 9:18 ` [PATCH] x86: tsc: get rid of custom DIV_ROUND Peter Zijlstra
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.