[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201117142145.43194f1a@gandalf.local.home>
Date: Tue, 17 Nov 2020 14:21:45 -0500
From: Steven Rostedt <rostedt@...dmis.org>
To: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
Cc: linux-kernel <linux-kernel@...r.kernel.org>,
Matt Mullins <mmullins@...x.us>,
Ingo Molnar <mingo@...hat.com>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Dmitry Vyukov <dvyukov@...gle.com>,
Martin KaFai Lau <kafai@...com>,
Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
Andrii Nakryiko <andriin@...com>,
John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...omium.org>,
netdev <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>,
Kees Cook <keescook@...omium.org>
Subject: Re: [PATCH] tracepoint: Do not fail unregistering a probe due to
memory allocation
On Tue, 17 Nov 2020 14:15:10 -0500 (EST)
Mathieu Desnoyers <mathieu.desnoyers@...icios.com> wrote:
> diff --git a/include/linux/tracepoint-defs.h b/include/linux/tracepoint-defs.h
> index e7c2276be33e..e0351bb0b140 100644
> --- a/include/linux/tracepoint-defs.h
> +++ b/include/linux/tracepoint-defs.h
> @@ -38,6 +38,7 @@ struct tracepoint {
> int (*regfunc)(void);
> void (*unregfunc)(void);
> struct tracepoint_func __rcu *funcs;
> + void *stub_func;
> };
>
> #ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
> diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
> index 0f21617f1a66..b0b805de3779 100644
> --- a/include/linux/tracepoint.h
> +++ b/include/linux/tracepoint.h
> @@ -287,6 +287,9 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
> #define DEFINE_TRACE_FN(_name, _reg, _unreg, proto, args) \
> static const char __tpstrtab_##_name[] \
> __section("__tracepoints_strings") = #_name; \
> + static void __cold __tracepoint_stub_func_##_name(void *__data, proto) \
> + { \
> + } \
The thing is, tracepoints are already bloated. I do not want to add
something like this that will unnecessarily add more text.
Since all tracepoints callbacks have at least one parameter (__data), we
could declare tp_stub_func as:
static void tp_stub_func(void *data, ...)
{
return;
}
And now C knows that tp_stub_func() can be called with one or more
parameters, and had better be able to deal with it!
-- Steve
> extern struct static_call_key STATIC_CALL_KEY(tp_func_##_name); \
> int __traceiter_##_name(void *__data, proto); \
> struct tracepoint __tracepoint_##_name __used \
> @@ -298,7 +301,8 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
> .iterator = &__traceiter_##_name, \
> .regfunc = _reg, \
> .unregfunc = _unreg, \
> - .funcs = NULL }; \
> + .funcs = NULL, \
> + .stub_func = __tracepoint_stub_func_##_name, }; \
> __TRACEPOINT_ENTRY(_name); \
> int __traceiter_##_name(void *__data, proto) \
> { \
>
> Thanks,
>
> Mathieu
>
Powered by blists - more mailing lists