Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c6567f64 authored by Frederic Weisbecker's avatar Frederic Weisbecker Committed by Ingo Molnar
Browse files

hw-breakpoints: Improve in-kernel event creation error granularity



In fail case, perf_event_create_kernel_counter() returns NULL
instead of an error, which doesn't help us to inform the user
about the origin of the problem from the outer most callers.
Often we can just return -EINVAL, which doesn't help anyone when
it's eventually about a memory allocation failure.

Then, this patch makes perf_event_create_kernel_counter() always
return a detailed error code.

Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Prasad <prasad@linux.vnet.ibm.com>
LKML-Reference: <1259210142-5714-2-git-send-regression-fweisbec@gmail.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent d99be40a
Loading
Loading
Loading
Loading
+11 −9
Original line number Original line Diff line number Diff line
@@ -4780,14 +4780,17 @@ perf_event_create_kernel_counter(struct perf_event_attr *attr, int cpu,
	 */
	 */


	ctx = find_get_context(pid, cpu);
	ctx = find_get_context(pid, cpu);
	if (IS_ERR(ctx))
	if (IS_ERR(ctx)) {
		return NULL;
		err = PTR_ERR(ctx);
		goto err_exit;
	}


	event = perf_event_alloc(attr, cpu, ctx, NULL,
	event = perf_event_alloc(attr, cpu, ctx, NULL,
				     NULL, callback, GFP_KERNEL);
				     NULL, callback, GFP_KERNEL);
	if (IS_ERR(event)) {
		err = PTR_ERR(event);
		err = PTR_ERR(event);
	if (IS_ERR(event))
		goto err_put_context;
		goto err_put_context;
	}


	event->filp = NULL;
	event->filp = NULL;
	WARN_ON_ONCE(ctx->parent_ctx);
	WARN_ON_ONCE(ctx->parent_ctx);
@@ -4805,10 +4808,9 @@ perf_event_create_kernel_counter(struct perf_event_attr *attr, int cpu,
	return event;
	return event;


 err_put_context:
 err_put_context:
	if (err < 0)
	put_ctx(ctx);
	put_ctx(ctx);

 err_exit:
	return NULL;
	return ERR_PTR(err);
}
}
EXPORT_SYMBOL_GPL(perf_event_create_kernel_counter);
EXPORT_SYMBOL_GPL(perf_event_create_kernel_counter);