mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
	linux-kernel@vger.kernel.org, Jiri Olsa <jolsa@redhat.com>
Subject: Re: [PATCH 5/5] perf tools: Fix data_read_offset() file opening
Date: Tue, 19 May 2015 23:48:18 +0900	[thread overview]
Message-ID: <20150519144818.GA29162@danjae.kornet> (raw)
In-Reply-To: <1432040746-1755-6-git-send-email-adrian.hunter@intel.com>

Hi Adrian,

On Tue, May 19, 2015 at 04:05:46PM +0300, Adrian Hunter wrote:
> Patch "perf tools: Protect dso cache fd with a mutex"
> changed data_file_size() to open the data file if it
> was not open.
> 
> data_read_offset() was calling data_file_size() to read
> the data file size, but data_file_size() can fail to
> open the file because the binary_type has not been set up.
> 
> The correct function to call is dso__data_size() which
> uses dso__data_fd() to open the file correctly.

Right, but I worried about the locking overhead.  By using
dso__data_size() it'll call dso__data_fd() everytime which grabs the
dso__data_open_lock that is a global mutex.  It can be a performance
bottleneck on multi-thread report IMHO.

I assumed that correct code should check the data fd or size before
calling read function as I read the comment in dso.h file.

What about adding the missing check in a proper place instead?

Thanks,
Namhyung


> 
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> ---
>  tools/perf/util/dso.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
> index 1b96c8d..e248f56 100644
> --- a/tools/perf/util/dso.c
> +++ b/tools/perf/util/dso.c
> @@ -756,7 +756,7 @@ off_t dso__data_size(struct dso *dso, struct machine *machine)
>  static ssize_t data_read_offset(struct dso *dso, struct machine *machine,
>  				u64 offset, u8 *data, ssize_t size)
>  {
> -	if (data_file_size(dso, machine))
> +	if (dso__data_size(dso, machine) < 0)
>  		return -1;
>  
>  	/* Check the offset sanity. */
> -- 
> 1.9.1
> 

  reply	other threads:[~2015-05-19 14:49 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-19 13:05 [PATCH 0/5] perf tools: Some fixes Adrian Hunter
2015-05-19 13:05 ` [PATCH 1/5] perf tools: Fix function declarations needed by parse-events.y Adrian Hunter
2015-05-27 16:45   ` [tip:perf/core] " tip-bot for Adrian Hunter
2015-05-19 13:05 ` [PATCH 2/5] perf build: Fix libunwind feature detection on 32-bit x86 Adrian Hunter
2015-05-27 16:46   ` [tip:perf/core] " tip-bot for Adrian Hunter
2015-05-19 13:05 ` [PATCH 3/5] perf tools: Fix parse_events_error dereferences Adrian Hunter
2015-05-27 16:46   ` [tip:perf/core] " tip-bot for Adrian Hunter
2015-05-19 13:05 ` [PATCH 4/5] perf session: Fix perf_session__peek_event() Adrian Hunter
2015-05-27 16:46   ` [tip:perf/core] " tip-bot for Adrian Hunter
2015-05-19 13:05 ` [PATCH 5/5] perf tools: Fix data_read_offset() file opening Adrian Hunter
2015-05-19 14:48   ` Namhyung Kim [this message]
2015-05-19 19:58     ` Adrian Hunter
2015-05-20  0:44       ` Namhyung Kim
2015-05-20  0:55         ` Arnaldo Carvalho de Melo
2015-05-19 14:00 ` [PATCH 0/5] perf tools: Some fixes Arnaldo Carvalho de Melo

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=20150519144818.GA29162@danjae.kornet \
    --to=namhyung@kernel.org \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    /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

Powered by JetHome