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>,
Frederic Weisbecker <fweisbec@gmail.com>,
Stephane Eranian <eranian@google.com>,
David Ahern <dsahern@gmail.com>, Andi Kleen <andi@firstfloor.org>
Subject: [RFC/PATCH 20/38] perf tools: Add a test case for timed map groups handling
Date: Fri, 2 Oct 2015 14:19:01 +0900 [thread overview]
Message-ID: <1443763159-29098-21-git-send-email-namhyung@kernel.org> (raw)
In-Reply-To: <1443763159-29098-1-git-send-email-namhyung@kernel.org>
A test case for verifying thread->mg and ->mg_list handling during
time change and new thread__find_addr_map_by_time() and friends.
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/tests/Build | 1 +
tools/perf/tests/builtin-test.c | 4 ++
tools/perf/tests/tests.h | 1 +
tools/perf/tests/thread-mg-time.c | 93 +++++++++++++++++++++++++++++++++++++++
4 files changed, 99 insertions(+)
create mode 100644 tools/perf/tests/thread-mg-time.c
diff --git a/tools/perf/tests/Build b/tools/perf/tests/Build
index fd4cabb9a1a0..d287b99ff3bb 100644
--- a/tools/perf/tests/Build
+++ b/tools/perf/tests/Build
@@ -27,6 +27,7 @@ perf-y += mmap-thread-lookup.o
perf-y += thread-comm.o
perf-y += thread-mg-share.o
perf-y += thread-lookup-time.o
+perf-y += thread-mg-time.o
perf-y += switch-tracking.o
perf-y += keep-tracking.o
perf-y += code-reading.o
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 027796fa105e..62de08a89e0e 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -199,6 +199,10 @@ static struct test {
.func = test__thread_lookup_time,
},
{
+ .desc = "Test thread map group handling with time",
+ .func = test__thread_mg_time,
+ },
+ {
.func = NULL,
},
};
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index 9c02755e86dd..03dcaccb570f 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -67,6 +67,7 @@ int test__insn_x86(void);
int test_session_topology(void);
int test__thread_comm(void);
int test__thread_lookup_time(void);
+int test__thread_mg_time(void);
#if defined(__x86_64__) || defined(__i386__) || defined(__arm__) || defined(__aarch64__)
#ifdef HAVE_DWARF_UNWIND_SUPPORT
diff --git a/tools/perf/tests/thread-mg-time.c b/tools/perf/tests/thread-mg-time.c
new file mode 100644
index 000000000000..841777125a64
--- /dev/null
+++ b/tools/perf/tests/thread-mg-time.c
@@ -0,0 +1,93 @@
+#include "tests.h"
+#include "machine.h"
+#include "thread.h"
+#include "map.h"
+#include "debug.h"
+
+#define PERF_MAP_START 0x40000
+
+int test__thread_mg_time(void)
+{
+ struct machines machines;
+ struct machine *machine;
+ struct thread *t;
+ struct map_groups *mg;
+ struct map *map, *old_map;
+ struct addr_location al = { .map = NULL, };
+
+ /*
+ * This test is to check whether it can retrieve a correct map
+ * for a given time. When multi-file data storage is enabled,
+ * those task/comm/mmap events are processed first so the
+ * later sample should find a matching comm properly.
+ */
+ machines__init(&machines);
+ machine = &machines.host;
+
+ /* this is needed to add/find map by time */
+ perf_has_index = true;
+
+ t = machine__findnew_thread(machine, 0, 0);
+ mg = t->mg;
+
+ map = dso__new_map("/usr/bin/perf");
+ map->start = PERF_MAP_START;
+ map->end = PERF_MAP_START + 0x1000;
+
+ thread__insert_map(t, map);
+
+ if (verbose > 1)
+ map_groups__fprintf(t->mg, stderr);
+
+ thread__find_addr_map(t, PERF_RECORD_MISC_USER, MAP__FUNCTION,
+ PERF_MAP_START, &al);
+
+ TEST_ASSERT_VAL("cannot find mapping for perf", al.map != NULL);
+ TEST_ASSERT_VAL("non matched mapping found", al.map == map);
+ TEST_ASSERT_VAL("incorrect map groups", al.map->groups == mg);
+ TEST_ASSERT_VAL("incorrect map groups", al.map->groups == t->mg);
+
+ thread__find_addr_map_by_time(t, PERF_RECORD_MISC_USER, MAP__FUNCTION,
+ PERF_MAP_START, &al, -1ULL);
+
+ TEST_ASSERT_VAL("cannot find timed mapping for perf", al.map != NULL);
+ TEST_ASSERT_VAL("non matched timed mapping", al.map == map);
+ TEST_ASSERT_VAL("incorrect timed map groups", al.map->groups == mg);
+ TEST_ASSERT_VAL("incorrect map groups", al.map->groups == t->mg);
+
+
+ pr_debug("simulate EXEC event (generate new mg)\n");
+ __thread__set_comm(t, "perf-test", 10000, true);
+
+ old_map = map;
+
+ map = dso__new_map("/usr/bin/perf-test");
+ map->start = PERF_MAP_START;
+ map->end = PERF_MAP_START + 0x2000;
+
+ thread__insert_map(t, map);
+
+ if (verbose > 1)
+ map_groups__fprintf(t->mg, stderr);
+
+ thread__find_addr_map(t, PERF_RECORD_MISC_USER, MAP__FUNCTION,
+ PERF_MAP_START + 4, &al);
+
+ TEST_ASSERT_VAL("cannot find mapping for perf-test", al.map != NULL);
+ TEST_ASSERT_VAL("invalid mapping found", al.map == map);
+ TEST_ASSERT_VAL("incorrect map groups", al.map->groups != mg);
+ TEST_ASSERT_VAL("incorrect map groups", al.map->groups == t->mg);
+
+ pr_debug("searching map in the old mag groups\n");
+ thread__find_addr_map_by_time(t, PERF_RECORD_MISC_USER, MAP__FUNCTION,
+ PERF_MAP_START, &al, 5000);
+
+ TEST_ASSERT_VAL("cannot find timed mapping for perf-test", al.map != NULL);
+ TEST_ASSERT_VAL("non matched timed mapping", al.map == old_map);
+ TEST_ASSERT_VAL("incorrect timed map groups", al.map->groups == mg);
+ TEST_ASSERT_VAL("incorrect map groups", al.map->groups != t->mg);
+
+ machine__delete_threads(machine);
+ machines__exit(&machines);
+ return 0;
+}
--
2.6.0
next prev parent reply other threads:[~2015-10-02 5:24 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-02 5:18 [RFC/PATCH 00/38] perf tools: Speed-up perf report by using multi thread (v5) Namhyung Kim
2015-10-02 5:18 ` [RFC/PATCH 01/38] perf tools: Use a software dummy event to track task/mmap events Namhyung Kim
2015-10-05 12:51 ` Jiri Olsa
2015-10-06 8:31 ` Namhyung Kim
2015-10-02 5:18 ` [RFC/PATCH 02/38] perf tools: Save mmap_param.len instead of mask Namhyung Kim
2015-10-02 18:44 ` Arnaldo Carvalho de Melo
2015-10-06 8:34 ` Namhyung Kim
2015-10-08 10:17 ` Jiri Olsa
2015-10-09 6:03 ` Namhyung Kim
2015-10-12 12:42 ` Jiri Olsa
2015-10-02 5:18 ` [RFC/PATCH 03/38] perf tools: Move auxtrace_mmap field to struct perf_evlist Namhyung Kim
2015-10-02 18:45 ` Arnaldo Carvalho de Melo
2015-10-05 11:29 ` Adrian Hunter
2015-10-06 9:03 ` Namhyung Kim
2015-10-06 9:26 ` Adrian Hunter
2015-10-07 9:06 ` Namhyung Kim
2015-10-08 16:07 ` Adrian Hunter
2015-10-09 7:54 ` Namhyung Kim
2015-10-06 8:56 ` Namhyung Kim
2015-10-05 13:14 ` Jiri Olsa
2015-10-06 8:40 ` Namhyung Kim
2015-10-08 10:18 ` Jiri Olsa
2015-10-02 5:18 ` [RFC/PATCH 04/38] perf tools: pass perf_mmap desc directly Namhyung Kim
2015-10-02 18:47 ` Arnaldo Carvalho de Melo
2015-10-02 5:18 ` [RFC/PATCH 05/38] perf tools: Create separate mmap for dummy tracking event Namhyung Kim
2015-10-02 5:18 ` [RFC/PATCH 06/38] perf tools: Extend perf_evlist__mmap_ex() to use track mmap Namhyung Kim
2015-10-02 5:18 ` [RFC/PATCH 07/38] perf tools: Add HEADER_DATA_INDEX feature Namhyung Kim
2015-10-02 5:18 ` [RFC/PATCH 08/38] perf tools: Handle indexed data file properly Namhyung Kim
2015-10-02 5:18 ` [RFC/PATCH 09/38] perf record: Add --index option for building index table Namhyung Kim
2015-10-02 18:58 ` Arnaldo Carvalho de Melo
2015-10-05 13:46 ` Jiri Olsa
2015-10-07 8:21 ` Namhyung Kim
2015-10-07 12:10 ` Jiri Olsa
2015-10-02 5:18 ` [RFC/PATCH 10/38] perf report: Skip dummy tracking event Namhyung Kim
2015-10-02 5:18 ` [RFC/PATCH 11/38] perf tools: Introduce thread__comm(_str)_by_time() helpers Namhyung Kim
2015-10-02 5:18 ` [RFC/PATCH 12/38] perf tools: Add a test case for thread comm handling Namhyung Kim
2015-10-02 5:18 ` [RFC/PATCH 13/38] perf tools: Use thread__comm_by_time() when adding hist entries Namhyung Kim
2015-10-02 5:18 ` [RFC/PATCH 14/38] perf tools: Convert dead thread list into rbtree Namhyung Kim
2015-10-02 5:18 ` [RFC/PATCH 15/38] perf tools: Introduce machine__find*_thread_by_time() Namhyung Kim
2015-10-08 12:20 ` Jiri Olsa
2015-10-09 6:04 ` Namhyung Kim
2015-10-02 5:18 ` [RFC/PATCH 16/38] perf tools: Add a test case for timed thread handling Namhyung Kim
2015-10-02 5:18 ` [RFC/PATCH 17/38] perf tools: Maintain map groups list in a leader thread Namhyung Kim
2015-10-08 12:51 ` Jiri Olsa
2015-10-09 6:24 ` Namhyung Kim
2015-10-08 12:58 ` Jiri Olsa
2015-10-09 6:58 ` Namhyung Kim
2015-10-12 12:43 ` Jiri Olsa
2015-10-02 5:18 ` [RFC/PATCH 18/38] perf tools: Introduce thread__find_addr_location_by_time() and friends Namhyung Kim
2015-10-12 13:35 ` Jiri Olsa
2015-10-02 5:19 ` [RFC/PATCH 19/38] perf callchain: Use " Namhyung Kim
2015-10-02 5:19 ` Namhyung Kim [this message]
2015-10-02 5:19 ` [RFC/PATCH 21/38] perf tools: Save timestamp of a map creation Namhyung Kim
2015-10-02 5:19 ` [RFC/PATCH 22/38] perf tools: Introduce map_groups__{insert,find}_by_time() Namhyung Kim
2015-10-02 5:19 ` [RFC/PATCH 23/38] perf tools: Use map_groups__find_addr_by_time() Namhyung Kim
2015-10-02 5:19 ` [RFC/PATCH 24/38] perf tools: Add testcase for managing maps with time Namhyung Kim
2015-10-02 5:19 ` [RFC/PATCH 25/38] perf callchain: Maintain libunwind's address space in map_groups Namhyung Kim
2015-10-02 5:19 ` [RFC/PATCH 26/38] perf session: Pass struct events stats to event processing functions Namhyung Kim
2015-10-02 5:19 ` [RFC/PATCH 27/38] perf hists: Pass hists struct to hist_entry_iter struct Namhyung Kim
2015-10-02 5:19 ` [RFC/PATCH 28/38] perf tools: Move BUILD_ID_SIZE definition to perf.h Namhyung Kim
2015-10-02 5:22 ` Namhyung Kim
2015-10-02 6:58 ` Namhyung Kim
2015-10-12 14:32 ` Jiri Olsa
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=1443763159-29098-21-git-send-email-namhyung@kernel.org \
--to=namhyung@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@kernel.org \
--cc=andi@firstfloor.org \
--cc=dsahern@gmail.com \
--cc=eranian@google.com \
--cc=fweisbec@gmail.com \
--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
Powered by JetHome