Skip to content

Commit

Permalink
tools: sof_perf_analyzer: fix component ID
Browse files Browse the repository at this point in the history
Previously, component ID in mtrace and kernel
is different, which makes it hard to find the
component from kernel message with a component
ID from mtrace. After it is fixed in SOF side,
now module_id take the first 16 bits, instance_id
takes next 8 bits. We should do a fix accordingly.

Link: thesofproject/sof#8051

Signed-off-by: Chao Song <[email protected]>
  • Loading branch information
Chao Song committed Sep 1, 2023
1 parent 59bc03f commit 0c36a49
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tools/sof_perf_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class TraceItem:
class Component:
'''The identifier for a SOF audio component'''
ppln_id: str
comp_id: str
comp_id: int

@dataclass(frozen=True)
class CompPerfSample:
Expand Down Expand Up @@ -99,9 +99,10 @@ def collect_perf_info(trace_item: TraceItem):
'''
msg = trace_item.msg.split()
ppln_id = msg[0].split(':')[1]
comp_id = int(msg[1], 16)
perf_val = int(msg[5]), int(msg[7]), int(msg[10]), int(msg[12])
perf_sample = CompPerfSample(trace_item.timestamp, *perf_val)
comp_perf_info_list = perf_info.setdefault(Component(ppln_id, msg[1]), [])
comp_perf_info_list = perf_info.setdefault(Component(ppln_id, comp_id), [])
comp_perf_info_list.append(perf_sample)

def dispatch_trace_item(trace_item: TraceItem):
Expand Down Expand Up @@ -215,7 +216,7 @@ def process_kmsg_file():
next_line = next(f)
widget_id = next_line.split('|')[0].split(':')[-1].strip()
# convert to the same ID format in mtrace
widget_id = '0x' + widget_id[:-6:-1]
widget_id = int('0x' + widget_id[-6:], 16)
component_name[Component(ppln_id, widget_id)] = widget_name

def analyze_perf_info():
Expand Down Expand Up @@ -246,7 +247,7 @@ def print_perf_info():
peak_cpu_peak_mcps = perf.peak_cpu_peak * TICK_TO_MCPS

comp_name = component_name.get(comp, 'None')
comp_id = f'{comp.ppln_id}-{comp.comp_id}'
comp_id = f'{comp.ppln_id}-{comp.comp_id:#08x}'
stat = stats_fmt.format(comp_name, comp_id, avg_cpu_avg_mcps, avg_cpu_peak_mcps,
peak_cpu_avg_mcps, peak_cpu_peak_mcps)
print(stat)
Expand Down

0 comments on commit 0c36a49

Please sign in to comment.