OSDN Git Service

perf thread: Fix reference count initial state
authorArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 11 Dec 2015 22:11:23 +0000 (19:11 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 14 Dec 2015 15:08:55 +0000 (12:08 -0300)
commitabd828688407eb86044f1bc9e5133c55d7597596
treeb42146c0c9ffa8dc7cd3643af4e021b5a4f4d1b8
parentb6847d2c2a50e96680e233ce4b2784981b6f309e
perf thread: Fix reference count initial state

We should always return from thread__new(), the constructor, with the
object with a reference count of one, so that:

     struct thread *thread = thread__new();
     thread__put(thread);

Will call thread__delete().

If any reference is made to that 'thread' variable, it better use
thread__get(thread) to hold a reference.

We were returning with thread->refcnt set to zero, fix it and some cases
where thread__delete() was being called, which were not a problem
because just one reference was being used, now that we set it to 1, use
thread__put() instead.

Reported-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-4b9mkuk66to4ecckpmpvqx6s@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/intel-pt.c
tools/perf/util/machine.c
tools/perf/util/thread.c