lkml.org 
[lkml]   [2014]   [Dec]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 34/37] perf tools: Convert lseek + read to pread
Date
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>
---
tools/perf/util/dso.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index d8ee1fd826e7..95c8d5a2b934 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -593,10 +593,7 @@ dso_cache__read(struct dso *dso, struct machine *machine,
}
}

- if (-1 == lseek(dso->data.fd, cache_offset, SEEK_SET))
- goto err_unlock;
-
- 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)
goto err_unlock;

--
2.1.3


\
 
 \ /
  Last update: 2014-12-24 08:21    [W:0.396 / U:0.172 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site