1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-01-31 02:00:45 +00:00

collector/perf: Only kill sleep if running perf stat

The stop() command of the PerfCollector kills all sleep commands in
the target, saying "We hope that no other important sleep is
on-going".  This is only needed if we are running "perf stat",
simpleperf does not need this.  Background the
perf/simpleperf command and only kill all sleeps in that specific case.
This commit is contained in:
Robert Freeman 2021-03-29 15:38:38 +01:00 committed by Marc Bonnici
parent 5d342044a2
commit 4859e818fb

View File

@ -24,7 +24,7 @@ from devlib.collector import (CollectorBase, CollectorOutput,
from devlib.utils.misc import ensure_file_directory_exists as _f from devlib.utils.misc import ensure_file_directory_exists as _f
PERF_COMMAND_TEMPLATE = '{binary} {command} {options} {events} sleep 1000 > {outfile} 2>&1 ' PERF_STAT_COMMAND_TEMPLATE = '{binary} {command} {options} {events} {sleep_cmd} > {outfile} 2>&1 '
PERF_REPORT_COMMAND_TEMPLATE= '{binary} report {options} -i {datafile} > {outfile} 2>&1 ' PERF_REPORT_COMMAND_TEMPLATE= '{binary} report {options} -i {datafile} > {outfile} 2>&1 '
PERF_RECORD_COMMAND_TEMPLATE= '{binary} record {options} {events} -o {outfile}' PERF_RECORD_COMMAND_TEMPLATE= '{binary} record {options} {events} -o {outfile}'
@ -141,11 +141,12 @@ class PerfCollector(CollectorBase):
def start(self): def start(self):
for command in self.commands: for command in self.commands:
self.target.kick_off(command, as_root=self.target.is_rooted) self.target.background(command, as_root=self.target.is_rooted)
def stop(self): def stop(self):
self.target.killall(self.perf_type, signal='SIGINT', self.target.killall(self.perf_type, signal='SIGINT',
as_root=self.target.is_rooted) as_root=self.target.is_rooted)
if self.perf_type == "perf" and self.command == "stat":
# perf doesn't transmit the signal to its sleep call so handled here: # perf doesn't transmit the signal to its sleep call so handled here:
self.target.killall('sleep', as_root=self.target.is_rooted) self.target.killall('sleep', as_root=self.target.is_rooted)
# NB: we hope that no other "important" sleep is on-going # NB: we hope that no other "important" sleep is on-going
@ -188,10 +189,12 @@ class PerfCollector(CollectorBase):
def _build_perf_stat_command(self, options, events, label): def _build_perf_stat_command(self, options, events, label):
event_string = ' '.join(['-e {}'.format(e) for e in events]) event_string = ' '.join(['-e {}'.format(e) for e in events])
command = PERF_COMMAND_TEMPLATE.format(binary = self.binary, sleep_cmd = 'sleep 1000' if self.perf_type == 'perf' else ''
command = PERF_STAT_COMMAND_TEMPLATE.format(binary = self.binary,
command = self.command, command = self.command,
options = options or '', options = options or '',
events = event_string, events = event_string,
sleep_cmd = sleep_cmd,
outfile = self._get_target_file(label, 'out')) outfile = self._get_target_file(label, 'out'))
return command return command