diff mbox

tools/power/x86/intel_pstate_tracer: Free the trace buffer memory

Message ID 1515191476-3424-1-git-send-email-dsmythies@telus.net (mailing list archive)
State Accepted, archived
Delegated to: Rafael Wysocki
Headers show

Commit Message

Doug Smythies Jan. 5, 2018, 10:31 p.m. UTC
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@telus.net>
---
 .../power/x86/intel_pstate_tracer/intel_pstate_tracer.py  | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Comments

Rafael J. Wysocki Jan. 5, 2018, 10:54 p.m. UTC | #1
On Fri, Jan 5, 2018 at 11:31 PM, Doug Smythies <doug.smythies@gmail.com> 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@telus.net>

Looks OK to me.  Srinivas?

> ---
>  .../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
>
srinivas pandruvada Jan. 5, 2018, 11:46 p.m. UTC | #2
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@gmail.c
> 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@telus.net>
> Looks OK to me.  Srinivas?

Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

> 
> > 
> > ---
> >  .../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
> >
diff mbox

Patch

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('../../')