Skip to content

Commit 2e90de7

Browse files
committed
refperf: Dynamically allocate thread-summary output buffer
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) <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent f518f15 commit 2e90de7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

kernel/rcu/refperf.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,12 @@ u64 process_durations(int n)
301301
int i;
302302
struct reader_task *rt;
303303
char buf1[64];
304-
char buf[512];
304+
char *buf;
305305
u64 sum = 0;
306306

307+
buf = kmalloc(128 + nreaders * 32, GFP_KERNEL);
308+
if (!buf)
309+
return 0;
307310
buf[0] = 0;
308311
sprintf(buf, "Experiment #%d (Format: <THREAD-NUM>:<Total loop time in ns>)",
309312
exp_idx);
@@ -322,6 +325,7 @@ u64 process_durations(int n)
322325

323326
PERFOUT("%s\n", buf);
324327

328+
kfree(buf);
325329
return sum;
326330
}
327331

0 commit comments

Comments
 (0)