-
Notifications
You must be signed in to change notification settings - Fork 132
Test to verify numa balancing by verifying numa_pte_updates and numa_hint_faults #3061
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
Merged
Naresh-ibm
merged 2 commits into
avocado-framework-tests:master
from
Pavithra1602:auto_numa
Mar 9, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| #!/usr/bin/env python | ||
| # | ||
| # This program is free software; you can redistribute it and/or modify | ||
| # it under the terms of the GNU General Public License as published by | ||
| # the Free Software Foundation; either version 2 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # This program is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
| # | ||
| # See LICENSE for more details. | ||
| # | ||
| # Copyright: 2025 IBM | ||
| # Author: Pavithra Prakash <pavrampu@linux.vnet.ibm.com> | ||
| # | ||
|
|
||
|
|
||
| import os | ||
| from avocado import Test | ||
| from avocado.utils import build | ||
| from avocado.utils import archive | ||
| from avocado.utils import process | ||
| from avocado.utils.software_manager.manager import SoftwareManager | ||
| from avocado.utils import distro | ||
|
|
||
|
|
||
| class AutoNuma(Test): | ||
|
|
||
| def count_numa_pte_updates(self): | ||
| """ | ||
| This function retrieves the current value of numa_pte_updates | ||
| from /proc/vmstat and returns it as an integer. | ||
| """ | ||
| cmd = 'cat /proc/vmstat | grep numa_pte_updates' | ||
| output = process.run(cmd, shell=True).stdout_text | ||
| return int(output.split()[-1]) | ||
|
|
||
| def count_numa_hint_faults(self): | ||
| """ | ||
| This function fetches the current value of numa_hint_faults from | ||
| /proc/vmstat and returns it as an integer. | ||
| """ | ||
| cmd = 'cat /proc/vmstat | grep numa_hint_faults | head -1' | ||
| output = process.run(cmd, shell=True).stdout_text | ||
| return int(output.split()[-1]) | ||
|
|
||
| def setUp(self): | ||
| """ | ||
| This function sets up the test environment by downloading, extracting, and | ||
| building the ebizzy workload from its source. | ||
| """ | ||
| smm = SoftwareManager() | ||
|
|
||
| detected_distro = distro.detect() | ||
| deps = ['gcc', 'make', 'time'] | ||
| if detected_distro.name == "rhel": | ||
| deps.extend(['numactl-devel']) | ||
| for packages in deps: | ||
| if not smm.check_installed(packages) and not smm.install(packages): | ||
| self.cancel('%s is needed for the test to be run' % packages) | ||
| self.url = self.params.get('ebizzy_url', | ||
| default='https://sourceforge.net/projects/ebizzy/files/ebizzy/0.3/ebizzy-0.3.tar.gz') | ||
| tarball = self.fetch_asset("ebizzy-0.3.tar.gz", locations=[self.url], expire='7d') | ||
| archive.extract(tarball, self.workdir) | ||
| version = os.path.basename(tarball.split('.tar.')[0]) | ||
| self.sourcedir = os.path.join(self.workdir, version) | ||
| os.chdir(self.sourcedir) | ||
| process.run('[ -x configure ] && ./configure', shell=True) | ||
| build.make(self.sourcedir) | ||
|
|
||
| def test(self): | ||
| """ | ||
| This test performs the following steps: | ||
|
|
||
| - Records the initial values of numa_pte_updates and numa_hint_faults. | ||
| - Disables NUMA balancing and runs ebizzy workload. | ||
| - Records the new values of numa_pte_updates and numa_hint_faults. | ||
| - Checks if there's any change in the values if yes, the test fails. | ||
| - Enables NUMA balancing and runs ebizzy workload again. | ||
| - Checks if numa_pte_updates and numa_hint_faults have increased by at least 10 after | ||
| enabling NUMA balancing. If not, the test fails. | ||
| """ | ||
| init_pte_updates = self.count_numa_pte_updates() | ||
| init_hint_faults = self.count_numa_hint_faults() | ||
| process.run('echo "0" > /proc/sys/kernel/numa_balancing', shell=True) | ||
| process.run('./ebizzy', shell=True) | ||
| pte_updates_0 = self.count_numa_pte_updates() | ||
| hint_faults_0 = self.count_numa_hint_faults() | ||
| if(pte_updates_0 - init_pte_updates) or (hint_faults_0 - init_hint_faults): | ||
| self.fail("Numa balancing disable test failed") | ||
| process.run('echo "1" > /proc/sys/kernel/numa_balancing', shell=True) | ||
| process.run('./ebizzy', shell=True) | ||
| pte_updates_1 = self.count_numa_pte_updates() | ||
| hint_faults_1 = self.count_numa_hint_faults() | ||
| if(pte_updates_1 - init_pte_updates) < 10: | ||
| self.fail("numa_pte_updates has not incremented even after " | ||
| "running workload with numa balancing enabled.") | ||
| if(hint_faults_1 - init_hint_faults) < 10: | ||
| self.fail("numa_hint_faults has not incremented even after" | ||
| " running workload with numa balancing enabled.") | ||
|
|
||
| def test_autonuma_benchmark(self): | ||
| """ | ||
| This test case runs downloading, extracting, and running the autonuma-benchmark tests, | ||
| Test results need to be verified manually. | ||
| """ | ||
| url_autonuma = self.params.get('url_autonuma', | ||
| default='https://github.com/pholasek/autonuma-benchmark/archive/refs/heads/master.zip') | ||
| tarball = self.fetch_asset("master.zip", locations=[url_autonuma], expire='7d') | ||
| archive.extract(tarball, self.workdir) | ||
| self.sourcedir = os.path.join(self.workdir, "autonuma-benchmark-master") | ||
| os.chdir(self.sourcedir) | ||
| process.system_output('./start_bench.sh -A', shell=True, ignore_status=True) | ||
| self.log.warn("Have run the tests please review the results in debug.log") | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| ebizzy_url: 'https://sourceforge.net/projects/ebizzy/files/ebizzy/0.3/ebizzy-0.3.tar.gz' | ||
| url_autonuma: 'https://github.com/pholasek/autonuma-benchmark/archive/refs/heads/master.zip' |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.