[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20191020161346.18938-3-andi@firstfloor.org>
Date: Sun, 20 Oct 2019 09:13:39 -0700
From: Andi Kleen <andi@...stfloor.org>
To: acme@...nel.org
Cc: jolsa@...nel.org, eranian@...gle.com, kan.liang@...ux.intel.com,
peterz@...radead.org, linux-kernel@...r.kernel.org,
Andi Kleen <ak@...ux.intel.com>
Subject: [PATCH v1 2/9] perf evsel: Avoid close(-1)
From: Andi Kleen <ak@...ux.intel.com>
In some weak fallback cases close can be called a lot with -1. Check
for this case and avoid calling close then.
This is mainly to shut up valgrind which complains about this case.
Signed-off-by: Andi Kleen <ak@...ux.intel.com>
---
tools/perf/lib/evsel.c | 3 ++-
tools/perf/util/evsel.c | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/tools/perf/lib/evsel.c b/tools/perf/lib/evsel.c
index 24abc80dd767..106522305ed0 100644
--- a/tools/perf/lib/evsel.c
+++ b/tools/perf/lib/evsel.c
@@ -120,7 +120,8 @@ void perf_evsel__close_fd(struct perf_evsel *evsel)
for (cpu = 0; cpu < xyarray__max_x(evsel->fd); cpu++)
for (thread = 0; thread < xyarray__max_y(evsel->fd); ++thread) {
- close(FD(evsel, cpu, thread));
+ if (FD(evsel, cpu, thread) >= 0)
+ close(FD(evsel, cpu, thread));
FD(evsel, cpu, thread) = -1;
}
}
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index a646975a20f3..bc57ac5d51a0 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1981,7 +1981,8 @@ int evsel__open(struct evsel *evsel, struct perf_cpu_map *cpus,
old_errno = errno;
do {
while (--thread >= 0) {
- close(FD(evsel, cpu, thread));
+ if (FD(evsel, cpu, thread) >= 0)
+ close(FD(evsel, cpu, thread));
FD(evsel, cpu, thread) = -1;
}
thread = nthreads;
--
2.21.0
Powered by blists - more mailing lists