From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757433AbbJHM6G (ORCPT ); Thu, 8 Oct 2015 08:58:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54041 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754387AbbJHM6E (ORCPT ); Thu, 8 Oct 2015 08:58:04 -0400 Date: Thu, 8 Oct 2015 14:58:00 +0200 From: Jiri Olsa To: Namhyung Kim Cc: Arnaldo Carvalho de Melo , Ingo Molnar , Peter Zijlstra , LKML , Frederic Weisbecker , Stephane Eranian , David Ahern , Andi Kleen Subject: Re: [RFC/PATCH 17/38] perf tools: Maintain map groups list in a leader thread Message-ID: <20151008125800.GC14829@krava.landal.opennet> References: <1443763159-29098-1-git-send-email-namhyung@kernel.org> <1443763159-29098-18-git-send-email-namhyung@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1443763159-29098-18-git-send-email-namhyung@kernel.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 02, 2015 at 02:18:58PM +0900, Namhyung Kim wrote: SNIP > int __thread__set_comm(struct thread *thread, const char *str, u64 timestamp, > bool exec) > { > @@ -182,6 +257,40 @@ int __thread__set_comm(struct thread *thread, const char *str, u64 timestamp, > unwind__flush_access(thread); > } > > + if (exec) { > + struct machine *machine; > + > + BUG_ON(thread->mg == NULL || thread->mg->machine == NULL); > + > + machine = thread->mg->machine; > + > + if (thread->tid != thread->pid_) { > + struct map_groups *old = thread->mg; > + struct thread *leader; > + > + leader = machine__findnew_thread(machine, thread->pid_, > + thread->pid_); > + > + /* now it'll be a new leader */ > + thread->pid_ = thread->tid; > + > + thread->mg = map_groups__new(old->machine); > + if (thread->mg == NULL) > + return -ENOMEM; > + > + /* save current mg in the new leader */ > + thread__clone_map_groups(thread, leader); > + > + /* current mg of leader thread needs one more refcnt */ > + map_groups__get(thread->mg); > + > + thread__set_map_groups(thread, thread->mg, old->timestamp); > + } > + > + /* create a new mg for newly executed binary */ > + thread__set_map_groups(thread, map_groups__new(machine), timestamp); should this ^^^^ be in the else case of above condition? also thread__fork calls thread__clone_map_groups once again, I have some difficulty to sort this out ATM.. is that correct? some comment on how we treat map groups in general (for fork/clone/exit) would be awesome ;-) thanks, jirka