From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Jiri Olsa <jolsa@redhat.com>
Cc: linux-kernel@vger.kernel.org,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Corey Ashford <cjashfor@linux.vnet.ibm.com>,
David Ahern <dsahern@gmail.com>,
Frederic Weisbecker <fweisbec@gmail.com>,
Ingo Molnar <mingo@kernel.org>,
Jean Pihet <jean.pihet@linaro.org>, Jiri Olsa <jolsa@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Paul Mackerras <paulus@samba.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: [PATCH 07/10] perf tests: Add pollfd growing test
Date: Fri, 22 Aug 2014 17:59:47 -0300 [thread overview]
Message-ID: <1408741190-5123-8-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1408741190-5123-1-git-send-email-acme@kernel.org>
From: Arnaldo Carvalho de Melo <acme@redhat.com>
[acme@ssdandy linux]$ perf test "Add fd"
34: Add fd to pollfd array, making it autogrow : Ok
[acme@ssdandy linux]$ perf test -v "Add fd"
34: Add fd to pollfd array, making it autogrow :
--- start ---
test child forked, pid 19817
before growing array: 2 [ 1, 2 ]
after 3rd add_pollfd: 3 [ 1, 2, 35 ]
after 4th add_pollfd: 4 [ 1, 2, 35, 88 ]
test child finished with 0
---- end ----
Add fd to pollfd array, making it autogrow: Ok
[acme@ssdandy linux]$
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jean Pihet <jean.pihet@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/n/tip-smflpyta146bzog7z0effjss@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/tests/builtin-test.c | 4 ++
tools/perf/tests/evlist.c | 111 ++++++++++++++++++++++++++++++++++++++++
tools/perf/tests/tests.h | 1 +
3 files changed, 116 insertions(+)
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 41e556edbe02..174c3ffc5713 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -162,6 +162,10 @@ static struct test {
.func = test__perf_evlist__filter_pollfd,
},
{
+ .desc = "Add fd to pollfd array, making it autogrow",
+ .func = test__perf_evlist__add_pollfd,
+ },
+ {
.func = NULL,
},
};
diff --git a/tools/perf/tests/evlist.c b/tools/perf/tests/evlist.c
index 77579158f4d9..99d7dfd4e20a 100644
--- a/tools/perf/tests/evlist.c
+++ b/tools/perf/tests/evlist.c
@@ -1,5 +1,7 @@
#include "util/evlist.h"
#include "util/debug.h"
+#include "util/thread_map.h"
+#include "util/cpumap.h"
#include "tests/tests.h"
static void perf_evlist__init_pollfd(struct perf_evlist *evlist,
@@ -101,3 +103,112 @@ int test__perf_evlist__filter_pollfd(void)
return 0;
}
+
+int test__perf_evlist__add_pollfd(void)
+{
+ struct perf_evsel evsel = {
+ .system_wide = false,
+ };
+ struct thread_map threads = {
+ .nr = 2,
+ };
+ struct perf_evlist evlist_alloc = {
+ .pollfd = NULL,
+ .threads = &threads,
+ }, *evlist = &evlist_alloc;
+
+ INIT_LIST_HEAD(&evlist->entries);
+ list_add(&evsel.node, &evlist->entries);
+
+ if (perf_evlist__alloc_pollfd(evlist) < 0) {
+ pr_debug("\nperf_evlist__alloc_pollfd(evlist) failed!");
+ return TEST_FAIL;
+ }
+
+ if (evlist->nr_fds_alloc != threads.nr) {
+ pr_debug("\n_evlist__alloc_pollfd: nr_fds_alloc=%d != (threads->nr(%d) * cpu_map->nr(%d))=%d",
+ evlist->nr_fds_alloc, thread_map__nr(evlist->threads), cpu_map__nr(evlist->cpus),
+ thread_map__nr(evlist->threads) * cpu_map__nr(evlist->cpus));
+ return TEST_FAIL;
+ }
+
+ if (perf_evlist__add_pollfd(evlist, 1) < 0) {
+ pr_debug("\nperf_evlist__add_pollfd(evlist, 1) failed!");
+ return TEST_FAIL;
+ }
+
+ if (evlist->nr_fds != 1) {
+ pr_debug("\nperf_evlist__add_pollfd(evlist, 1)=%d != 1", evlist->nr_fds);
+ return TEST_FAIL;
+ }
+
+ if (perf_evlist__add_pollfd(evlist, 2) < 0) {
+ pr_debug("\nperf_evlist__add_pollfd(evlist, 2) failed!");
+ return TEST_FAIL;
+ }
+
+ if (evlist->nr_fds != 2) {
+ pr_debug("\nperf_evlist__add_pollfd(evlist, 2)=%d != 2", evlist->nr_fds);
+ return TEST_FAIL;
+ }
+
+ perf_evlist__fprintf_pollfd(evlist, "before growing array", stderr);
+
+ if (perf_evlist__add_pollfd(evlist, 35) < 0) {
+ pr_debug("\nperf_evlist__add_pollfd(evlist, 35) failed!");
+ return TEST_FAIL;
+ }
+
+ if (evlist->nr_fds != 3) {
+ pr_debug("\nperf_evlist__add_pollfd(evlist, 35)=%d != 3", evlist->nr_fds);
+ return TEST_FAIL;
+ }
+
+ if (evlist->pollfd == NULL) {
+ pr_debug("\nperf_evlist__add_pollfd(evlist, 35) should have allocated evlist->pollfd!");
+ return TEST_FAIL;
+ }
+
+ perf_evlist__fprintf_pollfd(evlist, "after 3rd add_pollfd", stderr);
+
+ if (evlist->pollfd[2].fd != 35) {
+ pr_debug("\nevlist->pollfd[2](%d) != 35!", evlist->pollfd[2].fd);
+ return TEST_FAIL;
+ }
+
+ if (perf_evlist__add_pollfd(evlist, 88) < 0) {
+ pr_debug("\nperf_evlist__add_pollfd(evlist, 88) failed!");
+ return TEST_FAIL;
+ }
+
+ if (evlist->nr_fds != 4) {
+ pr_debug("\nperf_evlist__add_pollfd(evlist, 88)=%d != 2", evlist->nr_fds);
+ return TEST_FAIL;
+ }
+
+ perf_evlist__fprintf_pollfd(evlist, "after 4th add_pollfd", stderr);
+
+ if (evlist->pollfd[0].fd != 1) {
+ pr_debug("\nevlist->pollfd[0](%d) != 1!", evlist->pollfd[0].fd);
+ return TEST_FAIL;
+ }
+
+ if (evlist->pollfd[1].fd != 2) {
+ pr_debug("\nevlist->pollfd[1](%d) != 2!", evlist->pollfd[1].fd);
+ return TEST_FAIL;
+ }
+
+ if (evlist->pollfd[2].fd != 35) {
+ pr_debug("\nevlist->pollfd[2](%d) != 35!", evlist->pollfd[2].fd);
+ return TEST_FAIL;
+ }
+
+ if (evlist->pollfd[3].fd != 88) {
+ pr_debug("\nevlist->pollfd[3](%d) != 88!", evlist->pollfd[3].fd);
+ return TEST_FAIL;
+ }
+
+ pr_debug("\n");
+
+ return 0;
+}
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index 72c4c039bd80..699d4bb61dc7 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -50,6 +50,7 @@ int test__hists_output(void);
int test__hists_cumulate(void);
int test__switch_tracking(void);
int test__perf_evlist__filter_pollfd(void);
+int test__perf_evlist__add_pollfd(void);
#if defined(__x86_64__) || defined(__i386__) || defined(__arm__)
#ifdef HAVE_DWARF_UNWIND_SUPPORT
--
1.9.3
next prev parent reply other threads:[~2014-08-22 21:00 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-22 20:59 [RFC 00/10] perf pollfd series Arnaldo Carvalho de Melo
2014-08-22 20:59 ` [PATCH 01/10] perf evlist: Introduce perf_evlist__filter_pollfd method Arnaldo Carvalho de Melo
2014-08-25 6:57 ` Adrian Hunter
2014-08-22 20:59 ` [PATCH 02/10] perf tests: Add test for perf_evlist__filter_pollfd() Arnaldo Carvalho de Melo
2014-08-22 20:59 ` [PATCH 03/10] perf evlist: Monitor POLLERR and POLLHUP events too Arnaldo Carvalho de Melo
2014-08-22 20:59 ` [PATCH 04/10] perf record: Filter out POLLHUP'ed file descriptors Arnaldo Carvalho de Melo
2014-08-22 20:59 ` [PATCH 05/10] perf trace: " Arnaldo Carvalho de Melo
2014-08-22 20:59 ` [PATCH 06/10] perf evlist: Allow growing pollfd on add method Arnaldo Carvalho de Melo
2014-08-25 9:41 ` Jiri Olsa
2014-08-25 9:47 ` Jiri Olsa
2014-08-25 15:59 ` Arnaldo Carvalho de Melo
2014-08-22 20:59 ` Arnaldo Carvalho de Melo [this message]
2014-08-22 20:59 ` [PATCH 08/10] perf kvm stat live: Use perf_evlist__add_pollfd() instead of local equivalent Arnaldo Carvalho de Melo
2014-08-26 14:04 ` David Ahern
2014-08-22 20:59 ` [PATCH 09/10] perf evlist: Introduce poll method for common code idiom Arnaldo Carvalho de Melo
2014-08-22 20:59 ` [PATCH 10/10] tools lib api: Adopt fdarray class from perf's evlist Arnaldo Carvalho de Melo
2014-08-26 7:46 ` Namhyung Kim
2014-08-26 13:08 ` Arnaldo Carvalho de Melo
2014-08-25 11:04 ` [RFC 00/10] perf pollfd series Jiri Olsa
2014-08-25 15:56 ` Arnaldo Carvalho de Melo
2014-09-03 21:59 [RFC 00/10] perf pollfd series v2 Arnaldo Carvalho de Melo
2014-09-03 22:00 ` [PATCH 07/10] perf tests: Add pollfd growing test Arnaldo Carvalho de Melo
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=1408741190-5123-8-git-send-email-acme@kernel.org \
--to=acme@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=cjashfor@linux.vnet.ibm.com \
--cc=dsahern@gmail.com \
--cc=fweisbec@gmail.com \
--cc=jean.pihet@linaro.org \
--cc=jolsa@kernel.org \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=paulus@samba.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;
as well as URLs for NNTP newsgroup(s).