linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Borislav Petkov <bp@suse.de>, David Ahern <dsahern@gmail.com>,
	Don Zickus <dzickus@redhat.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
	Stephane Eranian <eranian@google.com>
Subject: [PATCH 12/17] perf tests: Fix map_groups refcount test
Date: Thu, 14 May 2015 19:38:04 -0300	[thread overview]
Message-ID: <1431643089-16176-13-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1431643089-16176-1-git-send-email-acme@kernel.org>

From: Arnaldo Carvalho de Melo <acme@redhat.com>

When introducing reference counting for struct thread instances I forgot
to remove the synthetic threads from the machine's rbtree so that it
then the threads would have just one reference and thus the
thread__put() replacing the thread__delete() really turns into a
thread__delete() (thread->refcnt == 1 at thread__put() time) and thus
drop the thread->mg refcount, as expected by the this test.

Fix it by calling machine__remove_thread() (the counterpart of
machine__findnew_thread()) on all the synthetic threads after the
checks that involves the rbtree were done.

Before:

  # perf test -v mg
  30: Test thread mg sharing                                 :
  --- start ---
  test child forked, pid 26995
  FAILED tests/thread-mg-share.c:68 wrong refcnt (4 != 3)
  test child finished with -1
  ---- end ----
  Test thread mg sharing: FAILED!
  #

After:

  # perf test mg
  30: Test thread mg sharing: Ok
  #

Fixes: b91fc39f4ad7 ("perf machine: Protect the machine->threads with a rwlock")
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-uoqq0fjei90ohhhcboz6ay33@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/tests/thread-mg-share.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/tools/perf/tests/thread-mg-share.c b/tools/perf/tests/thread-mg-share.c
index 04ecceed4e5b..c0ed56f7efc6 100644
--- a/tools/perf/tests/thread-mg-share.c
+++ b/tools/perf/tests/thread-mg-share.c
@@ -58,6 +58,18 @@ int test__thread_mg_share(void)
 	other_leader = machine__find_thread(machine, 4, 4);
 	TEST_ASSERT_VAL("failed to find other leader", other_leader);
 
+	/*
+	 * Ok, now that all the rbtree related operations were done,
+	 * lets remove all of them from there so that we can do the
+	 * refcounting tests.
+	 */
+	machine__remove_thread(machine, leader);
+	machine__remove_thread(machine, t1);
+	machine__remove_thread(machine, t2);
+	machine__remove_thread(machine, t3);
+	machine__remove_thread(machine, other);
+	machine__remove_thread(machine, other_leader);
+
 	other_mg = other->mg;
 	TEST_ASSERT_EQUAL("wrong refcnt", other_mg->refcnt, 2);
 
@@ -81,11 +93,6 @@ int test__thread_mg_share(void)
 
 	thread__put(other);
 
-	/*
-	 * Cannot call machine__delete_threads(machine) now,
-	 * because we've already released all the threads.
-	 */
-
 	machines__exit(&machines);
 	return 0;
 }
-- 
2.1.0


  parent reply	other threads:[~2015-05-14 22:43 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-14 22:37 [GIT PULL 00/17] perf/core improvements and fixes Arnaldo Carvalho de Melo
2015-05-14 22:37 ` [PATCH 01/17] perf kmem: Fix compiler warning about may be accessing uninitialized variable Arnaldo Carvalho de Melo
2015-05-14 22:37 ` [PATCH 02/17] perf tools: Document relation of per-thread event count feature Arnaldo Carvalho de Melo
2015-05-14 22:37 ` [PATCH 03/17] perf report: Force tty output if -T/--thread option is given Arnaldo Carvalho de Melo
2015-05-14 22:37 ` [PATCH 04/17] perf trace: Removed duplicated NULL test Arnaldo Carvalho de Melo
2015-05-14 22:37 ` [PATCH 05/17] perf probe: Remove length limitation for showing available variables Arnaldo Carvalho de Melo
2015-05-14 22:37 ` [PATCH 06/17] perf probe: Add --range option to show a variable's location range Arnaldo Carvalho de Melo
2015-06-25 12:30   ` Alexei Starovoitov
2015-05-14 22:37 ` [PATCH 07/17] perf probe: Show better error message when failed to find variable Arnaldo Carvalho de Melo
2015-05-14 22:38 ` [PATCH 08/17] perf tests: Fix to get negative exit codes Arnaldo Carvalho de Melo
2015-05-14 22:38 ` [PATCH 09/17] perf report: Do not restrict -T option by other options Arnaldo Carvalho de Melo
2015-05-14 22:38 ` [PATCH 10/17] perf tests: Show refcounting broken expectations in thread-mg-share test Arnaldo Carvalho de Melo
2015-05-14 22:38 ` [PATCH 11/17] perf machine: No need to keep a refcnt for last_match Arnaldo Carvalho de Melo
2015-05-14 22:38 ` Arnaldo Carvalho de Melo [this message]
2015-05-14 22:38 ` [PATCH 13/17] perf probe: Ignore tail calls to probed functions Arnaldo Carvalho de Melo
2015-05-14 22:38 ` [PATCH 14/17] perf report: Fix some option handling on --stdio Arnaldo Carvalho de Melo
2015-05-14 22:38 ` [PATCH 15/17] tools lib traceevent: Provide le16toh define for older systems Arnaldo Carvalho de Melo
2015-05-14 22:38 ` [PATCH 16/17] perf trace: Fix the build on older distros Arnaldo Carvalho de Melo
2015-05-14 22:38 ` [PATCH 17/17] perf tools: Make flex/bison calls honour V=1 Arnaldo Carvalho de Melo
2015-05-15  6:39 ` [GIT PULL 00/17] perf/core improvements and fixes Ingo Molnar

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=1431643089-16176-13-git-send-email-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=bp@suse.de \
    --cc=dsahern@gmail.com \
    --cc=dzickus@redhat.com \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@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;
as well as URLs for NNTP newsgroup(s).