<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/kernel/trace/trace_events_hist.c, branch v5.11</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v5.11</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v5.11'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2020-11-11T01:39:40Z</updated>
<entry>
<title>tracing: Fix some typos in comments</title>
<updated>2020-11-11T01:39:40Z</updated>
<author>
<name>Qiujun Huang</name>
<email>hqjagain@gmail.com</email>
</author>
<published>2020-10-29T15:05:54Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=2b5894cc33e9dea189a7010c7ed57d414786d174'/>
<id>urn:sha1:2b5894cc33e9dea189a7010c7ed57d414786d174</id>
<content type='text'>
s/detetector/detector/
s/enfoced/enforced/
s/writen/written/
s/actualy/actually/
s/bascially/basically/
s/Regarldess/Regardless/
s/zeroes/zeros/
s/followd/followed/
s/incrememented/incremented/
s/separatelly/separately/
s/accesible/accessible/
s/sythetic/synthetic/
s/enabed/enabled/
s/heurisitc/heuristic/
s/assocated/associated/
s/otherwides/otherwise/
s/specfied/specified/
s/seaching/searching/
s/hierachry/hierarchy/
s/internel/internal/
s/Thise/This/

Link: https://lkml.kernel.org/r/20201029150554.3354-1-hqjagain@gmail.com

Signed-off-by: Qiujun Huang &lt;hqjagain@gmail.com&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing: Check return value of __create_val_fields() before using its result</title>
<updated>2020-10-15T16:00:59Z</updated>
<author>
<name>Steven Rostedt (VMware)</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2020-10-13T19:48:52Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=6d9bd139455d9d40fec8c242985996468b34180c'/>
<id>urn:sha1:6d9bd139455d9d40fec8c242985996468b34180c</id>
<content type='text'>
After having a typo for writing a histogram trigger.

Wrote:
  echo 'hist:key=pid:ts=common_timestamp.usec' &gt; events/sched/sched_waking/trigger

Instead of:
  echo 'hist:key=pid:ts=common_timestamp.usecs' &gt; events/sched/sched_waking/trigger

