From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id A3E40A056D; Tue, 3 Mar 2020 06:41:23 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9144D1BFF9; Tue, 3 Mar 2020 06:41:23 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 276CA2BB8 for ; Tue, 3 Mar 2020 06:41:22 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Mar 2020 21:41:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,510,1574150400"; d="scan'208";a="286881359" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by FMSMGA003.fm.intel.com with ESMTP; 02 Mar 2020 21:41:21 -0800 Received: from fmsmsx120.amr.corp.intel.com (10.18.124.208) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 2 Mar 2020 21:41:21 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx120.amr.corp.intel.com (10.18.124.208) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 2 Mar 2020 21:41:20 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.43]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.201]) with mapi id 14.03.0439.000; Tue, 3 Mar 2020 13:41:18 +0800 From: "Tu, Lijuan" To: "Mo, YufengX" , "dts@dpdk.org" , "Yao, Lei A" CC: "Mo, YufengX" Thread-Topic: [dts] [PATCH V1 1/1] tests/vm_pw_mgmt_policy: optimize script Thread-Index: AQHV7HmyeEdwRNDcq02TxRJplYbHNKg2Y8HA Date: Tue, 3 Mar 2020 05:41:17 +0000 Message-ID: <8CE3E05A3F976642AAB0F4675D0AD20E0BBE8F4F@SHSMSX101.ccr.corp.intel.com> References: <20200226075542.15185-1-yufengx.mo@intel.com> <20200226075542.15185-2-yufengx.mo@intel.com> In-Reply-To: <20200226075542.15185-2-yufengx.mo@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dts] [PATCH V1 1/1] tests/vm_pw_mgmt_policy: optimize script X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org Sender: "dts" Applied, thanks > -----Original Message----- > From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of yufengmx > Sent: Wednesday, February 26, 2020 3:56 PM > To: dts@dpdk.org; Yao, Lei A > Cc: Mo, YufengX > Subject: [dts] [PATCH V1 1/1] tests/vm_pw_mgmt_policy: optimize script >=20 >=20 > *. use hwclock command to take the place of clock command for os > compatibility. > *. set longer clock command timeout. > *. use pktgen new callback function to take the place of shell script que= ry. > *. fix vcpu/pcpu mapping. > *. python3 support. >=20 > Signed-off-by: yufengmx > --- > tests/TestSuite_vm_pw_mgmt_policy.py | 84 ++++++++-------------------- > 1 file changed, 23 insertions(+), 61 deletions(-) >=20 > diff --git a/tests/TestSuite_vm_pw_mgmt_policy.py > b/tests/TestSuite_vm_pw_mgmt_policy.py > index 076046b..8da21b6 100644 > --- a/tests/TestSuite_vm_pw_mgmt_policy.py > +++ b/tests/TestSuite_vm_pw_mgmt_policy.py > @@ -1,6 +1,6 @@ > # BSD LICENSE > # > -# Copyright(c) 2010-2019 Intel Corporation. All rights reserved. > +# Copyright(c) 2010-2020 Intel Corporation. All rights reserved. > # All rights reserved. > # > # Redistribution and use in source and binary forms, with or without @@ = - > 173,6 +173,7 @@ class TestVmPwMgmtPolicy(TestCase): > for layer in list(pkt_layers.keys()): > pkt.config_layer(layer, pkt_layers[layer]) > streams.append(pkt.pktgen.pkt) > + self.logger.debug(pkt.pktgen.pkt.command()) >=20 > return streams >=20 > @@ -230,6 +231,8 @@ class TestVmPwMgmtPolicy(TestCase): > 'rate_percent': rate, > 'traffic_opt': { > 'method': 'throughput', > + 'callback': self.query_cpu_freq, > + 'interval': duration - 2, > 'duration': duration, > }} > # begin traffic checking > @@ -320,7 +323,8 @@ class TestVmPwMgmtPolicy(TestCase): > self.verify(self.vm_dut, "create vm_dut fail !") > self.add_console(self.vm_dut.session) > # get virtual machine cpu cores > - self.vcpu_map =3D self.vm.get_vm_cpu() > + _vcpu_map =3D self.vm.get_vm_cpu() > + self.vcpu_map =3D [int(item) for item in _vcpu_map] >=20 > def close_vm(self): > # close vm > @@ -403,7 +407,7 @@ class TestVmPwMgmtPolicy(TestCase): > time.sleep(2) >=20 > def guest_set_vm_turbo_status(self, vcpu, status): > - vcpu_index =3D self.vcpu_map.index(str(self.check_core)) > + vcpu_index =3D self.vcpu_map.index(self.check_core) > cmd =3D ["set_cpu_freq %d %s" % (vcpu_index, status), > "vmpower\(guest\)>", 5] > output =3D self.vm_g_con(cmd) > @@ -447,46 +451,12 @@ class TestVmPwMgmtPolicy(TestCase): > self.vm_testpmd.quit() > self.is_pmd_on =3D False >=20 > - def init_query_script(self): > - self.query_cur_freq =3D os.path.join( > - self.output_path, 'cpu_cur_freq.log') > - script_content =3D textwrap.dedent(""" > - # $1: core number > - sleep 8 > - echo "begin get core "$1" current frequency " > {0} > - while : > - do > - sleep 1 > - cat /sys/devices/system/cpu/cpu$1/cpufreq/cpuinfo_cur_fr= eq >> > {0} > - done > - """).format(self.query_cur_freq) > - fileName =3D 'vm_power_core.sh' > - query_script =3D os.path.join(self.output_path, fileName) > - with open(query_script, 'wb') as fp: > - fp.write('#!/bin/bash' + os.linesep + script_content) > - self.dut.session.copy_file_to(query_script, self.target_dir) > - self.query_tool =3D ';'.join([ > - 'cd {}'.format(self.target_dir), > - 'chmod 777 {}'.format(fileName), > - './' + fileName]) > - > - def start_query(self, core): > - cmd =3D self.query_tool + ' {0} > /dev/null 2>&1 &'.format(core) > - self.d_a_con(cmd) > - self.is_query_on =3D True > - > - def stop_query(self): > - if not self.is_query_on: > - return > - ps_name =3D os.path.basename(self.query_tool) > - cmd =3D "ps aux | grep -i '%s' | grep -v grep | awk {'print $2'}= " % ( > - ps_name) > - out =3D self.d_a_con(cmd) > - if out !=3D "": > - cmd =3D 'pkill -f {}'.format(ps_name) > - self.d_a_con(cmd) > - self.is_query_on =3D False > - self.dut.session.copy_file_from(self.query_cur_freq, self.output= _path) > + def query_cpu_freq(self): > + cmd =3D ("cat " > + "/sys/devices/system/cpu/cpu{}/cpufreq/cpuinfo_cur_freq").fo= rmat( > + self.check_core) > + output =3D self.d_a_con(cmd) > + self.cur_cpu_freq =3D 0 if not output else > + int(output.splitlines()[0]) >=20 > def set_desired_time(self, time_stage): > if not time_stage: > @@ -504,8 +474,8 @@ class TestVmPwMgmtPolicy(TestCase): > cmd =3D ';'.join([ > "{0}", > "{0} -s '{1}'", > - "clock -w"]).format(date_tool, timestamp) > - self.d_a_con(cmd) > + "hwclock -w"]).format(date_tool, timestamp) > + self.d_a_con([cmd, '# ', 20]) > cmd =3D "{0} '+%H:00'".format(date_tool) > output =3D self.d_a_con(cmd) > msg =3D "desired time fails to set" \ @@ -529,9 +499,9 @@ class > TestVmPwMgmtPolicy(TestCase): > cmd =3D ';'.join([ > "{0}", > "{0} -s '{1}'", > - "clock -w", > + "hwclock -w", > "{0}", ]).format(date_tool, real_time) > - self.d_a_con(cmd) > + self.d_a_con([cmd, '# ', 20]) >=20 > def preset_core_freq(self): > info =3D self.cpu_info.get(self.check_core, {}) @@ -663,12 +633,= 8 @@ > class TestVmPwMgmtPolicy(TestCase): > low workload: minimum cpu frequency > ''' > check_item =3D content.get('check') > - query_cur_freq =3D os.path.join( > - self.output_path, os.path.basename(self.query_cur_freq)) > - with open(query_cur_freq, 'rb') as fp: > - content =3D fp.read() > - self.logger.debug(content) > - real_freq =3D int(content.splitlines()[2].strip()) > + real_freq =3D self.cur_cpu_freq > + self.logger.warning(real_freq) > expected_freq =3D self.get_expected_freq(self.check_core, check_= item) > msg =3D ( > 'core <{0}> freq <{1}> are not ' > @@ -692,7 +658,6 @@ class TestVmPwMgmtPolicy(TestCase): >=20 > def run_test_post(self): > # close all binary processes > - self.stop_query() > self.close_vm_testpmd() > self.close_guest_mgr() > self.close_vm_power_mgr() > @@ -703,12 +668,9 @@ class TestVmPwMgmtPolicy(TestCase): > self.start_guest_mgr(content.get('option', '')) > # set binary process command > self.guest_send_policy() > - # start query > - self.start_query(self.check_core) >=20 > def run_guest_post(self): > # close guest > - self.stop_query() > self.close_guest_mgr() >=20 > def traffic_policy(self, name, content): > @@ -736,7 +698,7 @@ class TestVmPwMgmtPolicy(TestCase): > # run time policy, wait 10 second to make sure system re= ady > # and get enough query data > time.sleep(15) > - self.stop_query() > + self.query_cpu_freq() > # check cpu core status > self.check_core_freq(content) > except Exception as e: > @@ -833,7 +795,7 @@ class TestVmPwMgmtPolicy(TestCase): > keys =3D list(_common_config['option'].keys()) > opt_fmt =3D _common_config['opt_fmt'] > for item in product(*values): > - _options =3D dict(zip(keys, item)) > + _options =3D dict(list(zip(keys, item))) > _options['policy'] =3D policy_name > _opt_fmt =3D " ".join(opt_fmt) > _config =3D deepcopy(config) @@ -912,7 +874,7 @@ class > TestVmPwMgmtPolicy(TestCase): > self.verify(status, msg) >=20 > def preset_test_environment(self): > - self.is_mgr_on =3D self.is_pmd_on =3D self.is_query_on =3D None > + self.is_mgr_on =3D self.is_pmd_on =3D None > self.ext_con =3D {} > # get cpu cores information > self.dut.init_core_list_uncached_linux() > @@ -929,9 +891,9 @@ class TestVmPwMgmtPolicy(TestCase): > self.init_vm_power_mgr() > self.init_vm_testpmd() > self.init_guest_mgr() > - self.init_query_script() > # set branch ratio test value > self.check_core =3D int(self.vcpu_map[0]) > + self.cur_cpu_freq =3D None > # used to control testing range. When run with full test, cover = all > # possible command line options combination, it will be long tim= e. > self.full_test =3D False > -- > 2.21.0