Re: [PATCH 18/37] perf tools: Remove thread when map groups initialization failed

2014-12-28 Thread Namhyung Kim
On Sat, Dec 27, 2014 at 05:45:56PM -0700, David Ahern wrote:
> On 12/24/14 12:15 AM, Namhyung Kim wrote:
> >Otherwise it'll break the machine->threads tree.
> >
> >Signed-off-by: Namhyung Kim 
> >---
> >  tools/perf/util/machine.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> >diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
> >index 031bace39fdc..beae6e8fe789 100644
> >--- a/tools/perf/util/machine.c
> >+++ b/tools/perf/util/machine.c
> >@@ -411,6 +411,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(>rb_node, >threads);
> > thread__delete(th);
> > return NULL;
> > }
> >
> 
> Can you move the thread__init_map_groups() before the thread is added to the
> rbtree? If no, you need to delay setting 'machine->last_match = th'
> otherwise it references a deleted thread.

You're right - I'll move the setting after the thread__init_map_groups().

Thanks,
Namhyung
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 18/37] perf tools: Remove thread when map groups initialization failed

2014-12-28 Thread Namhyung Kim
On Sat, Dec 27, 2014 at 05:45:56PM -0700, David Ahern wrote:
 On 12/24/14 12:15 AM, Namhyung Kim wrote:
 Otherwise it'll break the machine-threads tree.
 
 Signed-off-by: Namhyung Kim namhy...@kernel.org
 ---
   tools/perf/util/machine.c | 1 +
   1 file changed, 1 insertion(+)
 
 diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
 index 031bace39fdc..beae6e8fe789 100644
 --- a/tools/perf/util/machine.c
 +++ b/tools/perf/util/machine.c
 @@ -411,6 +411,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);
  thread__delete(th);
  return NULL;
  }
 
 
 Can you move the thread__init_map_groups() before the thread is added to the
 rbtree? If no, you need to delay setting 'machine-last_match = th'
 otherwise it references a deleted thread.

You're right - I'll move the setting after the thread__init_map_groups().

Thanks,
Namhyung
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 18/37] perf tools: Remove thread when map groups initialization failed

2014-12-27 Thread David Ahern

On 12/24/14 12:15 AM, Namhyung Kim wrote:

Otherwise it'll break the machine->threads tree.

Signed-off-by: Namhyung Kim 
---
  tools/perf/util/machine.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 031bace39fdc..beae6e8fe789 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -411,6 +411,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(>rb_node, >threads);
thread__delete(th);
return NULL;
}



Can you move the thread__init_map_groups() before the thread is added to 
the rbtree? If no, you need to delay setting 'machine->last_match = th' 
otherwise it references a deleted thread.


David
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 18/37] perf tools: Remove thread when map groups initialization failed

2014-12-27 Thread David Ahern

On 12/24/14 12:15 AM, Namhyung Kim wrote:

Otherwise it'll break the machine-threads tree.

Signed-off-by: Namhyung Kim namhy...@kernel.org
---
  tools/perf/util/machine.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 031bace39fdc..beae6e8fe789 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -411,6 +411,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);
thread__delete(th);
return NULL;
}



Can you move the thread__init_map_groups() before the thread is added to 
the rbtree? If no, you need to delay setting 'machine-last_match = th' 
otherwise it references a deleted thread.


David
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/