lkml.org 
[lkml]   [2020]   [May]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] refperf: work around 64-bit division
On Fri, May 29, 2020 at 10:15:51PM +0200, Arnd Bergmann wrote:
> A 64-bit division was introduced in refperf, breaking compilation
> on all 32-bit architectures:
>
> kernel/rcu/refperf.o: in function `main_func':
> refperf.c:(.text+0x57c): undefined reference to `__aeabi_uldivmod'
>
> Work it by using div_u64 to mark the expensive operation.
>
> Fixes: bd5b16d6c88d ("refperf: Allow decimal nanoseconds")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> kernel/rcu/refperf.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/rcu/refperf.c b/kernel/rcu/refperf.c
> index 47df72c492b3..c2366648981d 100644
> --- a/kernel/rcu/refperf.c
> +++ b/kernel/rcu/refperf.c
> @@ -386,7 +386,7 @@ static int main_func(void *arg)
> if (torture_must_stop())
> goto end;
>
> - result_avg[exp] = 1000 * process_durations(nreaders) / (nreaders * loops);
> + result_avg[exp] = div_u64(1000 * process_durations(nreaders), nreaders * loops);
> }
>
> // Print the average of all experiments
> @@ -397,9 +397,14 @@ static int main_func(void *arg)
> strcat(buf, "Threads\tTime(ns)\n");
>
> for (exp = 0; exp < nruns; exp++) {
> + u64 avg;
> + u32 rem;
> +
> if (errexit)
> break;
> - sprintf(buf1, "%d\t%llu.%03d\n", exp + 1, result_avg[exp] / 1000, (int)(result_avg[exp] % 1000));
> +
> + avg = div_s64_rem(result_avg[exp], 1000, &rem);

Shouldn't this be div_u64_rem? result_avg is u64.

> + sprintf(buf1, "%d\t%llu.%03d\n", exp + 1, avg, rem);

Would %03u be the better specifier since rem is u32?

> strcat(buf, buf1);
> }
>
> --
> 2.26.2
>

Cheers,
Nathan

\
 
 \ /
  Last update: 2020-05-30 05:53    [W:0.074 / U:1.260 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site