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>
Unified · Split
| @@ -301,9 +301,12 @@ u64 process_durations(int n) · 300 unmodified lines | ||
| 301 | 301 | int i; |
| 302 | 302 | struct reader_task *rt; |
| 303 | 303 | char buf1[64]; |
| 304 | − char buf[512]; | |
| 304 | + char *buf; | |
| 305 | 305 | u64 sum = 0; |
| 306 | 306 | |
| 307 | + buf = kmalloc(128 + nreaders * 32, GFP_KERNEL); | |
| 308 | + if (!buf) | |
| 309 | + return 0; | |
| 307 | 310 | buf[0] = 0; |
| 308 | 311 | sprintf(buf, "Experiment #%d (Format: <THREAD-NUM>:<Total loop time in ns>)", |
| 309 | 312 | exp_idx); |
| @@ -322,6 +325,7 @@ u64 process_durations(int n) · 12 unmodified lines | ||
| 322 | 325 | |
| 323 | 326 | PERFOUT("%s\n", buf); |
| 324 | 327 | |
| 328 | + kfree(buf); | |
| 325 | 329 | return sum; |
| 326 | 330 | } |
| 327 | 331 | |