diff options
author | Jiri Olsa <jolsa@kernel.org> | 2018-11-05 23:23:40 +0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-12-17 20:58:03 +0300 |
commit | 94ad6e7e3606454498aeac1fdd1b9de5c1e6735a (patch) | |
tree | 00954eb7ea985e5053f7c1b53fc9c419a1316d4e /tools/perf/util/top.h | |
parent | 16c66bc167cc52992f66748aed7ac21396189457 (diff) | |
download | linux-94ad6e7e3606454498aeac1fdd1b9de5c1e6735a.tar.xz |
perf top: Use cond variable instead of a lock
Use conditional variable logic to synchronize between the reading and
processing threads. Currently it's done by having mutex around rotation
code.
Using a POSIX cond variable to sync both threads after queues rotation:
Process thread:
- Detects data
- Switches queues
- Sets rotate variable
- Waits in pthread_cond_wait()
Read thread:
- Detects rotate is set
- Kicks the process thread with a pthread_cond_signal()
After this rotation is safely completed and both threads can continue
with the new queue.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: David S. Miller <davem@davemloft.net>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/n/tip-3rdeg23rv3brvy1pwt3igvyw@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/top.h')
-rw-r--r-- | tools/perf/util/top.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/tools/perf/util/top.h b/tools/perf/util/top.h index 5f503293cfd8..5bce62ebcf14 100644 --- a/tools/perf/util/top.h +++ b/tools/perf/util/top.h @@ -44,7 +44,9 @@ struct perf_top { struct { struct ordered_events *in; struct ordered_events data[2]; - pthread_mutex_t lock; + bool rotate; + pthread_mutex_t mutex; + pthread_cond_t cond; } qe; }; |