]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
refperf: Work around 64-bit division
authorArnd Bergmann <arnd@arndb.de>
Fri, 29 May 2020 21:36:26 +0000 (14:36 -0700)
committerPaul E. McKenney <paulmck@kernel.org>
Mon, 29 Jun 2020 19:00:45 +0000 (12:00 -0700)
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.

[ paulmck: Update primitive and format per Nathan Chancellor. ]
Fixes: bd5b16d6c88d ("refperf: Allow decimal nanoseconds")
Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Valdis Klētnieks <valdis.kletnieks@vt.edu>
Acked-by: Randy Dunlap <rdunlap@infradead.org> # build-tested
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
kernel/rcu/refperf.c

index 063eeb0473a1e04574b89988187a90dc4b93af36..80d449060bdfd50e6ef1905deaa1da13d0c7dcfe 100644 (file)
@@ -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);
        }