LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, Namhyung Kim <namhyung@kernel.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Andi Kleen <andi@firstfloor.org>, David Ahern <dsahern@gmail.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Jiri Olsa <jolsa@redhat.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Stephane Eranian <eranian@google.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 10/10] perf symbols: Convert lseek + read to pread
Date: Thu, 29 Jan 2015 17:23:45 -0300	[thread overview]
Message-ID: <1422563025-28402-11-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1422563025-28402-1-git-send-email-acme@kernel.org>

From: Namhyung Kim <namhyung@kernel.org>

When dso_cache__read() is called, it reads data from the given offset
using lseek + normal read syscall.  It can be combined to a single pread
syscall.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1422518843-25818-40-git-send-email-namhyung@kernel.org
[ Fixed it up when cherry picking it from the multi threaded patchkit ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/dso.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 45be944d450a..c2f7d3b90966 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -532,12 +532,8 @@ dso_cache__read(struct dso *dso, u64 offset, u8 *data, ssize_t size)
 			break;
 
 		cache_offset = offset & DSO__DATA_CACHE_MASK;
-		ret = -EINVAL;
 
-		if (-1 == lseek(dso->data.fd, cache_offset, SEEK_SET))
-			break;
-
-		ret = read(dso->data.fd, cache->data, DSO__DATA_CACHE_SIZE);
+		ret = pread(dso->data.fd, cache->data, DSO__DATA_CACHE_SIZE, cache_offset);
 		if (ret <= 0)
 			break;
 
-- 
1.9.3


  parent reply	other threads:[~2015-01-29 20:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-29 20:23 [GIT PULL 00/10] perf/core improvements and fixes Arnaldo Carvalho de Melo
2015-01-29 20:23 ` [PATCH 01/10] perf evsel: Don't rely on malloc working for sz 0 Arnaldo Carvalho de Melo
2015-01-29 20:23 ` [PATCH 02/10] perf tools: Provide stub for missing pthread_attr_setaffinity_np Arnaldo Carvalho de Melo
2015-01-29 20:23 ` [PATCH 03/10] perf callchain: Cache eh/debug frame offset for dwarf unwind Arnaldo Carvalho de Melo
2015-01-29 20:23 ` [PATCH 04/10] perf tools: Do not use __perf_session__process_events() directly Arnaldo Carvalho de Melo
2015-01-29 20:23 ` [PATCH 05/10] perf record: Show precise number of samples Arnaldo Carvalho de Melo
2015-01-29 20:23 ` [PATCH 06/10] perf header: Set header version correctly Arnaldo Carvalho de Melo
2015-01-29 20:23 ` [PATCH 07/10] perf evsel: Set attr.task bit for a tracking event Arnaldo Carvalho de Melo
2015-01-29 20:23 ` [PATCH 08/10] perf symbols: Support to read compressed module from build-id cache Arnaldo Carvalho de Melo
2015-01-29 20:23 ` [PATCH 09/10] perf tools: Use perf_data_file__fd() consistently Arnaldo Carvalho de Melo
2015-01-29 20:23 ` Arnaldo Carvalho de Melo [this message]
2015-01-30 18:28 ` [GIT PULL 00/10] perf/core improvements and fixes Ingo Molnar

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=1422563025-28402-11-git-send-email-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=andi@firstfloor.org \
    --cc=dsahern@gmail.com \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --subject='Re: [PATCH 10/10] perf symbols: Convert lseek + read to pread' \
    /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

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).