Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 336757
b: refs/heads/master
c: c8cfc3c
h: refs/heads/master
i:
  336755: d5ae0e5
v: v3
  • Loading branch information
Thomas Renninger authored and Rafael J. Wysocki committed Nov 27, 2012
1 parent 74d875b commit 3d1987f
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ea1021ffa65a81da3d393fcbd7509d6e40d4d325
refs/heads/master: c8cfc3c6bf404b0f110631d5bba234982e6ad24f
15 changes: 13 additions & 2 deletions trunk/tools/power/cpupower/man/cpupower-monitor.1
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ cpupower\-monitor \- Report processor frequency and idle statistics
.RB "\-l"

.B cpupower monitor
.RB [ "\-m <mon1>," [ "<mon2>,..." ] ]
.RB [ -c ] [ "\-m <mon1>," [ "<mon2>,..." ] ]
.RB [ "\-i seconds" ]
.br
.B cpupower monitor
.RB [ "\-m <mon1>," [ "<mon2>,..." ] ]
.RB [ -c ][ "\-m <mon1>," [ "<mon2>,..." ] ]
.RB command
.br
.SH DESCRIPTION
Expand Down Expand Up @@ -64,6 +64,17 @@ Only display specific monitors. Use the monitor string(s) provided by \-l option
Measure intervall.
.RE
.PP
\-c
.RS 4
Schedule the process on every core before starting and ending measuring.
This could be needed for the Idle_Stats monitor when no other MSR based
monitor (has to be run on the core that is measured) is run in parallel.
This is to wake up the processors from deeper sleep states and let the
kernel re
-account its cpuidle (C-state) information before reading the
cpuidle timings from sysfs.
.RE
.PP
command
.RS 4
Measure idle and frequency characteristics of an arbitrary command/workload.
Expand Down
1 change: 1 addition & 0 deletions trunk/tools/power/cpupower/utils/helpers/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ struct cpupower_topology {

extern int get_cpu_topology(struct cpupower_topology *cpu_top);
extern void cpu_topology_release(struct cpupower_topology cpu_top);

/* CPU topology/hierarchy parsing ******************/

/* X86 ONLY ****************************************/
Expand Down
18 changes: 17 additions & 1 deletion trunk/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ static int mode;
static int interval = 1;
static char *show_monitors_param;
static struct cpupower_topology cpu_top;
static unsigned int wake_cpus;

/* ToDo: Document this in the manpage */
static char range_abbr[RANGE_MAX] = { 'T', 'C', 'P', 'M', };
Expand Down Expand Up @@ -314,16 +315,28 @@ int fork_it(char **argv)
int do_interval_measure(int i)
{
unsigned int num;
int cpu;

if (wake_cpus)
for (cpu = 0; cpu < cpu_count; cpu++)
bind_cpu(cpu);

for (num = 0; num < avail_monitors; num++) {
dprint("HW C-state residency monitor: %s - States: %d\n",
monitors[num]->name, monitors[num]->hw_states_num);
monitors[num]->start();
}

sleep(i);

if (wake_cpus)
for (cpu = 0; cpu < cpu_count; cpu++)
bind_cpu(cpu);

for (num = 0; num < avail_monitors; num++)
monitors[num]->stop();


return 0;
}

Expand All @@ -332,7 +345,7 @@ static void cmdline(int argc, char *argv[])
int opt;
progname = basename(argv[0]);

while ((opt = getopt(argc, argv, "+li:m:")) != -1) {
while ((opt = getopt(argc, argv, "+lci:m:")) != -1) {
switch (opt) {
case 'l':
if (mode)
Expand All @@ -351,6 +364,9 @@ static void cmdline(int argc, char *argv[])
mode = show;
show_monitors_param = optarg;
break;
case 'c':
wake_cpus = 1;
break;
default:
print_wrong_arg_exit();
}
Expand Down
17 changes: 17 additions & 0 deletions trunk/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,21 @@ extern long long timespec_diff_us(struct timespec start, struct timespec end);
"could be inaccurate\n"), mes, ov); \
}


/* Taken over from x86info project sources -> return 0 on success */
#include <sched.h>
#include <sys/types.h>
#include <unistd.h>
static inline int bind_cpu(int cpu)
{
cpu_set_t set;

if (sched_getaffinity(getpid(), sizeof(set), &set) == 0) {
CPU_ZERO(&set);
CPU_SET(cpu, &set);
return sched_setaffinity(getpid(), sizeof(set), &set);
}
return 1;
}

#endif /* __CPUIDLE_INFO_HW__ */

0 comments on commit 3d1987f

Please sign in to comment.