lkml.org 
[lkml]   [2011]   [May]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] trace: Add a free on close control mechanism for buffer_size_kb
From
Date
On Fri, 2011-04-29 at 16:16 -0700, Vaibhav Nagarnaik wrote:

> +static ssize_t tracing_resize_ring_buffer(unsigned long size)
> +{
> + int cpu, ret = 0;
> +
> + mutex_lock(&trace_types_lock);
> +
> + tracing_stop();
> +
> + /* disable all cpu buffers */
> + for_each_tracing_cpu(cpu) {
> + if (global_trace.data[cpu])
> + atomic_inc(&global_trace.data[cpu]->disabled);
> + if (max_tr.data[cpu])
> + atomic_inc(&max_tr.data[cpu]->disabled);
> + }
> +
> + if (size != global_trace.entries)
> + ret = __tracing_resize_ring_buffer(size);
> +
> + /* If check pages failed, return ENOMEM */
> + if (tracing_disabled)
> + ret = -ENOMEM;

This is incorrect. tracing_disabled is set from
__tracing_resize_ring_buffer() if the max buffer can't become the same
size as the global buffer.

What you should do is just check if ret is less than zero here.

if (ret < 0)
ret = -ENOMEM;

-- Steve


> +
> + for_each_tracing_cpu(cpu) {
> + if (global_trace.data[cpu])
> + atomic_dec(&global_trace.data[cpu]->disabled);
> + if (max_tr.data[cpu])
> + atomic_dec(&max_tr.data[cpu]->disabled);
> + }
> +
> + tracing_start();
> + mutex_unlock(&trace_types_lock);
> +
> + return ret;
> +}
> +
>



\
 
 \ /
  Last update: 2011-05-26 05:33    [W:0.106 / U:1.048 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site