perf machine: Mark removed threads as such
authorArnaldo Carvalho de Melo <[email protected]>
Mon, 25 May 2015 18:23:05 +0000 (15:23 -0300)
committerArnaldo Carvalho de Melo <[email protected]>
Wed, 27 May 2015 15:21:45 +0000 (12:21 -0300)
We use:

  BUG_ON(!RB_EMPTY_NODE(&thread->rb_node));

in the thread destructor as a debugging check to find out about
possibly still referenced thread instances being deleted, to do that
we need to make sure we use RB_CLEAR_NODE() right after rb_erase(),
i.e. that we use the newly introduced rb_erase_init(), that works
just like list_del_init().

Cc: Adrian Hunter <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Don Zickus <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Stephane Eranian <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
tools/perf/util/machine.c

index 7ec3188d3cb34d53a64fea44ef8afc66cdef50ac..6bf845758ae3814e877972c9f0644188a7eb7648 100644 (file)
@@ -400,7 +400,7 @@ static struct thread *____machine__findnew_thread(struct machine *machine,
                 * leader and that would screwed the rb tree.
                 */
                if (thread__init_map_groups(th, machine)) {
-                       rb_erase(&th->rb_node, &machine->threads);
+                       rb_erase_init(&th->rb_node, &machine->threads);
                        RB_CLEAR_NODE(&th->rb_node);
                        thread__delete(th);
                        return NULL;
@@ -1314,7 +1314,7 @@ static void __machine__remove_thread(struct machine *machine, struct thread *th,
        BUG_ON(atomic_read(&th->refcnt) == 0);
        if (lock)
                pthread_rwlock_wrlock(&machine->threads_lock);
-       rb_erase(&th->rb_node, &machine->threads);
+       rb_erase_init(&th->rb_node, &machine->threads);
        RB_CLEAR_NODE(&th->rb_node);
        /*
         * Move it first to the dead_threads list, then drop the reference,