Commit 0f5486b5 authored by Frederic Weisbecker's avatar Frederic Weisbecker Committed by Ingo Molnar
Browse files

perf_counter: Sleep before refresh using poll in perf top

perf top is refreshed every delay_secs the thread runs in such

while (sleep(delay_secs)) {

At the end of print_sym_table(), poll is used without sleep delay
to check if we have something from stdin.

It means that this check is done only every delay_secs, which can
be higher that 2 secs if the user defined a custom refresh rate.

We can drop sleep() here and directly use poll to wait between
refresh periods, so that the reaction after the user stops perf top
after typing "Enter" is immediate and doesn't suffer from the
delay_secs latency.

Nb: poll doesn't add any overhead that can parasite perf top measures
since it sleeps the entire timeout here.
Signed-off-by: default avatarFrederic Weisbecker <>
Cc: Peter Zijlstra <>
Cc: Mike Galbraith <>
Cc: Paul Mackerras <>
Cc: Corey Ashford <>
Cc: Marcelo Tosatti <>
Cc: Arnaldo Carvalho de Melo <>
Cc: Frederic Weisbecker <>
LKML-Reference: <>
Signed-off-by: default avatarIngo Molnar <>
parent 62fc4453
......@@ -204,7 +204,7 @@ static void print_sym_table(void)
......@@ -278,23 +278,21 @@ static void print_sym_table(void)
color_fprintf(stdout, color, "%4.1f%%", pcnt);
printf(" - %016llx : %s\n", sym->start, sym->name);
struct pollfd stdin_poll = { .fd = 0, .events = POLLIN };
if (poll(&stdin_poll, 1, 0) == 1) {
printf("key pressed - exiting.\n");
static void *display_thread(void *arg)
struct pollfd stdin_poll = { .fd = 0, .events = POLLIN };
int delay_msecs = delay_secs * 1000;
printf("PerfTop refresh period: %d seconds\n", delay_secs);
while (!sleep(delay_secs))
do {
} while (!poll(&stdin_poll, 1, delay_msecs) == 1);
printf("key pressed - exiting.\n");
return NULL;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment