Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding "perf_lock" Tests. #2811

Merged

Conversation

FarooqAbdulla02
Copy link
Contributor

Adding test of "perf lock" command with options called "record",
"report", "info", "script", "contention" with all possible through YAML file.

@FarooqAbdulla02
Copy link
Contributor Author

Run logs:

root@new:~/avocado-fvt-wrapper/tests/avocado-misc-tests/perf # avocado run perf_lock.py -m perf_lock.py.data/test_report.yaml --max-parallel-tasks=1
JOB ID : 345cb72c06ba80379f0abf8bf907bf9aed9c038f
JOB LOG : /root/avocado-fvt-wrapper/results/job-2042-02-14T08.33-345cb72/job.log
(01/15) perf_lock.py:perf_lock.test_lock;run-subsystem-record-variants-all_cpus-cb98: STARTED
(01/15) perf_lock.py:perf_lock.test_lock;run-subsystem-record-variants-all_cpus-cb98: PASS (13.28 s)
(02/15) perf_lock.py:perf_lock.test_lock;run-subsystem-record-variants-scheduling_message-4a1c: STARTED
(02/15) perf_lock.py:perf_lock.test_lock;run-subsystem-record-variants-scheduling_message-4a1c: PASS (4.48 s)
(03/15) perf_lock.py:perf_lock.test_lock;run-subsystem-report-variants-wait_field-7ace: STARTED
(03/15) perf_lock.py:perf_lock.test_lock;run-subsystem-report-variants-wait_field-7ace: PASS (4.54 s)
(04/15) perf_lock.py:perf_lock.test_lock;run-subsystem-report-variants-all_fields-83fe: STARTED
(04/15) perf_lock.py:perf_lock.test_lock;run-subsystem-report-variants-all_fields-83fe: PASS (4.47 s)
(05/15) perf_lock.py:perf_lock.test_lock;run-subsystem-report-variants-locks_with_entries-5eed: STARTED
(05/15) perf_lock.py:perf_lock.test_lock;run-subsystem-report-variants-locks_with_entries-5eed: PASS (195.88 s)
(06/15) perf_lock.py:perf_lock.test_lock;run-subsystem-report-variants-vmlinux_full-7632: STARTED
(06/15) perf_lock.py:perf_lock.test_lock;run-subsystem-report-variants-vmlinux_full-7632: PASS (4.46 s)
(07/15) perf_lock.py:perf_lock.test_lock;run-subsystem-info-variants-threads_list-955b: STARTED
(07/15) perf_lock.py:perf_lock.test_lock;run-subsystem-info-variants-threads_list-955b: PASS (4.52 s)
(08/15) perf_lock.py:perf_lock.test_lock;run-subsystem-info-variants-map_instances-46db: STARTED
(08/15) perf_lock.py:perf_lock.test_lock;run-subsystem-info-variants-map_instances-46db: PASS (4.49 s)
(09/15) perf_lock.py:perf_lock.test_lock;run-subsystem-script-variants-input_data-4fb1: STARTED
(09/15) perf_lock.py:perf_lock.test_lock;run-subsystem-script-variants-input_data-4fb1: PASS (4.53 s)
(10/15) perf_lock.py:perf_lock.test_lock;run-subsystem-contention-variants-contention_fields-e93e: STARTED
(10/15) perf_lock.py:perf_lock.test_lock;run-subsystem-contention-variants-contention_fields-e93e: PASS (4.50 s)
(11/15) perf_lock.py:perf_lock.test_lock;run-subsystem-contention-variants-all_cpus_entires-48d1: STARTED
(11/15) perf_lock.py:perf_lock.test_lock;run-subsystem-contention-variants-all_cpus_entires-48d1: PASS (4.53 s)
(12/15) perf_lock.py:perf_lock.test_lock;run-subsystem-contention-variants-avg_wait_key-8f59: STARTED
(12/15) perf_lock.py:perf_lock.test_lock;run-subsystem-contention-variants-avg_wait_key-8f59: PASS (4.42 s)
(13/15) perf_lock.py:perf_lock.test_lock;run-subsystem-contention-variants-trace_PID-fb94: STARTED
(13/15) perf_lock.py:perf_lock.test_lock;run-subsystem-contention-variants-trace_PID-fb94: PASS (4.55 s)
(14/15) perf_lock.py:perf_lock.test_lock;run-subsystem-contention-variants-input_full-b82a: STARTED
(14/15) perf_lock.py:perf_lock.test_lock;run-subsystem-contention-variants-input_full-b82a: PASS (4.49 s)
(15/15) perf_lock.py:perf_lock.test_lock;run-subsystem-contention-variants-vmlinux_full-390a: STARTED
(15/15) perf_lock.py:perf_lock.test_lock;run-subsystem-contention-variants-vmlinux_full-390a: PASS (4.54 s)
RESULTS : PASS 15 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB HTML : /root/avocado-fvt-wrapper/results/job-2042-02-14T08.33-345cb72/results.html
JOB TIME : 382.70 s

