[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201117155851.0c915705@gandalf.local.home>
Date: Tue, 17 Nov 2020 15:58:51 -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>,
Josh Poimboeuf <jpoimboe@...hat.com>,
Peter Zijlstra <peterz@...radead.org>
Subject: Re: [PATCH] tracepoint: Do not fail unregistering a probe due to
memory allocation
On Tue, 17 Nov 2020 15:34:51 -0500
Steven Rostedt <rostedt@...dmis.org> wrote:
> On Tue, 17 Nov 2020 14:47:20 -0500 (EST)
> Mathieu Desnoyers <mathieu.desnoyers@...icios.com> wrote:
>
> > There seems to be more effect on the data size: adding the "stub_func" field
> > in struct tracepoint adds 8320 bytes of data to my vmlinux. But considering
> > the layout of struct tracepoint:
> >
> > struct tracepoint {
> > const char *name; /* Tracepoint name */
> > struct static_key key;
> > struct static_call_key *static_call_key;
> > void *static_call_tramp;
> > void *iterator;
> > int (*regfunc)(void);
> > void (*unregfunc)(void);
> > struct tracepoint_func __rcu *funcs;
> > void *stub_func;
> > };
> >
> > I would argue that we have many other things to optimize there if we want to
> > shrink the bloat, starting with static keys and system call reg/unregfunc pointers.
>
> This is the part that I want to decrease, and yes there's other fish to fry
> in that code, but I really don't want to be adding more.
If it comes down to not trusting calling a stub, I'll still keep the stub
logic in, and just add the following:
diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h
index 0f21617f1a66..d50a1a652d61 100644
--- a/include/linux/tracepoint.h
+++ b/include/linux/tracepoint.h
@@ -33,6 +33,8 @@ struct trace_eval_map {
#define TRACEPOINT_DEFAULT_PRIO 10
+extern void tp_stub_func(void *data, ...);
+
extern struct srcu_struct tracepoint_srcu;
extern int
@@ -310,7 +312,8 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
do { \
it_func = (it_func_ptr)->func; \
__data = (it_func_ptr)->data; \
- ((void(*)(void *, proto))(it_func))(__data, args); \
+ if (likely(it_func != tp_stub_func)) \
+ ((void(*)(void *, proto))(it_func))(__data, args); \
} while ((++it_func_ptr)->func); \
return 0; \
} \
diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
index 774b3733cbbe..f3bb0ee478d1 100644
--- a/kernel/tracepoint.c
+++ b/kernel/tracepoint.c
@@ -54,7 +54,7 @@ struct tp_probes {
};
/* Called in removal of a func but failed to allocate a new tp_funcs */
-static void tp_stub_func(void)
+void tp_stub_func(void *data, ...)
{
return;
}
-- Steve
Powered by blists - more mailing lists