Commit 63d3c6f3 authored by Namhyung Kim's avatar Namhyung Kim Committed by Arnaldo Carvalho de Melo

perf tests: Do not rely on dso__data_read_offset() to open dso

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: default avatarNamhyung Kim <namhyung@kernel.org>
Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1422585209-32742-2-git-send-email-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 66af43d5
...@@ -112,6 +112,9 @@ int test__dso_data(void) ...@@ -112,6 +112,9 @@ int test__dso_data(void)
dso = dso__new((const char *)file); dso = dso__new((const char *)file);
TEST_ASSERT_VAL("Failed to access to dso",
dso__data_fd(dso, &machine) >= 0);
/* Basic 10 bytes tests. */ /* Basic 10 bytes tests. */
for (i = 0; i < ARRAY_SIZE(offsets); i++) { for (i = 0; i < ARRAY_SIZE(offsets); i++) {
struct test_data_offset *data = &offsets[i]; struct test_data_offset *data = &offsets[i];
...@@ -252,13 +255,13 @@ int test__dso_data_cache(void) ...@@ -252,13 +255,13 @@ int test__dso_data_cache(void)
struct dso *dso = dsos[i]; struct dso *dso = dsos[i];
/* /*
* Open dsos via dso__data_fd or dso__data_read_offset. * Open dsos via dso__data_fd(), it opens the data
* Both opens the data file and keep it open. * file and keep it open (unless open file limit).
*/ */
if (i % 2) {
fd = dso__data_fd(dso, &machine); fd = dso__data_fd(dso, &machine);
TEST_ASSERT_VAL("failed to get fd", fd > 0); TEST_ASSERT_VAL("failed to get fd", fd > 0);
} else {
if (i % 2) {
#define BUFSIZE 10 #define BUFSIZE 10
u8 buf[BUFSIZE]; u8 buf[BUFSIZE];
ssize_t n; ssize_t n;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment