From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752126AbbESWqY (ORCPT ); Tue, 19 May 2015 18:46:24 -0400 Received: from mail.kernel.org ([198.145.29.136]:45005 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751357AbbESWqX (ORCPT ); Tue, 19 May 2015 18:46:23 -0400 Date: Tue, 19 May 2015 19:46:18 -0300 From: Arnaldo Carvalho de Melo To: Namhyung Kim Cc: Ingo Molnar , Peter Zijlstra , Jiri Olsa , LKML , David Ahern , Adrian Hunter , Andi Kleen , Frederic Weisbecker , Stephane Eranian Subject: Re: [PATCH 33/40] perf session: Separate struct machines from session Message-ID: <20150519224618.GC26111@kernel.org> References: <1431909055-21442-1-git-send-email-namhyung@kernel.org> <1431909055-21442-34-git-send-email-namhyung@kernel.org> <20150518125259.GE15972@kernel.org> <20150519072815.GL21663@sejong> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150519072815.GL21663@sejong> X-Url: http://acmel.wordpress.com 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 Em Tue, May 19, 2015 at 04:28:15PM +0900, Namhyung Kim escreveu: > On Mon, May 18, 2015 at 09:52:59AM -0300, Arnaldo Carvalho de Melo wrote: > > Em Mon, May 18, 2015 at 09:30:48AM +0900, Namhyung Kim escreveu: > > > With multi-thread report, separate sessions can be passed to each > > > thread, in this case we should keep a single machine state for all > > > struct sessions. Separate machines and have a pointer in sessions. > > > > I had to look at all the patch to semi-figure this out, i.e. you said it > > should be separated from 'perf_session', agreed. > > > > But who will create it? How will it be passed to the perf_session > > instances? > > > > Most of the patch is making session->machines be turned into a pointer, > > but the meat, i.e. who creates it, is unclear, I see a malloc in > > perf_session__new(), where I was kinda expecting that a higer layer, > > perhaps in struct tool? Would create the list of all machines (struct > > machines) and then pass it to multiple perf_session__new() calls. > > > > But then perf_session__delete() calls 'free(session->machines)', huh? > > OK. So, this is what I have in my head: > > perf_tool__create_machines(tool) { > tool->machines = malloc(); > machines__init(tool->machines); > } Probably, but then in this case you would call machines__new(), that does the malloc and init. > > perf_session__new(file, repipe, tool) { > session->machines = tool->machines; > ... > } That could be ok. > > perf_tool__delete_machines(tool) { > /* call machines-related destructors */ > free(tool->machines); > } That would be machines__delete(tool->machines), that calls machine__exit() and then does the free. - Arnaldo