root@new:~/avocado-fvt-wrapper/tests/avocado-misc-tests/perf # avocado run perf_lock.py --max-parallel-tasks=1
JOB ID : 5b7addea87a85d9f4f44fb74e24af3eab20f21c3
JOB LOG : /root/avocado-fvt-wrapper/results/job-2042-02-14T08.49-5b7adde/job.log
(1/1) perf_lock.py:perf_lock.test_lock: STARTED
(1/1) perf_lock.py:perf_lock.test_lock: PASS (4.54 s)
RESULTS : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB HTML : /root/avocado-fvt-wrapper/results/job-2042-02-14T08.49-5b7adde/results.html
JOB TIME : 151.27 s

Log files:
perf_lock_with_yaml.tar.gz
perf_lock_without_yaml.tar.gz
SLES_perf-lock_with_yaml.tar.gz
SLES_perf-lock_without_yaml.tar.gz

Comment on lines 113 to 146
# Report command
if self.record == 'report':
report_cmd = "perf lock %s %s " % (self.record, self.option)
if self.option in ["--kallsyms"]:
self.option = self.get_kernel_version()
report_cmd = "perf lock %s %s -E 3" % (self.record,
self.option)
if self.check_perfdata_file_exist:
self.run_cmd(report_cmd)

# Info command
elif self.record == 'info':
report_cmd = "perf lock %s %s" % (self.record, self.option)
if self.check_perfdata_file_exist:
self.run_cmd(report_cmd)

# Script command
elif self.record == 'script':
report_cmd = "perf lock %s %s %s" % (self.record,
self.option,
self.output_file)
if self.check_perfdata_file_exist:
self.run_cmd(report_cmd)

# contention command
elif self.record == 'contention':
report_cmd = "perf lock %s %s" % (self.record, self.option)
if self.option in ["--vmlinux"]:
self.option = self.get_kernel_version()
report_cmd = "perf lock %s %s" % (self.record, self.option)
elif self.option in ["-i"]:
report_cmd = "perf lock %s %s %s" % (self.record,
self.option,
self.output_file)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All this can be clubbed in a single command. Inside this you can have checks for --kallsyms and --vmlinux. Other than that other parameters should be part of yaml file.
report_cmd = "perf lock -i %s %s %s" % (self.output_file, self.record, self.option)

Comment on lines 2 to 8
record:
name: record
variants: !mux
all_cpus:
option: -a -v sleep 3
scheduling_message:
option: -- perf bench sched messaging
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where are you running these record commands in the py file?

name: script
variants: !mux
input_data:
option: -i
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can add -f also in option option: -f -i

locks_with_entries:
option: -c -D -E 5
vmlinux_full:
option: --kallsyms
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-E 3 you can add here instead of .py file
option: -E 3 --kallsyms

trace_PID:
option: -p 1 -x ,
input_full:
option: -i
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try with option: -Y spinlock -q -i

input_full:
option: -i
vmlinux_full:
option: --vmlinux
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can change it to option: -E 2 --vmlinux

Comment on lines 88 to 99
def get_kernel_version(self):
'''
Funtion to get kernel version based on distro type
'''

if 'rhel' in self.distro_name:
self.kernel_version = self.option + \
" /boot/vmlinuz-" + platform.uname()[2]
elif 'SuSE' in self.distro_name:
self.kernel_version = self.option + \
" /boot/vmlinux-" + platform.uname()[2]
return self.kernel_version
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need of this function separately

Copy link
Contributor

@vaishnavibhat vaishnavibhat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perf command is provided by 'perf' package.Can we have this included along with make, gcc and not as a extended package ?

Copy link
Contributor

@disgoel disgoel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@Naresh-ibm Naresh-ibm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FarooqAbdulla02 can you add a README.txt as this a new test script.

@FarooqAbdulla02
Copy link
Contributor Author

@Naresh-ibm added "readme.txt" file with supported option set.

Copy link
Member

@PraveenPenguin PraveenPenguin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FarooqAbdulla02 thanks for patch , a couple of suggestion can you please address review comment and seems py file has a lot of whitespace please trim those

"""
Tests perf lock and it's options namely record, report, info, script
contention with all possible flags with the help of yaml file
:avocado: tags=perf,lock
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i feel lock should not tag as tag is used to filter and align in category

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PraveenPenguin sure, will remove "lock" here.


# Check perf lock is available in the system.
output = process.run('perf list | awk \'/lock:contention*/\'',
shell=True).stdout.decode("utf-8")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How hard to achieve this using python ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PraveenPenguin we can achieve same output with this command

    command = 'perf list | grep lock:contention*'
    output = process.run(command, shell=True).stdout.decode("utf-8")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FarooqAbdulla02 don't grep for lock:contention as its a subcommand in perf lock. we want to see if lock is enabled or not before running the test. You can use below command to check.
perf list|grep -iw lock:.*

@Naresh-ibm
Copy link
Collaborator

@FarooqAbdulla02 can you please check on Praveen's comments and re-push if needed?
will merge once you conclude on Praveen's comments

Adding test of "perf lock" command with options called
"record", "report", "info", "script", "contention" with
all possible through YAML file.

Signed-off-by: Shaik Abdulla <[email protected]>
Copy link
Collaborator

@abdhaleegit abdhaleegit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@Naresh-ibm Naresh-ibm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Naresh-ibm Naresh-ibm merged commit 2b8a3f0 into avocado-framework-tests:master Jun 8, 2024
3 checks passed
@kjain101
Copy link
Contributor

It seems this testcase doen't cover installing clang and other required bpf packages. So it might miss some of the functionality testing. Can you also add bpf part

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants