Re: [PATCH] tools/power/x86/intel_pstate_tracer: Free the trace buffer memory

From: Srinivas Pandruvada
Date: Fri Jan 05 2018 - 18:46:57 EST


On Fri, 2018-01-05 at 23:54 +0100, Rafael J. Wysocki wrote:
> On Fri, Jan 5, 2018 at 11:31 PM, Doug Smythies <doug.smythies@xxxxxxx
> om> wrote:
> >
> > The trace buffer memory should be, mostly, freed after
> > the buffer has been output.
> >
> > This patch is required before a future patch that will allow
> > the user to override the default, and specify the trace buffer
> > memory allocation as a command line option.
> >
> > Signed-off-by: Doug Smythies <dsmythies@xxxxxxxxx>
> Looks OK to me.ÂÂSrinivas?

Acked-by: Srinivas Pandruvada <srinivas.pandruvada@xxxxxxxxxxxxxxx>

>
> >
> > ---
> > Â.../power/x86/intel_pstate_tracer/intel_pstate_tracer.pyÂÂ| 15
> > +++++++++++++++
> > Â1 file changed, 15 insertions(+)
> >
> > diff --git
> > a/tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py
> > b/tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py
> > index 0b24dd9..29f50d4 100755
> > --- a/tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py
> > +++ b/tools/power/x86/intel_pstate_tracer/intel_pstate_tracer.py
> > @@ -411,6 +411,16 @@ def set_trace_buffer_size():
> > ÂÂÂÂÂÂÂÂÂprint('IO error setting trace buffer size ')
> > ÂÂÂÂÂÂÂÂÂquit()
> >
> > +def free_trace_buffer():
> > +ÂÂÂÂ""" Free the trace buffer memory """
> > +
> > +ÂÂÂÂtry:
> > +ÂÂÂÂÂÂÂopen('/sys/kernel/debug/tracing/buffer_size_kb'
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ, 'w').write("1")
> > +ÂÂÂÂexcept:
> > +ÂÂÂÂÂÂÂÂprint('IO error setting trace buffer size ')
> > +ÂÂÂÂÂÂÂÂquit()
> > +
> > Âdef read_trace_data(filename):
> > ÂÂÂÂÂ""" Read and parse trace data """
> >
> > @@ -583,4 +593,9 @@ for root, dirs, files in os.walk('.'):
> > ÂÂÂÂÂfor f in files:
> > ÂÂÂÂÂÂÂÂÂfix_ownership(f)
> >
> > +clear_trace_file()
> > +# Free the memory
> > +if interval:
> > +ÂÂÂÂfree_trace_buffer()
> > +
> > Âos.chdir('../../')
> > --
> > 2.7.4
> >