and the following crash happened:

 BUG: kernel NULL pointer dereference, address: 0000000000000008
 #PF: supervisor read access in kernel mode
 #PF: error_code(0x0000) - not-present page
 PGD 0 P4D 0
 Oops: 0000 [#1] PREEMPT SMP PTI
 CPU: 4 PID: 1641 Comm: sh Not tainted 5.9.0-rc5-test+ #549
 Hardware name: Hewlett-Packard HP Compaq Pro 6300 SFF/339A, BIOS K01 v03.03 07/14/2016
 RIP: 0010:event_hist_trigger_func+0x70b/0x1ee0
 Code: 24 08 89 d5 49 89 cc e9 8c 00 00 00 4c 89 f2 41 b9 00 10 00 00 4c 89 e1 44 89 ee 4c 89 ff e8 dc d3 ff ff 45 89 ea 4b 8b 14 d7 &lt;f6&gt; 42 08 04 74 17 41 8b 8f c0 00 00 00 8d 71 01 41 89 b7 c0 00 00
 RSP: 0018:ffff959213d53db0 EFLAGS: 00010202
 RAX: ffffffffffffffea RBX: 0000000000000000 RCX: 0000000000084c04
 RDX: 0000000000000000 RSI: df7326aefebd174c RDI: 0000000000031080
 RBP: 0000000000000002 R08: 0000000000000001 R09: 0000000000000001
 R10: 0000000000000001 R11: 0000000000000046 R12: ffff959211dcf690
 R13: 0000000000000001 R14: ffff95925a36e370 R15: ffff959251c89800
 FS:  00007fb9ea934740(0000) GS:ffff95925ab00000(0000) knlGS:0000000000000000
 CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
 CR2: 0000000000000008 CR3: 00000000c976c005 CR4: 00000000001706e0
 Call Trace:
  ? trigger_process_regex+0x78/0x110
  trigger_process_regex+0xc5/0x110
  event_trigger_write+0x71/0xd0
  vfs_write+0xca/0x210
  ksys_write+0x70/0xf0
  do_syscall_64+0x33/0x40
  entry_SYSCALL_64_after_hwframe+0x44/0xa9
 RIP: 0033:0x7fb9eaa29487
 Code: 64 89 02 48 c7 c0 ff ff ff ff eb bb 0f 1f 80 00 00 00 00 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 b8 01 00 00 00 0f 05 &lt;48&gt; 3d 00 f0 ff ff 77 51 c3 48 83 ec 28 48 89 54 24 18 48 89 74 24

This was caused by accessing the hlist_data fields after the call to
__create_val_fields() without checking if the creation succeed.

Link: https://lkml.kernel.org/r/20201013154852.3abd8702@gandalf.local.home

Fixes: 63a1e5de3006 ("tracing: Save normal string variables")
Reviewed-by: Masami Hiramatsu &lt;mhiramat@kernel.org&gt;
Reviewed-by: Tom Zanussi &lt;zanussi@kernel.org&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing: Add support for dynamic strings to synthetic events</title>
<updated>2020-10-05T23:32:18Z</updated>
<author>
<name>Tom Zanussi</name>
<email>zanussi@kernel.org</email>
</author>
<published>2020-10-04T22:14:06Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=bd82631d7ccdc894af2738e47abcba2cb6e7dea9'/>
<id>urn:sha1:bd82631d7ccdc894af2738e47abcba2cb6e7dea9</id>
<content type='text'>
Currently, sythetic events only support static string fields such as:

  # echo 'test_latency u64 lat; char somename[32]' &gt; /sys/kernel/debug/tracing/synthetic_events

Which is fine, but wastes a lot of space in the event.

It also prevents the most commonly-defined strings in the existing
trace events e.g. those defined using __string(), from being passed to
synthetic events via the trace() action.

With this change, synthetic events with dynamic fields can be defined:

  # echo 'test_latency u64 lat; char somename[]' &gt; /sys/kernel/debug/tracing/synthetic_events

And the trace() action can be used to generate events using either
dynamic or static strings:

  # echo 'hist:keys=name:lat=common_timestamp.usecs-$ts0:onmatch(sys.event).test_latency($lat,name)' &gt; /sys/kernel/debug/tracing/events

The synthetic event dynamic strings are implemented in the same way as
the existing __data_loc strings and appear as such in the format file.

[ &lt;rostedt@goodmis.org&gt;: added __set_synth_event_print_fmt() changes:

  I added the following to make it work with trace-cmd. Dynamic strings
  must have __get_str() for events in the print_fmt otherwise it can't be
  parsed correctly. ]

Link: https://lore.kernel.org/r/cover.1601588066.git.zanussi@kernel.org
Link: https://lkml.kernel.org/r/3ed35b6d0e390f5b94cb4a9ba1cc18f5982ab277.1601848695.git.zanussi@kernel.org

Tested-by: Axel Rasmussen &lt;axelrasmussen@google.com&gt;
Signed-off-by: Tom Zanussi &lt;zanussi@kernel.org&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing: Save normal string variables</title>
<updated>2020-10-05T22:13:53Z</updated>
<author>
<name>Tom Zanussi</name>
<email>zanussi@kernel.org</email>
</author>
<published>2020-10-04T22:14:05Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=63a1e5de3006f4ad713e4d72bcb404d0301e853d'/>
<id>urn:sha1:63a1e5de3006f4ad713e4d72bcb404d0301e853d</id>
<content type='text'>
String variables created as field variables and save variables are
already handled properly by having their values copied when set.  The
same isn't done for normal variables, but needs to be - simply saving
a pointer to a string contained in an old event isn't sufficient,
since that event's data may quickly become overwritten and therefore a
string pointer to it could yield garbage.

This change uses the same mechanism as field variables and simply
appends the new strings to the existing per-element field_var_str[]
array allocated for that purpose.

Link: https://lkml.kernel.org/r/1c1a03798b02e67307412a0c719d1bfb69b13007.1601848695.git.zanussi@kernel.org

Fixes: 02205a6752f2 (tracing: Add support for 'field variables')
Signed-off-by: Tom Zanussi &lt;zanussi@kernel.org&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing: Change STR_VAR_MAX_LEN</title>
<updated>2020-10-05T22:13:53Z</updated>
<author>
<name>Tom Zanussi</name>
<email>zanussi@kernel.org</email>
</author>
<published>2020-10-04T22:14:03Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=4a4a56b4e76bbe3211c4f93d99c0c1543f5f3230'/>
<id>urn:sha1:4a4a56b4e76bbe3211c4f93d99c0c1543f5f3230</id>
<content type='text'>
32 is too small for this value, and anyway it makes more sense to use
MAX_FILTER_STR_VAL, as this is also the value used for variable-length
__strings.

Link: https://lkml.kernel.org/r/6adfd1668ac1fd8670bd58206944a762061a5559.1601848695.git.zanussi@kernel.org

Tested-by: Axel Rasmussen &lt;axelrasmussen@google.com&gt;
Signed-off-by: Tom Zanussi &lt;zanussi@kernel.org&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing: fix double free</title>
<updated>2020-09-18T17:16:40Z</updated>
<author>
<name>Tom Rix</name>
<email>trix@redhat.com</email>
</author>
<published>2020-09-07T13:58:45Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=46bbe5c671e06f070428b9be142cc4ee5cedebac'/>
<id>urn:sha1:46bbe5c671e06f070428b9be142cc4ee5cedebac</id>
<content type='text'>
clang static analyzer reports this problem

trace_events_hist.c:3824:3: warning: Attempt to free
  released memory
    kfree(hist_data-&gt;attrs-&gt;var_defs.name[i]);

In parse_var_defs() if there is a problem allocating
var_defs.expr, the earlier var_defs.name is freed.
This free is duplicated by free_var_defs() which frees
the rest of the list.

Because free_var_defs() has to run anyway, remove the
second free fom parse_var_defs().

Link: https://lkml.kernel.org/r/20200907135845.15804-1-trix@redhat.com

Cc: stable@vger.kernel.org
Fixes: 30350d65ac56 ("tracing: Add variable support to hist triggers")
Reviewed-by: Tom Zanussi &lt;tom.zanussi@linux.intel.com&gt;
Signed-off-by: Tom Rix &lt;trix@redhat.com&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing: Move synthetic events to a separate file</title>
<updated>2020-06-01T12:23:22Z</updated>
<author>
<name>Tom Zanussi</name>
<email>zanussi@kernel.org</email>
</author>
<published>2020-05-28T19:32:37Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=726721a51838e3983023f906580722fc83f804ee'/>
<id>urn:sha1:726721a51838e3983023f906580722fc83f804ee</id>
<content type='text'>
With the addition of the in-kernel synthetic event API, synthetic
events are no longer specifically tied to the histogram triggers.

The synthetic event code is also making trace_event_hist.c very
bloated, so for those reasons, move it to a separate file,
trace_events_synth.c, along with a new trace_synth.h header file.

Because synthetic events are now independent from hist triggers, add a
new CONFIG_SYNTH_EVENTS config option, and have CONFIG_HIST_TRIGGERS
select it, and have CONFIG_SYNTH_EVENT_GEN_TEST depend on it.

Link: http://lkml.kernel.org/r/4d1fa1f85ed5982706ac44844ac92451dcb04715.1590693308.git.zanussi@kernel.org

Signed-off-by: Tom Zanussi &lt;zanussi@kernel.org&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing: Add hist_debug trace event files for histogram debugging</title>
<updated>2020-06-01T12:22:30Z</updated>
<author>
<name>Tom Zanussi</name>
<email>zanussi@kernel.org</email>
</author>
<published>2020-04-03T19:31:21Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=2d19bd79ae6509858582a9cade739c2e9a4fdca8'/>
<id>urn:sha1:2d19bd79ae6509858582a9cade739c2e9a4fdca8</id>
<content type='text'>
Add a new "hist_debug" file for each trace event, which when read will
dump out a bunch of internal details about the hist triggers defined
on that event.

This is normally off but can be enabled by saying 'y' to the new
CONFIG_HIST_TRIGGERS_DEBUG config option.

This is in support of the new Documentation file describing histogram
internals, Documentation/trace/histogram-design.rst, which was
requested by developers trying to understand the internals when
extending or making use of the hist triggers for higher-level tools.

The histogram-design.rst documentation refers to the hist_debug files
and demonstrates their use with output in the test examples.

Link: http://lkml.kernel.org/r/77914c22b0ba493d9783c53bbfbc6087d6a7e1b1.1585941485.git.zanussi@kernel.org

Signed-off-by: Tom Zanussi &lt;zanussi@kernel.org&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
<entry>
<title>tracing: Check state.disabled in synth event trace functions</title>
<updated>2020-06-01T12:21:08Z</updated>
<author>
<name>Tom Zanussi</name>
<email>zanussi@kernel.org</email>
</author>
<published>2020-04-03T19:31:19Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=1b94b3aed367ff2cdc84d325e0aa9d7cc9e3cf2a'/>
<id>urn:sha1:1b94b3aed367ff2cdc84d325e0aa9d7cc9e3cf2a</id>
<content type='text'>
Since trace_state.disabled is set in __synth_event_trace_start() at
the same time -ENOENT is returned, don't bother returning -ENOENT -
just have callers check trace_state.disabled instead, and avoid the
extra return val munging.

Link: http://lkml.kernel.org/r/87315c3889af870e8370e82b76cf48b426d70130.1585941485.git.zanussi@kernel.org

Suggested-by: Masami Hiramatsu &lt;mhiramat@kernel.org&gt;
Signed-off-by: Tom Zanussi &lt;zanussi@kernel.org&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@godmis.org&gt;
</content>
</entry>
<entry>
<title>tracing: Fix memory leaks in trace_events_hist.c</title>
<updated>2020-04-23T01:24:00Z</updated>
<author>
<name>Vamshi K Sthambamkadi</name>
<email>vamshi.k.sthambamkadi@gmail.com</email>
</author>
<published>2020-04-22T06:15:06Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=9da73974eb9c965dd9989befb593b8c8da9e4bdc'/>
<id>urn:sha1:9da73974eb9c965dd9989befb593b8c8da9e4bdc</id>
<content type='text'>
kmemleak report 1:
    [&lt;9092c50b&gt;] kmem_cache_alloc_trace+0x138/0x270
    [&lt;05a2c9ed&gt;] create_field_var+0xcf/0x180
    [&lt;528a2d68&gt;] action_create+0xe2/0xc80
    [&lt;63f50b61&gt;] event_hist_trigger_func+0x15b5/0x1920
    [&lt;28ea5d3d&gt;] trigger_process_regex+0x7b/0xc0
    [&lt;3138e86f&gt;] event_trigger_write+0x4d/0xb0
    [&lt;ffd66c19&gt;] __vfs_write+0x30/0x200
    [&lt;4f424a0d&gt;] vfs_write+0x96/0x1b0
    [&lt;da59a290&gt;] ksys_write+0x53/0xc0
    [&lt;3717101a&gt;] __ia32_sys_write+0x15/0x20
    [&lt;c5f23497&gt;] do_fast_syscall_32+0x70/0x250
    [&lt;46e2629c&gt;] entry_SYSENTER_32+0xaf/0x102

This is because save_vars[] of struct hist_trigger_data are
not destroyed

kmemleak report 2:
    [&lt;9092c50b&gt;] kmem_cache_alloc_trace+0x138/0x270
    [&lt;6e5e97c5&gt;] create_var+0x3c/0x110
    [&lt;de82f1b9&gt;] create_field_var+0xaf/0x180
    [&lt;528a2d68&gt;] action_create+0xe2/0xc80
    [&lt;63f50b61&gt;] event_hist_trigger_func+0x15b5/0x1920
    [&lt;28ea5d3d&gt;] trigger_process_regex+0x7b/0xc0
    [&lt;3138e86f&gt;] event_trigger_write+0x4d/0xb0
    [&lt;ffd66c19&gt;] __vfs_write+0x30/0x200
    [&lt;4f424a0d&gt;] vfs_write+0x96/0x1b0
    [&lt;da59a290&gt;] ksys_write+0x53/0xc0
    [&lt;3717101a&gt;] __ia32_sys_write+0x15/0x20
    [&lt;c5f23497&gt;] do_fast_syscall_32+0x70/0x250
    [&lt;46e2629c&gt;] entry_SYSENTER_32+0xaf/0x102

struct hist_field allocated through create_var() do not initialize
"ref" field to 1. The code in __destroy_hist_field() does not destroy
object if "ref" is initialized to zero, the condition
if (--hist_field-&gt;ref &gt; 1) always passes since unsigned int wraps.

kmemleak report 3:
    [&lt;f8666fcc&gt;] __kmalloc_track_caller+0x139/0x2b0
    [&lt;bb7f80a5&gt;] kstrdup+0x27/0x50
    [&lt;39d70006&gt;] init_var_ref+0x58/0xd0
    [&lt;8ca76370&gt;] create_var_ref+0x89/0xe0
    [&lt;f045fc39&gt;] action_create+0x38f/0xc80
    [&lt;7c146821&gt;] event_hist_trigger_func+0x15b5/0x1920
    [&lt;07de3f61&gt;] trigger_process_regex+0x7b/0xc0
    [&lt;e87daf8f&gt;] event_trigger_write+0x4d/0xb0
    [&lt;19bf1512&gt;] __vfs_write+0x30/0x200
    [&lt;64ce4d27&gt;] vfs_write+0x96/0x1b0
    [&lt;a6f34170&gt;] ksys_write+0x53/0xc0
    [&lt;7d4230cd&gt;] __ia32_sys_write+0x15/0x20
    [&lt;8eadca00&gt;] do_fast_syscall_32+0x70/0x250
    [&lt;235cf985&gt;] entry_SYSENTER_32+0xaf/0x102

hist_fields (system &amp; event_name) are not freed

Link: http://lkml.kernel.org/r/20200422061503.GA5151@cosmos

Signed-off-by: Vamshi K Sthambamkadi &lt;vamshi.k.sthambamkadi@gmail.com&gt;
Signed-off-by: Steven Rostedt (VMware) &lt;rostedt@goodmis.org&gt;
</content>
</entry>
</feed>
