Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

stm class: Add source type

Currently kernel HW tracing infrastrtucture and specifically its SyS-T
part treats all source data in the same way. Treating and encoding
different trace data sources differently might allow decoding software
to make use of e.g. ftrace event ids by converting them to a SyS-T
message catalog.

The solution is to keep source type stored within stm_source_data
structure to allow different handling by stm output/protocol.
Currently we only differentiate between STM_USER and STM_FTRACE sources.

Signed-off-by: Mikhail Lappo <miklelappo@gmail.com>
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20240429130119.1518073-3-alexander.shishkin@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Mikhail Lappo and committed by
Greg Kroah-Hartman
07cf8356 3df46386

+15
+1
drivers/hwtracing/stm/console.c
··· 22 22 .data = { 23 23 .name = "console", 24 24 .nr_chans = 1, 25 + .type = STM_USER, 25 26 .link = stm_console_link, 26 27 .unlink = stm_console_unlink, 27 28 },
+1
drivers/hwtracing/stm/ftrace.c
··· 23 23 .data = { 24 24 .name = "ftrace", 25 25 .nr_chans = STM_FTRACE_NR_CHANNELS, 26 + .type = STM_FTRACE, 26 27 .link = stm_ftrace_link, 27 28 .unlink = stm_ftrace_unlink, 28 29 },
+1
drivers/hwtracing/stm/heartbeat.c
··· 78 78 } 79 79 80 80 stm_heartbeat[i].data.nr_chans = 1; 81 + stm_heartbeat[i].data.type = STM_USER; 81 82 stm_heartbeat[i].data.link = stm_heartbeat_link; 82 83 stm_heartbeat[i].data.unlink = stm_heartbeat_unlink; 83 84 hrtimer_init(&stm_heartbeat[i].hrtimer, CLOCK_MONOTONIC,
+12
include/linux/stm.h
··· 30 30 STP_PACKET_TIMESTAMPED = 0x2, 31 31 }; 32 32 33 + /** 34 + * enum stm_source_type - STM source driver 35 + * @STM_USER: any STM trace source 36 + * @STM_FTRACE: ftrace STM source 37 + */ 38 + enum stm_source_type { 39 + STM_USER, 40 + STM_FTRACE, 41 + }; 42 + 33 43 struct stp_policy; 34 44 35 45 struct stm_device; ··· 116 106 * @name: device name, will be used for policy lookup 117 107 * @src: internal structure, only used by stm class code 118 108 * @nr_chans: number of channels to allocate 109 + * @type: type of STM source driver represented by stm_source_type 119 110 * @link: called when this source gets linked to an STM device 120 111 * @unlink: called when this source is about to get unlinked from its STM 121 112 * ··· 128 117 struct stm_source_device *src; 129 118 unsigned int percpu; 130 119 unsigned int nr_chans; 120 + unsigned int type; 131 121 int (*link)(struct stm_source_data *data); 132 122 void (*unlink)(struct stm_source_data *data); 133 123 };