From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Jiri Olsa <jolsa@redhat.com>, LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 2/3] perf tools: Do not rely on dso__data_read_offset() to open dso
Date: Fri, 30 Jan 2015 11:33:28 +0900 [thread overview]
Message-ID: <1422585209-32742-2-git-send-email-namhyung@kernel.org> (raw)
In-Reply-To: <1422585209-32742-1-git-send-email-namhyung@kernel.org>
Do not rely on dso__data_read_offset() will always call dso__data_fd()
internally. With multi-thread support, accessing a fd will be
protected by a lock and it'll cause a huge contention. It can be
avoided since we can skip reading from file if there's a data in the
dso cache.
If one needs to call the dso__data_read_offset(), [s]he also needs to
call dso__data_fd() (or set dso->binary_type at least) first like the
dwarf unwind code does.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/tests/dso-data.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/tools/perf/tests/dso-data.c b/tools/perf/tests/dso-data.c
index 22a8c428283a..513e5febbe5a 100644
--- a/tools/perf/tests/dso-data.c
+++ b/tools/perf/tests/dso-data.c
@@ -112,6 +112,9 @@ int test__dso_data(void)
dso = dso__new((const char *)file);
+ TEST_ASSERT_VAL("Failed to access to dso",
+ dso__data_fd(dso, &machine) >= 0);
+
/* Basic 10 bytes tests. */
for (i = 0; i < ARRAY_SIZE(offsets); i++) {
struct test_data_offset *data = &offsets[i];
@@ -252,13 +255,13 @@ int test__dso_data_cache(void)
struct dso *dso = dsos[i];
/*
- * Open dsos via dso__data_fd or dso__data_read_offset.
- * Both opens the data file and keep it open.
+ * Open dsos via dso__data_fd(), it opens the data
+ * file and keep it open (unless open file limit).
*/
+ fd = dso__data_fd(dso, &machine);
+ TEST_ASSERT_VAL("failed to get fd", fd > 0);
+
if (i % 2) {
- fd = dso__data_fd(dso, &machine);
- TEST_ASSERT_VAL("failed to get fd", fd > 0);
- } else {
#define BUFSIZE 10
u8 buf[BUFSIZE];
ssize_t n;
--
2.2.2
next prev parent reply other threads:[~2015-01-30 2:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-30 2:33 [PATCH 1/3] perf test: Fix dso cache testcase Namhyung Kim
2015-01-30 2:33 ` Namhyung Kim [this message]
2015-01-30 13:56 ` [PATCH 2/3] perf tools: Do not rely on dso__data_read_offset() to open dso Jiri Olsa
2015-02-18 18:24 ` [tip:perf/core] perf tests: Do not rely on dso__data_read_offset( ) " tip-bot for Namhyung Kim
2015-01-30 2:33 ` [PATCH 3/3] perf tools: Fix a dso open fail message Namhyung Kim
2015-02-18 18:25 ` [tip:perf/core] " tip-bot for Namhyung Kim
2015-01-30 13:49 ` [PATCH 1/3] perf test: Fix dso cache testcase Jiri Olsa
2015-02-18 18:24 ` [tip:perf/core] " tip-bot for Namhyung Kim
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=1422585209-32742-2-git-send-email-namhyung@kernel.org \
--to=namhyung@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@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
all inboxes | Powered by JetHome®