From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965522AbbENWnj (ORCPT ); Thu, 14 May 2015 18:43:39 -0400 Received: from casper.infradead.org ([85.118.1.10]:55033 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965148AbbENWiV (ORCPT ); Thu, 14 May 2015 18:38:21 -0400 From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , Adrian Hunter , Borislav Petkov , David Ahern , Don Zickus , Frederic Weisbecker , Jiri Olsa , Namhyung Kim , Stephane Eranian Subject: [PATCH 12/17] perf tests: Fix map_groups refcount test Date: Thu, 14 May 2015 19:38:04 -0300 Message-Id: <1431643089-16176-13-git-send-email-acme@kernel.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1431643089-16176-1-git-send-email-acme@kernel.org> References: <1431643089-16176-1-git-send-email-acme@kernel.org> X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnaldo Carvalho de Melo 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 Cc: Borislav Petkov Cc: David Ahern Cc: Don Zickus Cc: Frederic Weisbecker Cc: Jiri Olsa Cc: Namhyung Kim Cc: Stephane Eranian Link: http://lkml.kernel.org/n/tip-uoqq0fjei90ohhhcboz6ay33@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- 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