Re: [for-next][PATCH 2/8] ftrace: Create a slight optimization on searching the ftrace_hash

From: Steven Rostedt
Date: Fri Feb 03 2017 - 09:57:25 EST


On Fri, 3 Feb 2017 23:26:46 +0900
Namhyung Kim <namhyung@xxxxxxxxxx> wrote:

> Hi Steve,
>
> On Fri, Feb 3, 2017 at 10:40 PM, Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
> > From: "Steven Rostedt (VMware)" <rostedt@xxxxxxxxxxx>
> >
> > This is a micro-optimization, but as it has to deal with a fast path of the
> > function tracer, these optimizations can be noticed.
> >
> > The ftrace_lookup_ip() returns true if the given ip is found in the hash. If
> > it's not found or the hash is NULL, it returns false. But there's some cases
> > that a NULL hash is a true, and the ftrace_hash_empty() is tested before
> > calling ftrace_lookup_ip() in those cases. But as ftrace_lookup_ip() tests
> > that first, that adds a few extra unneeded instructions in those cases.
> >
> > A new static "always_inlined" function is created that does not perform the
> > hash empty test. This most only be used by callers that do the check first
> > anyway, as an empty or NULL hash could cause a crash if a lookup is
> > performed on it.
> >
> > Also add kernel doc for the ftrace_lookup_ip() main function.
>
> It'd be nice if ftrace_graph_addr() was changed also.
>

Yeah, I was looking at that. But I was nervous about placing this
function in the header file.

-- Steve