lkml.org 
[lkml]   [2020]   [May]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] perf/evsel: Fix missing close fd when ignore_missing_thread
Date
While monitoring a multithread process with pid option, if any of the
threads exit before we open the event fd, we can ignore the missing
thread.

We use perf_evsel__remove_fd() to remove the FD of the missing thread,
but we missed to close these fds. This patch explicitly closes the fd
before remove it.

Fixes: ca8000684ec4 ("perf evsel: Enable ignore_missing_thread for pid option")
Signed-off-by: Cheng Jian <cj.chengjian@huawei.com>
---
tools/perf/util/evsel.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index eb880efbce16..cbb04a18839c 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1489,9 +1489,13 @@ static void perf_evsel__remove_fd(struct evsel *pos,
int nr_cpus, int nr_threads,
int thread_idx)
{
- for (int cpu = 0; cpu < nr_cpus; cpu++)
- for (int thread = thread_idx; thread < nr_threads - 1; thread++)
+ for (int cpu = 0; cpu < nr_cpus; cpu++) {
+ for (int thread = thread_idx;
+ thread < nr_threads - 1; thread++) {
+ close(FD(pos, cpu, thread));
FD(pos, cpu, thread) = FD(pos, cpu, thread + 1);
+ }
+ }
}

static int update_fds(struct evsel *evsel,
--
2.17.1
\
 
 \ /
  Last update: 2020-05-30 08:16    [W:0.907 / U:0.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site