Skip to content

Commit 6b35e10

Browse files
btian1Chao Song
authored andcommitted
tools: sof_perf_analyzer: fix widget ID parsing error
In existing code, we parse component name from the line that contains 'Create widget', and component ID from the next line, which normally is the ipc tx message: Create widget host-copier.0.playback instance 0 - pipe 1 - core 0 ipc tx : 0x40000004|0x15: MOD_INIT_INSTANCE [data size: 84] However, due to the concurrent nature of linux kernel, the assumption that `Create widget` message and `ipc tx` message are always adjacent is wrong. An exception will be raised if the next line is not the 'ipc tx' message. The first step to fix the issue is to make a kernel PR to print all the information we need in a single 'Create widget' line, thus to avoid the requirement for multiple lines of kernel message, see thesofproject/linux#4709. And next,this patch will parse the new 'Create widget' line to get component name and ID. Fixes: #1108 Signed-off-by: Baofeng Tian <baofeng.tian@intel.com> Signed-off-by: Chao Song <chao.song@linux.intel.com>
1 parent 3d4668f commit 6b35e10

1 file changed

Lines changed: 18 additions & 12 deletions

File tree

tools/sof_perf_analyzer.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,14 @@ def process_trace_file():
175175

176176
def process_kmsg_file():
177177
'''Process the dmesg to get the component ID to component name mapping,
178-
component name is acquired from the line that contains 'Create widget',
179-
component ID is acquired from the next line. Example:
180-
[ 334.818435] kernel: snd_sof:sof_ipc4_widget_setup: sof-audio-pci-intel-mtl 0000:00:1f.3:
181-
Create widget host-copier.0.playback instance 0 - pipe 1 - core 0
182-
[ 334.818442] kernel: snd_sof:sof_ipc4_log_header: sof-audio-pci-intel-mtl 0000:00:1f.3:
183-
ipc tx : 0x40000004|0x15: MOD_INIT_INSTANCE [data size: 84]
178+
they are acquired from the line that contains 'Create widget':
179+
[ 59.622645] snd_sof:sof_ipc4_widget_setup: sof-audio-pci-intel-mtl 0000:00:1f.3:
180+
Create widget host-copier.0.capture (pipe 3) - ID 4, instance 3, core 0"
181+
182+
By design in the kernel, pipeline ID is the instance ID of pipeline
183+
widget, so it is acquired from the line that contains 'Create pipeline':
184+
[ 59.622134] snd_sof:sof_ipc4_widget_setup: sof-audio-pci-intel-mtl 0000:00:1f.3:
185+
Create pipeline pipeline.3 (pipe 3) - instance 3, core 0
184186
185187
In practice, sof-test only capture kernel message and firmware trace generated during a test
186188
case run. Mostly in manual tests, if the kernel message file contains multiple firmware runs
@@ -190,7 +192,7 @@ def process_kmsg_file():
190192
with open(args.kmsg, encoding='utf8') as f:
191193
ppln_id = None
192194
for line in f:
193-
if match_obj := re.search(r'Create widget', line):
195+
if match_obj := re.search(r"Create (widget|pipeline)", line):
194196
span_end_pos = match_obj.span()[1]
195197
line_split = line[span_end_pos + 1:].split()
196198
widget_name = line_split[0]
@@ -200,11 +202,15 @@ def process_kmsg_file():
200202
# creation, because it is always the first one to be created before all other
201203
# widgets in the same pipeline and pipelines are created sequentially.
202204
if widget_name.startswith('pipeline'):
203-
ppln_id = line_split[2]
204-
next_line = next(f)
205-
widget_id = next_line.split('|')[0].split(':')[-1].strip()
206-
# convert to the same ID format in mtrace
207-
widget_id = int('0x' + widget_id[-6:], 16)
205+
# remove ending comma(,) with [:-1]
206+
ppln_id = int(line_split[5][:-1])
207+
continue
208+
# remove ending comma(,) with [:-1]
209+
module_instance_id = int(line_split[7][:-1])
210+
# remove ending comma(,) with [:-1]
211+
widget_id = int(line_split[5][:-1])
212+
# final module id are composed with high16(module instance id) + low16(module id)
213+
widget_id |= module_instance_id << 16
208214
comp_name[str(Component(ppln_id, widget_id))] = widget_name
209215

210216
col_data = pd.DataFrame(

0 commit comments

Comments
 (0)