diff options
author | Namhyung Kim <namhyung@kernel.org> | 2015-01-30 03:33:28 +0100 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-02-06 11:46:35 +0100 |
commit | 63d3c6f3835d011c783c606c8a1583b041f579aa (patch) | |
tree | 265db940d9911b060c88e743ef1b86c6a103f77e /tools/perf/tests/dso-data.c | |
parent | perf test: Fix dso cache testcase (diff) | |
download | linux-63d3c6f3835d011c783c606c8a1583b041f579aa.tar.xz linux-63d3c6f3835d011c783c606c8a1583b041f579aa.zip |
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: Namhyung Kim <namhyung@kernel.org>
Acked-by: Jiri 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.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/tests/dso-data.c')
-rw-r--r-- | tools/perf/tests/dso-data.c | 13 |
1 files 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; |