]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
refperf: Dynamically allocate thread-summary output buffer
authorPaul E. McKenney <paulmck@kernel.org>
Tue, 26 May 2020 00:45:03 +0000 (17:45 -0700)
committerPaul E. McKenney <paulmck@kernel.org>
Mon, 29 Jun 2020 19:00:44 +0000 (12:00 -0700)
Currently, the buffer used to accumulate the thread-summary output is
fixed size, which will cause problems if someone decides to run on a large
number of PCUs.  This commit therefore dynamically allocates this buffer.

[ paulmck: Fix memory allocation as suggested by KASAN. ]
Cc: Joel Fernandes (Google) <joel@joelfernandes.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
kernel/rcu/refperf.c

index 75b9cceaece1303f818ef1f5a6ef3e5ea0a72eed..fc940e3dba1f9de689a159df4e69ace78a0fbeee 100644 (file)
@@ -301,9 +301,12 @@ u64 process_durations(int n)
        int i;
        struct reader_task *rt;
        char buf1[64];
-       char buf[512];
+       char *buf;
        u64 sum = 0;
 
+       buf = kmalloc(128 + nreaders * 32, GFP_KERNEL);
+       if (!buf)
+               return 0;
        buf[0] = 0;
        sprintf(buf, "Experiment #%d (Format: <THREAD-NUM>:<Total loop time in ns>)",
                exp_idx);
@@ -322,6 +325,7 @@ u64 process_durations(int n)
 
        PERFOUT("%s\n", buf);
 
+       kfree(buf);
        return sum;
 }