lkml.org 
[lkml]   [2009]   [Oct]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH 3/4] tracing/profile: Add filter support
From
On Thu, Oct 15, 2009 at 11:21 AM, Li Zefan <lizf@cn.fujitsu.com> wrote:
> - Add an ioctl to allocate a filter for a perf event.
>
> - Free the filter when the associated perf event is to be freed.
>
> - Do the filtering in perf_swevent_match().
>
> Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>

{snip}

> +int ftrace_profile_set_filter(struct perf_event *event, int event_id,
> +                             char *filter_str)
> +{
> +       int err;
> +       struct event_filter *filter;
> +       struct filter_parse_state *ps;
> +       struct ftrace_event_call *call = NULL;
> +
> +       mutex_lock(&event_mutex);
> +
> +       list_for_each_entry(call, &ftrace_events, list) {
> +               if (call->id == event_id)
> +                       break;
> +       }
> +       if (!call)
> +               return -EINVAL;
> +
> +       if (event->filter)
> +               return -EEXIST;
> +
> +       filter = __alloc_preds();
> +       if (IS_ERR(filter))
> +               return PTR_ERR(filter);


Just return will leave &event_mutex locked...

Am I missing something here?

> +
> +       err = -ENOMEM;
> +       ps = kzalloc(sizeof(*ps), GFP_KERNEL);
> +       if (!ps)
> +               goto free_preds;
> +
> +       parse_init(ps, filter_ops, filter_str);
> +       err = filter_parse(ps);
> +       if (err)
> +               goto free_ps;
> +
> +       err = replace_preds(call, filter, ps, filter_str, false);
> +       if (!err)
> +               event->filter = filter;
> +
> +free_ps:
> +       filter_opstack_clear(ps);
> +       postfix_clear(ps);
> +       kfree(ps);
> +
> +free_preds:
> +       if (err)
> +               __free_preds(filter);
> +
> +       mutex_unlock(&event_mutex);
> +
> +       return err;
> +}
> +
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2009-10-15 11:51    [W:0.123 / U:2.748 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site