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 -- 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/