mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
libcpumf: Relocate ctr_in_list() for shared use
Move ctr_in_list() from cpumf/lspai.c to a shared location to enable reuse in other binaries that require counter list filtering. Reviewed-by: Thomas Richter <tmricht@linux.ibm.com> Signed-off-by: Jan Polensky <japo@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
20a4ebd83c
commit
3a0c394fa2
@@ -14,6 +14,7 @@
|
||||
|
||||
#include "lib/libcpumf.h"
|
||||
#include "lib/util_path.h"
|
||||
#include "lib/util_libc.h"
|
||||
|
||||
#define SERVICELEVEL "/proc/service_levels"
|
||||
|
||||
@@ -175,3 +176,25 @@ long perf_event_open(struct perf_event_attr *hw_event, pid_t pid, int cpu, int g
|
||||
{
|
||||
return syscall(__NR_perf_event_open, hw_event, pid, cpu, group_fd, flags);
|
||||
}
|
||||
|
||||
bool ctr_in_list(char *name, char *ctrlist)
|
||||
{
|
||||
char *token;
|
||||
char *list;
|
||||
|
||||
if (!ctrlist) /* No --counters means all counters */
|
||||
return true;
|
||||
|
||||
list = util_strdup(ctrlist);
|
||||
token = strtok(list, ",");
|
||||
while (token) {
|
||||
if (strcmp(token, name) == 0) {
|
||||
free(list);
|
||||
return true;
|
||||
}
|
||||
token = strtok(NULL, ",");
|
||||
}
|
||||
|
||||
free(list);
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user