From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>, Thomas Gleixner <tglx@linutronix.de>
Cc: Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
Clark Williams <williams@redhat.com>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
Song Liu <songliubraving@fb.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Andi Kleen <ak@linux.intel.com>,
Peter Zijlstra <peterz@infradead.org>,
Stanislav Fomichev <sdf@google.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 23/41] perf dso: Separate generic code in dso_cache__read
Date: Wed, 29 May 2019 10:35:47 -0300 [thread overview]
Message-ID: <20190529133605.21118-24-acme@kernel.org> (raw)
In-Reply-To: <20190529133605.21118-1-acme@kernel.org>
From: Jiri Olsa <jolsa@kernel.org>
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>
---
tools/perf/util/dso.c | 48 ++++++++++++++++++++++++-------------------
1 file changed, 27 insertions(+), 21 deletions(-)
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index cb6199c1390a..7734f50a6912 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -794,6 +794,31 @@ dso_cache__memcpy(struct dso_cache *cache, u64 offset,
return cache_size;
}
+static ssize_t file_read(struct dso *dso, struct machine *machine,
+ u64 offset, char *data)
+{
+ ssize_t ret;
+
+ pthread_mutex_lock(&dso__data_open_lock);
+
+ /*
+ * dso->data.fd might be closed if other thread opened another
+ * file (dso) due to open file limit (RLIMIT_NOFILE).
+ */
+ try_to_open_dso(dso, machine);
+
+ if (dso->data.fd < 0) {
+ dso->data.status = DSO_DATA_STATUS_ERROR;
+ ret = -errno;
+ goto out;
+ }
+
+ ret = pread(dso->data.fd, data, DSO__DATA_CACHE_SIZE, offset);
+out:
+ pthread_mutex_unlock(&dso__data_open_lock);
+ return ret;
+}
+
static ssize_t
dso_cache__read(struct dso *dso, struct machine *machine,
u64 offset, u8 *data, ssize_t size)
@@ -803,37 +828,18 @@ dso_cache__read(struct dso *dso, struct machine *machine,
ssize_t ret;
do {
- u64 cache_offset;
+ u64 cache_offset = offset & DSO__DATA_CACHE_MASK;
cache = zalloc(sizeof(*cache) + DSO__DATA_CACHE_SIZE);
if (!cache)
return -ENOMEM;
- pthread_mutex_lock(&dso__data_open_lock);
-
- /*
- * dso->data.fd might be closed if other thread opened another
- * file (dso) due to open file limit (RLIMIT_NOFILE).
- */
- try_to_open_dso(dso, machine);
-
- if (dso->data.fd < 0) {
- ret = -errno;
- dso->data.status = DSO_DATA_STATUS_ERROR;
- break;
- }
-
- cache_offset = offset & DSO__DATA_CACHE_MASK;
-
- ret = pread(dso->data.fd, cache->data, DSO__DATA_CACHE_SIZE, cache_offset);
- if (ret <= 0)
- break;
+ 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);
--
2.20.1
next prev parent reply other threads:[~2019-05-29 13:35 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-29 13:35 [GIT PULL] perf/core improvements and fixes for 5.3 Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 01/41] perf-with-kcore.sh: Always allow fix_buildid_cache_permissions Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 02/41] perf intel-pt: Fix itrace defaults for perf script Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 03/41] perf auxtrace: " Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 04/41] perf intel-pt: Fix itrace defaults for perf script intel-pt documentation Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 05/41] perf machine: Keep zero in pgoff BPF map Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 06/41] perf tools: Preserve eBPF maps when loading kcore Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 07/41] perf augmented_raw_syscalls: Fix up comment Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 08/41] perf beauty: Add generator for 'move_mount' flags argument Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 09/41] perf trace: Beautify 'move_mount' arguments Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 10/41] perf beauty: Add generator for fspick's 'flags' arg values Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 11/41] perf trace: Beautify 'fspick' arguments Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 12/41] perf beauty: Add generator for fsconfig's 'cmd' arg values Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 13/41] perf trace: Beautify 'fsconfig' arguments Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 14/41] perf beauty: Add generator for fsmount's 'attr_flags' arg values Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 15/41] perf trace: Introduce syscall_arg__scnprintf_strarray_flags Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 16/41] perf trace: Beautify 'fsmount' arguments Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 17/41] perf trace beauty clone: Handle CLONE_PIDFD Arnaldo Carvalho de Melo
2019-05-29 14:49 ` Christian Brauner
2019-05-29 13:35 ` [PATCH 18/41] perf beauty: Add generator for sync_file_range's 'flags' arg values Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 19/41] perf trace: Beautify 'sync_file_range' arguments Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 20/41] perf top: Add --namespaces option Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 21/41] perf tools: Remove const from thread read accessors Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 22/41] perf dso: Separate generic code in dso__data_file_size() Arnaldo Carvalho de Melo
2019-05-29 13:35 ` Arnaldo Carvalho de Melo [this message]
2019-05-29 13:35 ` [PATCH 24/41] perf dso: Simplify dso_cache__read function Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 25/41] perf dso: Add BPF DSO read and size hooks Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 26/41] perf script: Pad DSO name for --call-trace Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 27/41] perf tests: Add map_groups__merge_in test Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 28/41] perf script: Add --show-bpf-events to show eBPF related events Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 29/41] perf script: Remove superfluous BPF event titles Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 30/41] perf version: Append 12 git SHA chars to the version string Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 31/41] perf machine: Return NULL instead of null-terminating /proc/version array Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 32/41] perf annotate TUI browser: Do not use member from variable within its own initialization Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 33/41] perf python: Remove -fstack-protector-strong if clang doesn't have it Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 34/41] perf top: Lower message level for failure on synthesizing events for pre-existing BPF programs Arnaldo Carvalho de Melo
2019-05-29 13:35 ` [PATCH 35/41] perf scripts python: exported-sql-viewer.py: Change python2 to python Arnaldo Carvalho de Melo
2019-05-29 13:36 ` [PATCH 36/41] perf scripts python: exported-sql-viewer.py: Use argparse module for argument parsing Arnaldo Carvalho de Melo
2019-05-29 13:36 ` [PATCH 37/41] perf scripts python: exported-sql-viewer.py: Add support for pyside2 Arnaldo Carvalho de Melo
2019-05-29 13:36 ` [PATCH 38/41] perf scripts python: export-to-sqlite.py: " Arnaldo Carvalho de Melo
2019-05-29 13:36 ` [PATCH 39/41] perf scripts python: export-to-postgresql.py: " Arnaldo Carvalho de Melo
2019-05-29 13:36 ` [PATCH 40/41] perf intel-pt: Improve sync_switch by processing PERF_RECORD_SWITCH* in events Arnaldo Carvalho de Melo
2019-05-29 13:36 ` [PATCH 41/41] perf intel-pt: Rationalize intel_pt_sync_switch()'s use of next_tid Arnaldo Carvalho de Melo
2019-05-30 7:50 ` [GIT PULL] perf/core improvements and fixes for 5.3 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=20190529133605.21118-24-acme@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=sdf@google.com \
--cc=songliubraving@fb.com \
--cc=tglx@linutronix.de \
--cc=williams@redhat.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).