Re: [PATCH v0 3/5] perf: Introduce instruction trace filtering

From: Alexander Shishkin
Date: Fri Dec 11 2015 - 12:15:46 EST


Peter Zijlstra <peterz@xxxxxxxxxxxxx> writes:

> On Fri, Dec 11, 2015 at 03:36:36PM +0200, Alexander Shishkin wrote:
>> +static int
>> +perf_event_set_itrace_filter(struct perf_event *event, char *filter_str)
>> +{
>> + int ret = 0;
>> +
>> + /*
>> + * Since this is called in perf_ioctl() path, we're already holding
>> + * ctx::mutex.
>> + */
>> + lockdep_assert_held(&event->ctx->mutex);
>> +
>> + /*
>> + * For now, we only support filtering in per-task events; doing so
>> + * for cpu-wide events requires additional context switching trickery,
>> + * since same object code will be mapped at different virtual
>> + * addresses in different processes.
>> + */
>> + if (!event->ctx->task)
>> + return -EOPNOTSUPP;
>> +
>> + /* remove existing filters, if any */
>> + perf_itrace_filters_clear(event);
>> +
>> + ret = perf_event_parse_itrace_filter(event, filter_str);
>> + if (!ret) {
>> + perf_itrace_filters_apply(event);
>> +
>> + ret = perf_event_itrace_filters_setup(event);
>> + if (ret)
>> + perf_itrace_filters_clear(event);
>
> This is what I meant, if you try and set a 'wrong' filter while it
> already has filters set, you'll not only error out, you'll also wipe the
> current state.
>
> This seems wrong.

Ah, now I see what you mean. Yes, you're right.

Regards,
--
Alex
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/