summaryrefslogtreecommitdiff
path: root/tools/tracing/rtla/src/timerlat.c
diff options
context:
space:
mode:
authorCosta Shulyupin <costa.shul@redhat.com>2025-10-02 15:35:38 +0300
committerTomas Glozar <tglozar@redhat.com>2025-11-20 13:15:53 +0100
commit04fa6bf3736d727bb800dddb23c9a513969e565d (patch)
treee0bc4cff09ea89949b03cf92f10a4edd6540d486 /tools/tracing/rtla/src/timerlat.c
parent0d5077c73aceb51ef10d096160dd62a11db2f3e4 (diff)
downloadlinux-next-04fa6bf3736d727bb800dddb23c9a513969e565d.tar.gz
linux-next-04fa6bf3736d727bb800dddb23c9a513969e565d.zip
tools/rtla: Add for_each_monitored_cpu() helper
The rtla tools have many instances of iterating over CPUs while checking if they are monitored. Add a for_each_monitored_cpu() helper macro to make the code more readable and reduce code duplication. Signed-off-by: Costa Shulyupin <costa.shul@redhat.com> Reviewed-by: Tomas Glozar <tglozar@redhat.com> Link: https://lore.kernel.org/r/20251002123553.389467-1-costa.shul@redhat.com Signed-off-by: Tomas Glozar <tglozar@redhat.com>
Diffstat (limited to 'tools/tracing/rtla/src/timerlat.c')
-rw-r--r--tools/tracing/rtla/src/timerlat.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/tools/tracing/rtla/src/timerlat.c b/tools/tracing/rtla/src/timerlat.c
index b69212874127..28ea4f6710c1 100644
--- a/tools/tracing/rtla/src/timerlat.c
+++ b/tools/tracing/rtla/src/timerlat.c
@@ -126,9 +126,7 @@ int timerlat_enable(struct osnoise_tool *tool)
nr_cpus = sysconf(_SC_NPROCESSORS_CONF);
- for (i = 0; i < nr_cpus; i++) {
- if (params->common.cpus && !CPU_ISSET(i, &params->common.monitored_cpus))
- continue;
+ for_each_monitored_cpu(i, nr_cpus, &params->common) {
if (save_cpu_idle_disable_state(i) < 0) {
err_msg("Could not save cpu idle state.\n");
return -1;
@@ -221,10 +219,7 @@ void timerlat_free(struct osnoise_tool *tool)
if (dma_latency_fd >= 0)
close(dma_latency_fd);
if (params->deepest_idle_state >= -1) {
- for (i = 0; i < nr_cpus; i++) {
- if (params->common.cpus &&
- !CPU_ISSET(i, &params->common.monitored_cpus))
- continue;
+ for_each_monitored_cpu(i, nr_cpus, &params->common) {
restore_cpu_idle_disable_state(i);
}
}