Eiichi Tsukata
fc19ad387e
tracing/snapshot: Resize spare buffer if size changed
...
commit 46cc0b44428d0f0e81f11ea98217fc0edfbeab07 upstream.
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>
Signed-off-by: Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-08-04 09:33:26 +02:00
..
2019-08-04 09:33:19 +02:00
2016-10-11 15:06:32 -07:00
2018-12-08 13:05:05 +01:00
2019-07-21 09:06:05 +02:00
2017-09-02 07:07:53 +02:00
2019-05-10 17:52:10 +02:00
2016-08-26 14:42:08 +02:00
2019-08-04 09:33:17 +02:00
2019-06-11 12:22:48 +02:00
2018-11-13 11:17:01 -08:00
2019-05-31 06:48:30 -07:00
2019-05-31 06:48:22 -07:00
2019-08-04 09:33:21 +02:00
2019-08-04 09:33:26 +02:00
2018-01-10 09:29:51 +01:00
2018-02-17 13:21:18 +01:00
2016-04-04 09:46:47 -04:00
2018-09-26 08:36:37 +02:00
2018-05-30 07:50:49 +02:00
2016-07-29 17:54:17 -07:00
2019-05-31 06:48:20 -07:00
2018-08-03 07:55:25 +02:00
2018-11-13 11:16:57 -08:00
2017-01-06 10:40:13 +01:00
2017-03-26 13:05:58 +02:00
2018-10-13 09:18:56 +02:00
2019-07-10 09:55:39 +02:00
2017-10-12 11:51:25 +02:00
2019-06-22 08:17:18 +02:00
2019-02-06 17:33:29 +01:00
2017-07-21 07:42:21 +02:00
2019-01-13 10:03:51 +01:00
2016-07-28 16:07:41 -07:00
2019-03-27 14:13:03 +09:00
2018-01-10 09:29:52 +01:00
2019-04-20 09:07:52 +02:00
2017-12-14 09:28:24 +01:00
2016-03-15 16:55:16 -07:00
2018-08-03 07:55:12 +02:00
2018-06-05 10:28:57 +02:00
2016-09-01 17:52:01 -07:00
2016-08-02 19:35:27 -04:00
2019-04-27 09:34:45 +02:00
2016-08-02 19:35:30 -04:00
2018-08-03 07:55:12 +02:00
2019-06-22 08:17:19 +02:00
2017-03-12 06:41:45 +01:00
2019-01-13 10:03:51 +01:00
2016-04-11 22:43:43 +01:00
2018-10-03 17:01:48 -07:00
2017-05-20 14:28:40 +02:00
2018-12-29 13:40:16 +01:00
2019-08-04 09:33:16 +02:00
2018-04-13 19:47:53 +02:00
2016-07-15 10:41:42 +02:00
2019-07-10 09:55:45 +02:00
2018-05-30 07:50:29 +02:00
2018-04-24 09:34:09 +02:00
2018-05-22 16:58:02 +02:00
2019-06-11 12:22:43 +02:00
2018-08-15 18:14:53 +02:00
2016-10-11 15:06:33 -07:00
2018-08-15 18:14:42 +02:00
2017-02-14 15:25:42 -08:00
2018-08-03 07:55:24 +02:00
2016-09-13 14:41:36 +02:00
2019-06-22 08:17:13 +02:00
2016-05-20 17:58:30 -07:00
2019-06-22 08:17:11 +02:00
2016-08-02 19:35:02 -04:00
2016-11-03 16:55:58 -04:00
2016-08-22 10:01:49 -07:00
2018-05-09 09:50:20 +02:00
2017-06-17 06:41:51 +02:00
2018-01-10 09:29:52 +01:00
2016-09-05 13:52:39 +02:00
2018-09-09 20:01:24 +02:00
2018-09-09 20:01:24 +02:00
2016-09-22 20:00:36 -05:00
2017-06-17 06:41:57 +02:00
2017-06-17 06:41:57 +02:00
2017-11-15 15:53:17 +01:00
2018-05-30 07:50:36 +02:00