Skip to content

Commit

Permalink
tools/power turbostat: on SIGUSR1: sample, print and continue
Browse files Browse the repository at this point in the history
Interval-mode turbostat now catches and discards SIGUSR1.

Thus, SIGUSR1 can be used to tell turbostat to cut short
the current measurement interval.  Turbostat will then start
the next measurement interval using the regular interval length.

This can be used to give turbostat variable intervals.
Invoke turbostat with --interval LARGE_NUMBER_SEC
and have a program that has permission to send it a SIGUSR1
always before LARGE_NUMBER_SEC expires.

It may also be useful to use "--enable Time_Of_Day_Seconds"
to observe the actual interval length.

Signed-off-by: Len Brown <len.brown@intel.com>
  • Loading branch information
Len Brown committed Jun 1, 2018
1 parent 8aa2ed0 commit 0721196
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tools/power/x86/turbostat/turbostat.8
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ CPU PRF_CTRL

SIGINT will interrupt interval-mode.
The end-of-interval data will be collected and displayed before turbostat exits.

SIGUSR1 will end current interval,
end-of-interval data will be collected and displayed before turbostat
starts a new interval.
.SH NOTES

.B "turbostat "
Expand Down
6 changes: 6 additions & 0 deletions tools/power/x86/turbostat/turbostat.c
Original file line number Diff line number Diff line change
Expand Up @@ -2610,6 +2610,10 @@ static void signal_handler (int signal)
if (debug)
fprintf(stderr, " SIGINT\n");
break;
case SIGUSR1:
if (debug > 1)
fprintf(stderr, "SIGUSR1\n");
break;
}
}

Expand All @@ -2623,6 +2627,8 @@ void setup_signal_handler(void)

if (sigaction(SIGINT, &sa, NULL) < 0)
err(1, "sigaction SIGINT");
if (sigaction(SIGUSR1, &sa, NULL) < 0)
err(1, "sigaction SIGUSR1");
}
void turbostat_loop()
{
Expand Down

0 comments on commit 0721196

Please sign in to comment.