refperf: work around 64-bit division
PATCH 1/1 refperf: work around 64-bit division
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.
--- kernel/rcu/refperf.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
kernel/rcu/refperf.c +7 -2
@@ -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); +sprintf (buf1,"%d\t%llu.%03d\n" , exp +1 , avg, rem);strcat (buf, buf1); }
Signature · 1 line
2.26.2
Paul E. McKenney
maintainerQuoted 10 lines · Arnd Bergmann
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_u64to mark the expensive operation.Fixes bd5b16d6c88d ("refperf: Allow decimal nanoseconds")Signed-off-by Arnd Bergmann <[email protected]>
Many thanks, Arnd!
I queued this and reverted my earlier 64-bit-only restriction, pushing the result out on the -rcu tree's "dev" branch. I also added a couple of Reported-by entries.
Thanx, Paul
Quoted 36 lines
--- kernel/rcu/refperf.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)kernel/rcu/refperf.c +7
-2@@ -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); +sprintf (buf1,"%d\t%llu.%03d\n" , exp +1 , avg, rem);strcat (buf, buf1); }Signature · 1 line
2.26.2
Quoted 10 lines · Arnd Bergmann
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_u64to mark the expensive operation.Fixes bd5b16d6c88d ("refperf: Allow decimal nanoseconds")Signed-off-by Arnd Bergmann <[email protected]>
Thanks.
Quoted 34 lines
--- kernel/rcu/refperf.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)kernel/rcu/refperf.c +7
-2@@ -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); +sprintf (buf1,"%d\t%llu.%03d\n" , exp +1 , avg, rem);strcat (buf, buf1); }
Signature · 1 line
~Randy
Quoted 29 lines · Arnd Bergmann
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_u64to mark the expensive operation.Fixes bd5b16d6c88d ("refperf: Allow decimal nanoseconds")Signed-off-by Arnd Bergmann <[email protected]>--- kernel/rcu/refperf.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)kernel/rcu/refperf.c +1
-1@@ -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" );
kernel/rcu/refperf.c static int main_func(void *arg) · line 406
Quoted 10 lines
kernel/rcu/refperf.c +5
-1for (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.
kernel/rcu/refperf.c static int main_func(void *arg) · line 407
Quoted 1 line
kernel/rcu/refperf.c +1
-0+sprintf (buf1,"%d\t%llu.%03d\n" , exp +1 , avg, rem);
Would %03u be the better specifier since rem is u32?
Quoted 6 lines
kernel/rcu/refperf.c +0
-0strcat (buf, buf1); }Signature · 1 line
2.26.2
Cheers,
Nathan
Quoted 14 lines · Nathan Chancellor
kernel/rcu/refperf.c static int main_func(void *arg) · line 406
Quoted 11 lines · Arnd Bergmann
strcat(buf, "Threads\tTime(ns)\n"); for (exp = 0; exp < nruns; exp++) {kernel/rcu/refperf.c +5
-1+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_avgis u64.
Yes, you are right. Actually that would be an important optimization since div_u64_rem() optimizes for constant divisors while div_s64_rem uses the slow path.
Quoted 3 lines
Quoted 1 line
+
sprintf(buf1, "%d\t%llu.%03d\n", exp + 1, avg, rem);Would %03u be the better specifier since rem is u32?
Yes, though this makes no difference in practice.
Paul, should I send a fixup for these two, or do you prefer to just edit it in place?
Arnd
Paul E. McKenney
maintainerQuoted 21 lines · Arnd Bergmann
Quoted 14 lines · Nathan Chancellor
kernel/rcu/refperf.c static int main_func(void *arg) · line 406
Quoted 11 lines · Arnd Bergmann
strcat(buf, "Threads\tTime(ns)\n"); for (exp = 0; exp < nruns; exp++) {kernel/rcu/refperf.c +5
-1+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_avgis u64.Yes, you are right. Actually that would be an important optimization since
div_u64_rem()optimizes for constant divisors whilediv_s64_remuses the slow path.
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
+
sprintf(buf1, "%d\t%llu.%03d\n", exp + 1, avg, rem);Would %03u be the better specifier since rem is u32?
Yes, though this makes no difference in practice.
Paul, should I send a fixup for these two, or do you prefer to just edit it in place?
I will apply it with Randy's Ack, thank you all!
Thanx, Paul
Quoted 21 lines · Arnd Bergmann
Quoted 14 lines · Nathan Chancellor
Review
Quoted 11 lines · Arnd Bergmann
strcat(buf, "Threads\tTime(ns)\n"); for (exp = 0; exp < nruns; exp++) {(quoted diff) +5
-1+ 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_avgis u64.Yes, you are right. Actually that would be an important optimization since
div_u64_rem()optimizes for constant divisors whilediv_s64_remuses the slow path.
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
+
sprintf(buf1, "%d\t%llu.%03d\n", exp + 1, avg, rem);Would %03u be the better specifier since rem is u32?
Yes, though this makes no difference in practice.
Paul, should I send a fixup for these two, or do you prefer to just edit it in place?
And here is the update, thank you all!
Thanx, Paul
------------------------------------------------------------------------
commit 0dd4132157c2cf6bec2a0a6e04163067323abdb1
Author: Arnd Bergmann <[email protected]> Date: Fri May 29 14:36:26 2020 -0700
refperf: Work around 64-bit division
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'
Fix this by using div_u64 to mark the expensive operation.
kernel/rcu/refperf.c +6 -2
@@ -478,7 +478,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
@@ -489,9 +489,13 @@ static int main_func(void *arg)strcat (buf,"Runs\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_u64_rem (result_avg[exp],1000 , &rem); +sprintf (buf1,"%d\t%llu.%03u\n" , exp +1 , avg, rem);strcat (buf, buf1); }