All of lore.kernel.org
 help / color / mirror / Atom feed
* Question perf annotate: how to free allocated memory of arch->instructions
@ 2018-01-18 14:56 Thomas-Mich Richter
  2018-01-18 16:23 ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas-Mich Richter @ 2018-01-18 14:56 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, linux-perf-use., Hendrik Brueckner

I have a question regarding the struct arch and its initialization/un_initialization.

Function symbol__disassemble() invokes arch->init() once it has identified the archticture
its running on. 
When I execute command ./perf annotate --stdio I discovered that functions
arch__associate_ins_ops()
--> arch__grow_instructions()

are called to create/enlarge the array of machine instructions which require special
annotations like branches, jumps, etc to display arrows etc in the GUI. (At least on s390).

On ARM/ARM64 the arch->priv field also points to malloc'ed space needed for ARM specific
processing.

However there is no uninit() like function to remove any allocated memory and to clean up
before perf terminates.

Is this done on intention to rely on the exit of perf to release any allocated memory?
Are there plans to change this, that is invent an uninit() like function for proper memory free?
Where would be the best place to call this uninit() like function?

Thanks
-- 
Thomas Richter, Dept 3303, IBM LTC Boeblingen Germany
--
Vorsitzende des Aufsichtsrats: Martina Koederitz 
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Question perf annotate: how to free allocated memory of arch->instructions
  2018-01-18 14:56 Question perf annotate: how to free allocated memory of arch->instructions Thomas-Mich Richter
@ 2018-01-18 16:23 ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 2+ messages in thread
From: Arnaldo Carvalho de Melo @ 2018-01-18 16:23 UTC (permalink / raw)
  To: Thomas-Mich Richter; +Cc: linux-perf-use., Hendrik Brueckner

Em Thu, Jan 18, 2018 at 03:56:00PM +0100, Thomas-Mich Richter escreveu:
> I have a question regarding the struct arch and its initialization/un_initialization.
> 
> Function symbol__disassemble() invokes arch->init() once it has identified the archticture
> its running on. 
> When I execute command ./perf annotate --stdio I discovered that functions
> arch__associate_ins_ops()
> --> arch__grow_instructions()
> 
> are called to create/enlarge the array of machine instructions which require special
> annotations like branches, jumps, etc to display arrows etc in the GUI. (At least on s390).
> 
> On ARM/ARM64 the arch->priv field also points to malloc'ed space needed for ARM specific
> processing.
> 
> However there is no uninit() like function to remove any allocated memory and to clean up
> before perf terminates.
> 
> Is this done on intention to rely on the exit of perf to release any allocated memory?

We can call symbol__disassemble() multiple times ina TUI session, but
then this is done only once, i.e. the second symbol__disassemble() will
find that already in place, etc.

So no leaks, when we exit, this is all cleaned up.

> Are there plans to change this, that is invent an uninit() like function for proper memory free?
> Where would be the best place to call this uninit() like function?

I think this may be useful, for completeness sake, and for using when
trying to find leaks, using something like valgrind, etc.

But do not use it at end when not debugging, as this will make the tool
exit time take longer for no gain.

For some long running app that does annotation for multiple
architectures, etc, theoretically one would want to tear down those
structures to save space, so having the ->exit() routine (we use that
name as the counterpart to ->init()) may come handy.

- Arnaldo

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-01-18 16:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-18 14:56 Question perf annotate: how to free allocated memory of arch->instructions Thomas-Mich Richter
2018-01-18 16:23 ` Arnaldo Carvalho de Melo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.