From f8d188317236e1a27c0992b7f5b9655af3983139 Mon Sep 17 00:00:00 2001 From: Disha Goel Date: Fri, 2 Aug 2024 18:40:02 +0530 Subject: [PATCH 1/2] perf: enhance tests to support Power11 This commit enhances the perf tests to support Power11 processor. Signed-off-by: Disha Goel --- perf/perf_24x7_all_events.py | 2 +- perf/perf_24x7_hardware_counters.py | 18 +++++++++--------- perf/perf_cpu_hotplug.py | 11 ++++------- perf/perf_genericevents.py | 2 +- perf/perf_json.py | 2 +- perf/perf_metric.py | 6 +++--- 6 files changed, 19 insertions(+), 22 deletions(-) diff --git a/perf/perf_24x7_all_events.py b/perf/perf_24x7_all_events.py index a39347654..2d4b79f5c 100755 --- a/perf/perf_24x7_all_events.py +++ b/perf/perf_24x7_all_events.py @@ -62,7 +62,7 @@ def setUp(self): perf_stat = "%s hv_24x7/HPM_0THRD_NON_IDLE_CCYC" % perf_args elif self.rev == '004e': perf_stat = "%s hv_24x7/CPM_TLBIE" % perf_args - elif self.rev == '0080': + elif self.rev in ['0080', '0082']: perf_stat = "%s hv_24x7/CPM_TLBIE_FIN" % perf_args event_sysfs = "/sys/bus/event_source/devices/hv_24x7" diff --git a/perf/perf_24x7_hardware_counters.py b/perf/perf_24x7_hardware_counters.py index 79ed61c96..25f002a76 100755 --- a/perf/perf_24x7_hardware_counters.py +++ b/perf/perf_24x7_hardware_counters.py @@ -72,7 +72,7 @@ def setUp(self): self.perf_stat = "%s hv_24x7/HPM_0THRD_NON_IDLE_CCYC" % self.perf_args if self.rev == '004e': self.perf_stat = "%s hv_24x7/CPM_TLBIE" % self.perf_args - if self.rev == '0080': + if self.rev in ['0080', '0082']: self.perf_stat = "%s hv_24x7/CPM_TLBIE_FIN" % self.perf_args self.event_sysfs = "/sys/bus/event_source/devices/hv_24x7" @@ -175,10 +175,10 @@ def test_check_invalid_core(self): self.fail('perf unable to recognize out of range core value') def test_event_w_chip_param(self): - if self.rev == '004b' or self.rev == '004e': + if self.rev in ['004b', '004e']: event_out = genio.read_file( "%s/events/PM_PB_CYC" % self.event_sysfs).rstrip('\t\r\n\0') - if self.rev == '0080': + if self.rev in ['0080', '0082']: event_out = genio.read_file( "%s/events/PM_PHB0_0_CYC" % self.event_sysfs).rstrip('\t\r\n\0') if "chip=?" in event_out: @@ -192,9 +192,9 @@ def test_event_w_chip_param(self): self.fail('chip file does not exist') def test_event_wo_chip_param(self): - if self.rev == '004b' or self.rev == '004e': + if self.rev in ['004b', '004e']: cmd = "hv_24x7/PM_PB_CYC,domain=1/ /bin/true" - if self.rev == '0080': + if self.rev in ['0080', '0082']: cmd = "hv_24x7/PM_PHB0_0_CYC,domain=1/ /bin/true" chip_miss = self.event_stat1(cmd) if "Required parameter 'chip' not specified" not in chip_miss.stdout.decode("utf-8"): @@ -209,9 +209,9 @@ def test_check_valid_chip(self): Test chip value in range self.chips-1 and max 65535 """ for chip_val in range(0, self.chips): - if self.rev == '004b' or self.rev == '004e': + if self.rev in ['004b', '004e']: cmd = "hv_24x7/PM_PB_CYC,domain=1,chip=%s/ /bin/true" % chip_val - if self.rev == '0080': + if self.rev in ['0080', '0082']: cmd = "hv_24x7/PM_PHB0_0_CYC,domain=1,chip=%s/ /bin/true" % chip_val output_chip = self.event_stat1(cmd) if "Performance counter stats for" not in output_chip.stderr.decode("utf-8"): @@ -223,9 +223,9 @@ def test_check_invalid_chip(self): """ invalid_chip = [self.chips, 65536] for chip_val in invalid_chip: - if self.rev == '004b' or self.rev == '004e': + if self.rev in ['004b', '004e']: cmd = "hv_24x7/PM_PB_CYC,domain=1,chip=%s/ /bin/true" % chip_val - if self.rev == '0080': + if self.rev in ['0080', '0082']: cmd = "hv_24x7/PM_PHB0_0_CYC,domain=1,chip=%s/ /bin/true" % chip_val res = self.event_stat1(cmd) if res.exit_status == 0: diff --git a/perf/perf_cpu_hotplug.py b/perf/perf_cpu_hotplug.py index b683c187c..c3894e2f7 100644 --- a/perf/perf_cpu_hotplug.py +++ b/perf/perf_cpu_hotplug.py @@ -57,19 +57,16 @@ def setUp(self): 3. Offline the cpumask CPU and check cpumask moved to new CPU or not """ smm = SoftwareManager() - processor_type = genio.read_file("/proc/cpuinfo") - + self.rev = cpu.get_revision() detected_distro = distro.detect() + # Offline cpu list during the test self.cpu_off = [] if 'ppc64' not in detected_distro.arch: self.cancel("Processor is not PowerPC") - for line in processor_type.splitlines(): - if 'revision' in line: - self.rev = (line.split(':')[1]) - if '0080' not in self.rev: - self.cancel("Test is supported only on Power10") + if self.rev not in ['0080', '0082']: + self.cancel("Test is supported on Power10 and above") deps = ['gcc', 'make'] if 'Ubuntu' in detected_distro.name: diff --git a/perf/perf_genericevents.py b/perf/perf_genericevents.py index 72ebc722d..0fbf20b6d 100755 --- a/perf/perf_genericevents.py +++ b/perf/perf_genericevents.py @@ -44,7 +44,7 @@ def read_generic_events(self): self.generic_events = dict(parser.items('POWER8')) elif '004e' in self.rev: self.generic_events = dict(parser.items('POWER9')) - elif '0080' in self.rev: + elif '0080' in self.rev or '0082' in self.rev: self.generic_events = dict(parser.items('POWER10')) else: self.cancel("Processor is not supported: %s" % cpu_info) diff --git a/perf/perf_json.py b/perf/perf_json.py index d59f67098..c04acd2f4 100644 --- a/perf/perf_json.py +++ b/perf/perf_json.py @@ -96,7 +96,7 @@ def setUp(self): process.system("make prefix=/usr/local install -C %s" % self.sourcedir, shell=True, sudo=True) self.rev = cpu.get_revision() - rev_to_power = {'004b': 'power8', '004e': 'power9', '0080': 'power10'} + rev_to_power = {'004b': 'power8', '004e': 'power9', '0080': 'power10', '0082': 'power10'} if self.rev in rev_to_power: self.testdir += '%s/' % rev_to_power[self.rev] self.sourcedir = os.path.join(self.buldir, self.testdir) diff --git a/perf/perf_metric.py b/perf/perf_metric.py index db1fe600d..5295eeda8 100755 --- a/perf/perf_metric.py +++ b/perf/perf_metric.py @@ -117,12 +117,12 @@ def test_all_metric_events_with_metric(self): def test_cpi_stall(self): """ - Function to test CPI_STALL_RATIO feature. Power10 PMU provides events - to understand stall cycles of different pipeline stages. + Function to test CPI_STALL_RATIO feature. On Power10 and above, PMU provides + events to understand stall cycles of different pipeline stages. """ # Check if CPI_STALL_RATIO metricgroup is present in perf list or not output = process.system_output('perf list metricgroup') - if self.rev == '0080' and 'CPI_STALL_RATIO' in output.decode().split(): + if self.rev in ['0080', '0082'] and 'CPI_STALL_RATIO' in output.decode().split(): cmd = "perf stat --metric-no-group -M CPI_STALL_RATIO perf bench sched messaging" res = process.run(cmd, shell=True, verbose=True) result = (res.stdout + res.stderr).decode() From d9ef3ce9688cc8bce6f970790097f32e542b3a24 Mon Sep 17 00:00:00 2001 From: Disha Goel Date: Tue, 6 Aug 2024 16:19:49 +0530 Subject: [PATCH 2/2] perf/perf_rawevents: enhance test to handle missing files and add support for P11 Modified `copy_files` method to handle cases where the source file is `None` or does not exist. Simplified the retrieval of CPU revision by using `cpu.get_revision()` instead of parsing `/proc/cpuinfo`. Added support for testing Power11 revision `0082` by using Power10 files only since no event changes are there. Signed-off-by: Disha Goel --- perf/perf_rawevents.py | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/perf/perf_rawevents.py b/perf/perf_rawevents.py index f4b41779d..88f0b1554 100644 --- a/perf/perf_rawevents.py +++ b/perf/perf_rawevents.py @@ -18,14 +18,14 @@ import platform import shutil from avocado import Test -from avocado.utils import distro, process, genio +from avocado.utils import distro, process, genio, cpu from avocado.utils.software_manager.manager import SoftwareManager class PerfRawevents(Test): """ - Tests raw events on Power8, Power9 and Power10 along with + Tests raw events on different Power platforms along with named events :avocado: tags=perf,rawevents,events """ @@ -33,8 +33,11 @@ class PerfRawevents(Test): fail_cmd = list() def copy_files(self, filename): - shutil.copyfile(self.get_data(filename), - os.path.join(self.teststmpdir, filename)) + src = self.get_data(filename) + if src is None or not os.path.isfile(src): + self.cancel(f'File {filename} not found.') + else: + shutil.copyfile(src, os.path.join(self.teststmpdir, filename)) def setUp(self): ''' @@ -45,10 +48,7 @@ def setUp(self): smm = SoftwareManager() detected_distro = distro.detect() self.distro_name = detected_distro.name - processor = genio.read_file("/proc/cpuinfo") - for line in processor.splitlines(): - if 'revision' in line: - self.rev = (line.split(' ')[3].strip()) + self.rev = cpu.get_revision() if detected_distro.arch != 'ppc64le': self.cancel('This test is not supported on %s architecture' % detected_distro.arch) @@ -67,9 +67,13 @@ def setUp(self): if not smm.check_installed(package) and not smm.install(package): self.cancel('%s is needed for the test to be run' % package) - for filename in ['name_events_004b', 'raw_codes_004b', 'name_events_004e', - 'raw_codes_004e', 'name_events_0080', 'raw_codes_0080']: - self.copy_files(filename) + revisions_to_test = ['004b', '004e', '0080', '0082'] + for rev in revisions_to_test: + for filename in [f'name_events_{rev}', f'raw_codes_{rev}']: + if rev == '0082': + # Use Power10 files for Power11 + filename = filename.replace('0082', '0080') + self.copy_files(filename) os.chdir(self.teststmpdir) # Clear the dmesg to capture the delta at the end of the test. @@ -91,13 +95,13 @@ def error_check(self): self.fail("perf_raw_events: refer log file for failed events") def test_raw_code(self): - file_name = 'raw_codes_' + self.rev + file_name = 'raw_codes_' + (self.rev if self.rev != '0082' else '0080') perf_flags = "perf stat -e r" self.run_event(file_name, perf_flags) self.error_check() def test_name_event(self): - file_name = 'name_events_' + self.rev + file_name = 'name_events_' + (self.rev if self.rev != '0082' else '0080') perf_flags = "perf stat -e " self.run_event(file_name, perf_flags) self.error_check()