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