Skip to content

Commit

Permalink
Merge pull request avocado-framework-tests#2865 from disgoel/p11-changes
Browse files Browse the repository at this point in the history
perf: enhance tests to support Power11
  • Loading branch information
PraveenPenguin authored Sep 3, 2024
2 parents 6d1b324 + d9ef3ce commit 83f787c
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 35 deletions.
2 changes: 1 addition & 1 deletion perf/perf_24x7_all_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
18 changes: 9 additions & 9 deletions perf/perf_24x7_hardware_counters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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:
Expand All @@ -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"):
Expand All @@ -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"):
Expand All @@ -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:
Expand Down
11 changes: 4 additions & 7 deletions perf/perf_cpu_hotplug.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion perf/perf_genericevents.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion perf/perf_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions perf/perf_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
30 changes: 17 additions & 13 deletions perf/perf_rawevents.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,26 @@
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
"""
# Initializing fail command list
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):
'''
Expand All @@ -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)
Expand All @@ -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.
Expand All @@ -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()
Expand Down

0 comments on commit 83f787c

Please sign in to comment.