From: Jiri Olsa <jolsa@redhat.com>
To: Tommi Rantala <tommi.t.rantala@nokia.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Namhyung Kim <namhyung@kernel.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/4] perf cgroup: Avoid needless closing of unopened fd
Date: Mon, 20 Apr 2020 10:48:47 +0200 [thread overview]
Message-ID: <20200420084847.GC718574@krava> (raw)
In-Reply-To: <20200417132330.119407-1-tommi.t.rantala@nokia.com>
On Fri, Apr 17, 2020 at 04:23:26PM +0300, Tommi Rantala wrote:
> Do not bother with close() if fd is not valid, just to silence valgrind:
>
> $ valgrind ./perf script
> ==59169== Memcheck, a memory error detector
> ==59169== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
> ==59169== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info
> ==59169== Command: ./perf script
> ==59169==
> ==59169== Warning: invalid file descriptor -1 in syscall close()
> ==59169== Warning: invalid file descriptor -1 in syscall close()
> ==59169== Warning: invalid file descriptor -1 in syscall close()
> ==59169== Warning: invalid file descriptor -1 in syscall close()
> ==59169== Warning: invalid file descriptor -1 in syscall close()
> ==59169== Warning: invalid file descriptor -1 in syscall close()
> ==59169== Warning: invalid file descriptor -1 in syscall close()
> ==59169== Warning: invalid file descriptor -1 in syscall close()
>
> Signed-off-by: Tommi Rantala <tommi.t.rantala@nokia.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
thanks,
jirka
> ---
> tools/perf/util/cgroup.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/cgroup.c b/tools/perf/util/cgroup.c
> index b73fb7823048..050dea9f1e88 100644
> --- a/tools/perf/util/cgroup.c
> +++ b/tools/perf/util/cgroup.c
> @@ -107,7 +107,8 @@ static int add_cgroup(struct evlist *evlist, const char *str)
>
> static void cgroup__delete(struct cgroup *cgroup)
> {
> - close(cgroup->fd);
> + if (cgroup->fd >= 0)
> + close(cgroup->fd);
> zfree(&cgroup->name);
> free(cgroup);
> }
> --
> 2.25.2
>
next prev parent reply other threads:[~2020-04-20 8:49 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-17 13:23 [PATCH 1/4] perf cgroup: Avoid needless closing of unopened fd Tommi Rantala
2020-04-17 13:23 ` [PATCH 2/4] perf tools: Move zstd_fini() to session deletion Tommi Rantala
2020-04-20 8:54 ` Jiri Olsa
2020-04-23 5:52 ` Rantala, Tommi T. (Nokia - FI/Espoo)
2020-04-17 13:23 ` [PATCH 3/4] perf tools: Fix segfaults due to missing zstd decompressor initialization Tommi Rantala
2020-04-20 9:05 ` Jiri Olsa
2020-04-17 13:23 ` [PATCH 4/4] perf bench: Fix div-by-zero if runtime is zero Tommi Rantala
2020-04-20 9:05 ` Jiri Olsa
2020-04-20 12:05 ` Arnaldo Carvalho de Melo
2020-05-08 13:05 ` [tip: perf/core] " tip-bot2 for Tommi Rantala
2020-04-20 8:48 ` Jiri Olsa [this message]
2020-04-20 12:05 ` [PATCH 1/4] perf cgroup: Avoid needless closing of unopened fd Arnaldo Carvalho de Melo
2020-05-08 13:05 ` [tip: perf/core] " tip-bot2 for Tommi Rantala
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200420084847.GC718574@krava \
--to=jolsa@redhat.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=tommi.t.rantala@nokia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).