Eiichi Tsukata
46cc0b4442
tracing/snapshot: Resize spare buffer if size changed
...
Current snapshot implementation swaps two ring_buffers even though their
sizes are different from each other, that can cause an inconsistency
between the contents of buffer_size_kb file and the current buffer size.
For example:
# cat buffer_size_kb
7 (expanded: 1408)
# echo 1 > events/enable
# grep bytes per_cpu/cpu0/stats
bytes: 1441020
# echo 1 > snapshot // current:1408, spare:1408
# echo 123 > buffer_size_kb // current:123, spare:1408
# echo 1 > snapshot // current:1408, spare:123
# grep bytes per_cpu/cpu0/stats
bytes: 1443700
# cat buffer_size_kb
123 // != current:1408
And also, a similar per-cpu case hits the following WARNING:
Reproducer:
# echo 1 > per_cpu/cpu0/snapshot
# echo 123 > buffer_size_kb
# echo 1 > per_cpu/cpu0/snapshot
WARNING:
WARNING: CPU: 0 PID: 1946 at kernel/trace/trace.c:1607 update_max_tr_single.part.0+0x2b8/0x380
Modules linked in:
CPU: 0 PID: 1946 Comm: bash Not tainted 5.2.0-rc6 #20
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-2.fc30 04/01/2014
RIP: 0010:update_max_tr_single.part.0+0x2b8/0x380
Code: ff e8 dc da f9 ff 0f 0b e9 88 fe ff ff e8 d0 da f9 ff 44 89 ee bf f5 ff ff ff e8 33 dc f9 ff 41 83 fd f5 74 96 e8 b8 da f9 ff <0f> 0b eb 8d e8 af da f9 ff 0f 0b e9 bf fd ff ff e8 a3 da f9 ff 48
RSP: 0018:ffff888063e4fca0 EFLAGS: 00010093
RAX: ffff888066214380 RBX: ffffffff99850fe0 RCX: ffffffff964298a8
RDX: 0000000000000000 RSI: 00000000fffffff5 RDI: 0000000000000005
RBP: 1ffff1100c7c9f96 R08: ffff888066214380 R09: ffffed100c7c9f9b
R10: ffffed100c7c9f9a R11: 0000000000000003 R12: 0000000000000000
R13: 00000000ffffffea R14: ffff888066214380 R15: ffffffff99851060
FS: 00007f9f8173c700(0000) GS:ffff88806d000000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000714dc0 CR3: 0000000066fa6000 CR4: 00000000000006f0
Call Trace:
? trace_array_printk_buf+0x140/0x140
? __mutex_lock_slowpath+0x10/0x10
tracing_snapshot_write+0x4c8/0x7f0
? trace_printk_init_buffers+0x60/0x60
? selinux_file_permission+0x3b/0x540
? tracer_preempt_off+0x38/0x506
? trace_printk_init_buffers+0x60/0x60
__vfs_write+0x81/0x100
vfs_write+0x1e1/0x560
ksys_write+0x126/0x250
? __ia32_sys_read+0xb0/0xb0
? do_syscall_64+0x1f/0x390
do_syscall_64+0xc1/0x390
entry_SYSCALL_64_after_hwframe+0x49/0xbe
This patch adds resize_buffer_duplicate_size() to check if there is a
difference between current/spare buffer sizes and resize a spare buffer
if necessary.
Link: http://lkml.kernel.org/r/20190625012910.13109-1-devel@etsukata.com
Cc: stable@vger.kernel.org
Fixes: ad909e21bbe69 ("tracing: Add internal tracing_snapshot() functions")
Signed-off-by: Eiichi Tsukata <devel@etsukata.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
2019-06-28 14:58:52 -04:00
..
2019-05-13 02:05:50 +02:00
2019-05-14 19:52:48 -07:00
2018-10-24 20:55:56 -04:00
2019-05-14 13:44:24 +01:00
2019-05-09 08:40:55 -07:00
2019-05-14 09:47:49 -07:00
2019-05-14 19:52:51 -07:00
2019-05-19 10:58:45 -07:00
2019-06-14 17:01:50 -04:00
2019-05-07 08:46:46 +02:00
2019-05-06 19:40:31 -07:00
2019-05-18 15:52:26 -07:00
2019-05-15 16:05:47 -07:00
2019-05-14 19:52:48 -07:00
2019-05-16 11:00:20 -07:00
2019-06-28 14:58:52 -04:00
2019-04-29 16:48:03 +02:00
2019-04-04 21:04:13 -04:00
2019-04-09 14:19:06 +02:00
2019-04-28 20:33:43 -04:00
2019-04-26 13:51:03 -04:00
2019-04-28 20:33:43 -04:00
2019-03-20 20:57:48 -04:00
2019-04-28 20:33:43 -04:00
2019-05-07 20:03:32 -07:00
2019-05-07 20:03:32 -07:00
2019-04-29 12:37:47 +02:00
2018-10-31 08:54:14 -07:00
2019-01-25 11:22:43 -08:00
2019-05-15 08:16:14 -07:00
2019-03-07 18:32:02 -08:00
2019-05-06 14:50:46 -07:00
2019-03-05 21:07:14 -08:00
2019-01-08 13:18:44 -08:00
2018-10-26 16:26:32 -07:00
2019-05-14 19:52:47 -07:00
2019-04-09 14:19:06 +02:00
2019-05-14 19:52:49 -07:00
2019-05-14 09:47:46 -07:00
2019-04-29 16:48:03 +02:00
2019-03-07 18:31:59 -08:00
2019-04-19 12:59:36 +02:00
2019-04-18 14:07:52 +02:00
2019-04-29 08:29:21 +02:00
2019-01-21 17:38:56 -03:00
2019-05-06 16:57:52 -07:00
2018-12-15 17:44:35 +09:00
2019-03-07 18:32:02 -08:00
2019-05-03 19:42:41 +02:00
2019-05-14 09:47:50 -07:00
2019-04-29 16:48:03 +02:00
2019-04-16 09:38:16 +02:00
2019-05-14 19:52:48 -07:00
2019-05-14 19:52:49 -07:00
2019-05-14 19:52:47 -07:00
2019-05-14 09:47:51 -07:00
2018-11-07 14:41:41 +01:00
2019-03-28 15:00:37 +01:00
2019-05-14 10:55:54 -07:00
2019-05-14 19:52:49 -07:00
2019-04-25 22:06:11 +02:00
2019-05-18 15:52:26 -07:00
2018-09-16 16:08:25 +02:00
2019-05-14 19:52:51 -07:00
2018-10-31 08:54:16 -07:00
2019-03-29 10:01:37 -07:00
2019-05-14 19:52:51 -07:00
2019-03-12 13:27:20 -07:00
2019-04-19 12:59:36 +02:00
2019-04-19 12:39:32 +02:00
2019-05-07 19:06:04 -07:00
2019-05-16 10:43:58 -07:00
2019-01-30 19:27:00 +01:00
2019-03-22 14:36:02 +01:00
2018-12-05 19:31:44 -08:00
2019-04-29 12:37:57 +02:00
2019-04-09 14:19:06 +02:00
2019-05-07 14:31:03 +02:00
2019-05-14 09:47:44 -07:00
2019-01-04 13:13:47 -08:00
2019-05-14 19:52:51 -07:00
2019-04-27 17:07:22 -04:00
2019-03-26 14:42:53 -07:00
2018-11-27 09:21:41 -08:00
2019-01-11 18:05:40 -08:00
2018-10-09 16:51:11 +02:00
2018-11-07 23:51:16 -06:00
2019-05-14 19:52:49 -07:00
2019-04-19 09:46:05 -07:00
2019-04-18 14:05:51 +02:00
2019-04-16 16:55:15 +02:00
2019-05-09 13:48:52 -07:00