Commit 7c339fb
ring-buffer: Ensure proper resetting of atomic variables in ring_buffer_reset_online_cpus
In ring_buffer_reset_online_cpus, the buffer_size_kb write operation
may permanently fail if the cpu_online_mask changes between two
for_each_online_buffer_cpu loops. The number of increases and decreases
on both cpu_buffer->resize_disabled and cpu_buffer->record_disabled may be
inconsistent, causing some CPUs to have non-zero values for these atomic
variables after the function returns.
This issue can be reproduced by "echo 0 > trace" while hotplugging cpu.
After reproducing success, we can find out buffer_size_kb will not be
functional anymore.
To prevent leaving 'resize_disabled' and 'record_disabled' non-zero after
ring_buffer_reset_online_cpus returns, we ensure that each atomic variable
has been set up before atomic_sub() to it.
Link: https://lore.kernel.org/linux-trace-kernel/20230426062027.17451-1-Tze-nan.Wu@mediatek.com
Cc: stable@vger.kernel.org
Cc: <mhiramat@kernel.org>
Cc: npiggin@gmail.com
Fixes: b23d7a5 ("ring-buffer: speed up buffer resets by avoiding synchronize_rcu for each CPU")
Reviewed-by: Cheng-Jui Wang <cheng-jui.wang@mediatek.com>
Signed-off-by: Tze-nan Wu <Tze-nan.Wu@mediatek.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>1 parent fa359d0 commit 7c339fb
1 file changed
Lines changed: 13 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5326 | 5326 | | |
5327 | 5327 | | |
5328 | 5328 | | |
| 5329 | + | |
| 5330 | + | |
| 5331 | + | |
5329 | 5332 | | |
5330 | 5333 | | |
5331 | 5334 | | |
| |||
5342 | 5345 | | |
5343 | 5346 | | |
5344 | 5347 | | |
5345 | | - | |
| 5348 | + | |
5346 | 5349 | | |
5347 | 5350 | | |
5348 | 5351 | | |
5349 | 5352 | | |
5350 | 5353 | | |
5351 | 5354 | | |
5352 | | - | |
| 5355 | + | |
5353 | 5356 | | |
5354 | 5357 | | |
| 5358 | + | |
| 5359 | + | |
| 5360 | + | |
| 5361 | + | |
| 5362 | + | |
| 5363 | + | |
| 5364 | + | |
5355 | 5365 | | |
5356 | 5366 | | |
5357 | 5367 | | |
5358 | | - | |
| 5368 | + | |
5359 | 5369 | | |
5360 | 5370 | | |
5361 | 5371 | | |
| |||
0 commit comments