History

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) <joel@joelfernandes.org> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>

Paul E. McKenney committed 6 years ago

Commit 2e90de71 parent f518f151 file · +5 −1Browse files

Unified · Split

kernel/rcu/refperf.c+5−1
@@ -301,9 +301,12 @@ u64 process_durations(int n) · 300 unmodified lines
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) · 12 unmodified lines
322325
323326 PERFOUT("%s\n", buf);
324327
328+ kfree(buf);
325329 return sum;
326330 }
327331

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t