mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] clocksource: use clocksource_freq2mult() helper
@ 2016-03-16 10:21 Alexander Kuleshov
  2016-04-07 22:28 ` John Stultz
  2016-04-08  4:55 ` John Stultz
  0 siblings, 2 replies; 3+ messages in thread
From: Alexander Kuleshov @ 2016-03-16 10:21 UTC (permalink / raw)
  To: John Stultz, Thomas Gleixner; +Cc: linux-kernel, Alexander Kuleshov

which is introduced in the 7aca0c072 commit to simplify calculation of
the mult and shift in the clocks_calc_mult_shift().

Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>
---
 kernel/time/clocksource.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
index 56ece14..de57923 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -80,9 +80,7 @@ clocks_calc_mult_shift(u32 *mult, u32 *shift, u32 from, u32 to, u32 maxsec)
 	 * accuracy and fits the maxsec conversion range:
 	 */
 	for (sft = 32; sft > 0; sft--) {
-		tmp = (u64) to << sft;
-		tmp += from / 2;
-		do_div(tmp, from);
+		tmp = clocksource_freq2mult(from, sft, to);
 		if ((tmp >> sftacc) == 0)
 			break;
 	}
-- 
2.8.0.rc2.216.g1477fb2.dirty

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] clocksource: use clocksource_freq2mult() helper
  2016-03-16 10:21 [PATCH] clocksource: use clocksource_freq2mult() helper Alexander Kuleshov
@ 2016-04-07 22:28 ` John Stultz
  2016-04-08  4:55 ` John Stultz
  1 sibling, 0 replies; 3+ messages in thread
From: John Stultz @ 2016-04-07 22:28 UTC (permalink / raw)
  To: Alexander Kuleshov; +Cc: Thomas Gleixner, lkml

On Wed, Mar 16, 2016 at 3:21 AM, Alexander Kuleshov
<kuleshovmail@gmail.com> wrote:
> which is introduced in the 7aca0c072 commit to simplify calculation of
> the mult and shift in the clocks_calc_mult_shift().
>
> Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>

Queued for testing.

thanks
-john

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] clocksource: use clocksource_freq2mult() helper
  2016-03-16 10:21 [PATCH] clocksource: use clocksource_freq2mult() helper Alexander Kuleshov
  2016-04-07 22:28 ` John Stultz
@ 2016-04-08  4:55 ` John Stultz
  1 sibling, 0 replies; 3+ messages in thread
From: John Stultz @ 2016-04-08  4:55 UTC (permalink / raw)
  To: Alexander Kuleshov; +Cc: Thomas Gleixner, lkml

On Wed, Mar 16, 2016 at 3:21 AM, Alexander Kuleshov
<kuleshovmail@gmail.com> wrote:
> which is introduced in the 7aca0c072 commit to simplify calculation of
> the mult and shift in the clocks_calc_mult_shift().
>
> Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>
> ---
>  kernel/time/clocksource.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
> index 56ece14..de57923 100644
> --- a/kernel/time/clocksource.c
> +++ b/kernel/time/clocksource.c
> @@ -80,9 +80,7 @@ clocks_calc_mult_shift(u32 *mult, u32 *shift, u32 from, u32 to, u32 maxsec)
>          * accuracy and fits the maxsec conversion range:
>          */
>         for (sft = 32; sft > 0; sft--) {
> -               tmp = (u64) to << sft;
> -               tmp += from / 2;
> -               do_div(tmp, from);
> +               tmp = clocksource_freq2mult(from, sft, to);
>                 if ((tmp >> sftacc) == 0)
>                         break;
>         }

I'm worried you never tested this, as its clearly broken, and keeps my
systems from booting.

clocksource_freq2mult returns a u32. In the code being removed, tmp is
a u64. So this may truncate the high bits.

Since sftacc is often 32, this causes it to exit prematurely on the
first pass through the loop.

Please do make sure to boot test what you send out. I spent some time
thinking I had broken my qemu testing setup before I realized it was
this simple looking patch.

thanks
-john

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-04-08  4:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-16 10:21 [PATCH] clocksource: use clocksource_freq2mult() helper Alexander Kuleshov
2016-04-07 22:28 ` John Stultz
2016-04-08  4:55 ` John Stultz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®