Commit 10d9dda4 authored by Masami Hiramatsu (Google)'s avatar Masami Hiramatsu (Google)
Browse files

tracing: tprobe-events: Fix to register tracepoint correctly

Since __tracepoint_user_init() calls tracepoint_user_register() without
initializing tuser->tpoint with given tracpoint, it does not register
tracepoint stub function as callback correctly, and tprobe does not work.

Initializing tuser->tpoint correctly before tracepoint_user_register()
so that it sets up tracepoint callback.

I confirmed below example works fine again.

echo "t sched_switch preempt prev_pid=prev->pid next_pid=next->pid" > /sys/kernel/tracing/dynamic_events
echo 1 > /sys/kernel/tracing/events/tracepoints/sched_switch/enable
cat /sys/kernel/tracing/trace_pipe

Link: https://lore.kernel.org/all/176244793514.155515.6466348656998627773.stgit@devnote2/



Fixes: 2867495d ("tracing: tprobe-events: Register tracepoint when enable tprobe event")
Reported-by: default avatarBeau Belgrave <beaub@linux.microsoft.com>
Cc: stable@vger.kernel.org
Signed-off-by: default avatarMasami Hiramatsu (Google) <mhiramat@kernel.org>
Tested-by: default avatarBeau Belgrave <beaub@linux.microsoft.com>
Reviewed-by: default avatarBeau Belgrave <beaub@linux.microsoft.com>
parent 6146a0f1
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -106,13 +106,14 @@ static struct tracepoint_user *__tracepoint_user_init(const char *name, struct t
	if (!tuser->name)
		return NULL;

	/* Register tracepoint if it is loaded. */
	if (tpoint) {
		tuser->tpoint = tpoint;
		ret = tracepoint_user_register(tuser);
		if (ret)
			return ERR_PTR(ret);
	}

	tuser->tpoint = tpoint;
	tuser->refcount = 1;
	INIT_LIST_HEAD(&tuser->list);
	list_add(&tuser->list, &tracepoint_user_list);