perf dso: Separate generic code in dso_cache__read
Move the file specific code in the dso_cache__read function to a separate file_read function. I'll add BPF specific code in the following patches. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Acked-by: Song Liu <songliubraving@fb.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stanislav Fomichev <sdf@google.com> Link: http://lkml.kernel.org/r/20190508132010.14512-3-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
5523769ee1
commit
ea5db1bd5a
|
@ -794,21 +794,11 @@ dso_cache__memcpy(struct dso_cache *cache, u64 offset,
|
|||
return cache_size;
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
dso_cache__read(struct dso *dso, struct machine *machine,
|
||||
u64 offset, u8 *data, ssize_t size)
|
||||
static ssize_t file_read(struct dso *dso, struct machine *machine,
|
||||
u64 offset, char *data)
|
||||
{
|
||||
struct dso_cache *cache;
|
||||
struct dso_cache *old;
|
||||
ssize_t ret;
|
||||
|
||||
do {
|
||||
u64 cache_offset;
|
||||
|
||||
cache = zalloc(sizeof(*cache) + DSO__DATA_CACHE_SIZE);
|
||||
if (!cache)
|
||||
return -ENOMEM;
|
||||
|
||||
pthread_mutex_lock(&dso__data_open_lock);
|
||||
|
||||
/*
|
||||
|
@ -818,22 +808,38 @@ dso_cache__read(struct dso *dso, struct machine *machine,
|
|||
try_to_open_dso(dso, machine);
|
||||
|
||||
if (dso->data.fd < 0) {
|
||||
ret = -errno;
|
||||
dso->data.status = DSO_DATA_STATUS_ERROR;
|
||||
break;
|
||||
ret = -errno;
|
||||
goto out;
|
||||
}
|
||||
|
||||
cache_offset = offset & DSO__DATA_CACHE_MASK;
|
||||
ret = pread(dso->data.fd, data, DSO__DATA_CACHE_SIZE, offset);
|
||||
out:
|
||||
pthread_mutex_unlock(&dso__data_open_lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = pread(dso->data.fd, cache->data, DSO__DATA_CACHE_SIZE, cache_offset);
|
||||
if (ret <= 0)
|
||||
break;
|
||||
static ssize_t
|
||||
dso_cache__read(struct dso *dso, struct machine *machine,
|
||||
u64 offset, u8 *data, ssize_t size)
|
||||
{
|
||||
struct dso_cache *cache;
|
||||
struct dso_cache *old;
|
||||
ssize_t ret;
|
||||
|
||||
do {
|
||||
u64 cache_offset = offset & DSO__DATA_CACHE_MASK;
|
||||
|
||||
cache = zalloc(sizeof(*cache) + DSO__DATA_CACHE_SIZE);
|
||||
if (!cache)
|
||||
return -ENOMEM;
|
||||
|
||||
ret = file_read(dso, machine, cache_offset, cache->data);
|
||||
|
||||
cache->offset = cache_offset;
|
||||
cache->size = ret;
|
||||
} while (0);
|
||||
|
||||
pthread_mutex_unlock(&dso__data_open_lock);
|
||||
|
||||
if (ret > 0) {
|
||||
old = dso_cache__insert(dso, cache);
|
||||
|
|
Loading…
Reference in New Issue