def _run_rtapp(cls, target, res_dir, profile, ftrace_coll=None, cg_cfg=None): wload = RTA.by_profile(target, "rta_{}".format(cls.__name__.lower()), profile, res_dir=res_dir) trace_path = os.path.join(res_dir, cls.TRACE_PATH) dmesg_path = os.path.join(res_dir, cls.DMESG_PATH) ftrace_coll = ftrace_coll or FtraceCollector.from_conf( target, cls.ftrace_conf) dmesg_coll = DmesgCollector(target) cgroup = cls._target_configure_cgroup(target, cg_cfg) as_root = cgroup is not None with dmesg_coll, ftrace_coll, target.freeze_userspace(): wload.run(cgroup=cgroup, as_root=as_root) ftrace_coll.get_trace(trace_path) dmesg_coll.get_trace(dmesg_path) return trace_path
def _do_test(self, profile, exp_phases): rtapp = RTA.by_profile(self.target, name='test', profile=profile, res_dir=self.res_dir, calibration=None) with open(rtapp.local_json) as f: conf = json.load(f, object_pairs_hook=OrderedDict) # Check that the configuration looks like we expect it to phases = list(conf['tasks']['test_task']['phases'].values()) self.assertEqual(len(phases), len(exp_phases), 'Wrong number of phases') for phase, exp_phase in zip(phases, exp_phases): self.assertDictEqual(phase, exp_phase) # Try running the workload and check that it produces the expected log # files rtapp.run() # rtapp_cmds = [c for c in self.target.executed_commands if 'rt-app' in c] # self.assertListEqual(rtapp_cmds, [self.get_expected_command(rtapp)]) self.assert_output_file_exists('output.log') self.assert_output_file_exists('test.json') self.assert_output_file_exists('rt-app-test_task-0.log') self.assert_can_read_logfile(exp_tasks=['test_task'])
def run_rtapp(cls, target, res_dir, profile=None, ftrace_coll=None, cg_cfg=None): """ Run the given RTA profile on the target, and collect an ftrace trace. :param target: target to execute the workload on. :type target: lisa.target.Target :param res_dir: Artifact folder where the artifacts will be stored. :type res_dir: str or lisa.utils.ArtifactPath :param profile: ``rt-app`` profile, as a dictionary of ``dict(task_name, RTATask)``. If ``None``, :meth:`~lisa.tests.base.RTATestBundle.get_rtapp_profile` is called with ``target.plat_info``. :type profile: dict(str, lisa.wlgen.rta.RTATask) :param ftrace_coll: Ftrace collector to use to record the trace. This allows recording extra events compared to the default one, which is based on the ``ftrace_conf`` class attribute. :type ftrace_coll: lisa.trace.FtraceCollector :param cg_cfg: CGroup configuration dictionary. If ``None``, :meth:`lisa.tests.base.RTATestBundle.get_cgroup_configuration` is called with ``target.plat_info``. :type cg_cfg: dict """ trace_path = ArtifactPath.join(res_dir, cls.TRACE_PATH) dmesg_path = ArtifactPath.join(res_dir, cls.DMESG_PATH) ftrace_coll = ftrace_coll or FtraceCollector.from_conf( target, cls.ftrace_conf) dmesg_coll = DmesgCollector(target) profile = profile or cls.get_rtapp_profile(target.plat_info) cg_cfg = cg_cfg or cls.get_cgroup_configuration(target.plat_info) wload = RTA.by_profile(target, "rta_{}".format(cls.__name__.lower()), profile, res_dir=res_dir) cgroup = cls._target_configure_cgroup(target, cg_cfg) as_root = cgroup is not None # Pre-hit the calibration information, in case this is a lazy value. # This avoids polluting the trace and the dmesg output with the # calibration tasks. Since we know that rt-app will always need it for # anything useful, it's reasonable to do it here. target.plat_info['rtapp']['calib'] with dmesg_coll, ftrace_coll, target.freeze_userspace(): wload.run(cgroup=cgroup, as_root=as_root) ftrace_coll.get_trace(trace_path) dmesg_coll.get_trace(dmesg_path) return trace_path
def _do_test(self, profile, exp_phases): rtapp = RTA.by_profile( self.target, name='test', profile=profile, res_dir=self.res_dir, calibration=None, log_stats=True) with open(rtapp.local_json) as f: conf = json.load(f, object_pairs_hook=OrderedDict) # Check that the configuration looks like we expect it to phases = list(conf['tasks']['test']['phases'].values()) assert len(phases) == len(exp_phases), 'Wrong number of phases' for phase, exp_phase in zip(phases, exp_phases): if 'cpus' not in exp_phase: exp_phase = copy.copy(exp_phase) exp_phase.update( cpus=sorted(range(self.target.plat_info['cpus-count'])), nodes_membind=sorted(range(self.target.plat_info['numa-nodes-count'])), ) assert phase == exp_phase # Try running the workload and check that it produces the expected log # files rtapp.run() # rtapp_cmds = [c for c in self.target.executed_commands if 'rt-app' in c] # assert rtapp_cmds == [self.get_expected_command(rtapp)] self.assert_output_file_exists('output.log') self.assert_output_file_exists('test.json') self.assert_output_file_exists('rt-app-test-0.log') self.assert_can_read_logfile(exp_tasks=['test-0'])
def _get_calib_conf(self, calibration): profile = {"test": Periodic()} rtapp = RTA.by_profile( self.target, name='test', res_dir=self.res_dir, profile=profile, calibration=calibration) with open(rtapp.local_json) as fh: return json.load(fh)['global']['calibration']
from lisa.wlgen.rta import RTA, Periodic from lisa.datautils import df_filter_task_ids import pandas as pd setup_logging() target = Target.from_one_conf('conf/lisa/qemu_target_default.yml') #target = Target.from_default_conf() rtapp_profile = {} tasks = [] for cpu in range(4): tasks.append("tsk{}-{}".format(cpu, cpu)) rtapp_profile["tsk{}".format(cpu)] = Periodic(duty_cycle_pct=50, duration_s=120) wload = RTA.by_profile(target, "experiment_wload", rtapp_profile) ftrace_coll = FtraceCollector(target, events=["sched_switch"]) trace_path = os.path.join(wload.res_dir, "trace.dat") with ftrace_coll: wload.run() ftrace_coll.get_trace(trace_path) trace = Trace(trace_path, target.plat_info, events=["sched_switch"]) # sched_switch __comm __pid __cpu __line prev_comm prev_pid prev_prio prev_state next_comm next_pid next_prio df = trace.df_events('sched_switch')[['next_pid', 'next_comm', '__cpu']] def analize_task_migration(task_id, ddf): start = ddf.index[0]