mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
cpumf/lshwc: Add command line flag to specify individual counters
Add command-line option --counters "AAA,BBB,...,ZZZ" to specify a comma-separated list of counter names to display. Counter names must match exactly, ignoring case. All counters not listed are excluded from output. 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
3a0c394fa2
commit
4c9ceeeb64
@@ -37,7 +37,7 @@
|
||||
#include "lib/util_base.h"
|
||||
#include "lib/util_path.h"
|
||||
#include "lib/util_scandir.h"
|
||||
#include "lib/util_libc.h"
|
||||
#include "lib/util_str.h"
|
||||
#include "lib/util_file.h"
|
||||
#include "lib/util_fmt.h"
|
||||
#include "lib/libcpumf.h"
|
||||
@@ -61,6 +61,7 @@ static bool hideundef;
|
||||
static bool delta, firstread;
|
||||
static int output_format = FMT_CSV;
|
||||
static bool quote_all;
|
||||
static char *ctrlist; /* Comma separated list of counter to extract */
|
||||
|
||||
static unsigned int max_possible_cpus; /* No of possible CPUs */
|
||||
static struct ctrname { /* List of defined counters */
|
||||
@@ -151,6 +152,8 @@ static bool read_counternames(void)
|
||||
return false;
|
||||
}
|
||||
for (i = 0; i < count && ctr >= 0; i++) {
|
||||
if (!ctr_in_list(namelist[i]->d_name, ctrlist))
|
||||
continue;
|
||||
util_asprintf(&ctrpath, "%s/%s", path, namelist[i]->d_name);
|
||||
if (util_file_read_va(ctrpath, "event=%x", &ctr) == 1)
|
||||
ctrname[ctr].name = mk_name(ctr, namelist[i]->d_name);
|
||||
@@ -779,6 +782,12 @@ static struct util_opt opt_vec[] = {
|
||||
.argument = "FORMAT",
|
||||
.desc = "List counters in specified FORMAT (" FMT_TYPE_NAMES ")"
|
||||
},
|
||||
{
|
||||
.option = { "counters", required_argument, NULL, 'c' },
|
||||
.argument = "LIST",
|
||||
.flags = UTIL_OPT_FLAG_NOSHORT,
|
||||
.desc = "Specify comma separated list of counters to display"
|
||||
},
|
||||
UTIL_OPT_HELP,
|
||||
UTIL_OPT_VERSION,
|
||||
UTIL_OPT_END
|
||||
@@ -892,6 +901,12 @@ int main(int argc, char **argv)
|
||||
errx(EXIT_FAILURE, "Supported formats:" FMT_TYPE_NAMES);
|
||||
output_format = fmt;
|
||||
break;
|
||||
case 'c':
|
||||
hideundef = true;
|
||||
ctrlist = util_strdup(optarg);
|
||||
util_str_rm_whitespace(optarg, ctrlist);
|
||||
util_str_toupper(ctrlist);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -927,5 +942,6 @@ int main(int argc, char **argv)
|
||||
free_counternames();
|
||||
free(check);
|
||||
free(ioctlbuffer);
|
||||
free(ctrlist);
|
||||
return ch;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ lshwc \- extract CPU Measurement Facilities counter sets
|
||||
.IR time ]
|
||||
.RB [ \-f
|
||||
.IR format ]
|
||||
.RB [ \-c
|
||||
.IR list ]
|
||||
\fR[\fIcpulist\fR][:\fIsets\fR]\fP
|
||||
.br
|
||||
\*c
|
||||
@@ -173,6 +175,11 @@ and \fBvalue\fP.
|
||||
.RE
|
||||
.
|
||||
.TP
|
||||
.BR \-c ", " \-\-counters \fI\ LIST\fP
|
||||
Specify a comma-separated list of counter names to be printed.
|
||||
If a counter name does not match any valid counter name, it is omitted. (Implies -H)
|
||||
.
|
||||
.TP
|
||||
\fR[\fIcpulist\fR][:\fIsets\fR]\fP
|
||||
A comma-separated list of CPUs.
|
||||
Each CPU can optionally be followed by characters that specify the counter set.
|
||||
|
||||
Reference in New Issue
Block a user