linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Changbin Du <changbin.du@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] ftrace: simplify ftrace hash lookup code
Date: Tue, 10 Sep 2019 05:28:04 -0400	[thread overview]
Message-ID: <20190910052804.57308909@oasis.local.home> (raw)
In-Reply-To: <20190910003321.d3q65j756z3vzhiw@mail.google.com>

On Tue, 10 Sep 2019 08:33:23 +0800
Changbin Du <changbin.du@gmail.com> wrote:

> > 
> > bool ftrace_lookup_ip(struct ftrace_hash *hash, unsigned long ip, bool empty_result)
> > {
> > 	if (ftrace_hash_empty(hash))
> > 		return empty_result;
> > 
> > 	return __ftrace_lookup_ip(hash, ip);
> > }
> >  
> We must add another similar function since ftrace_lookup_ip() returns a pointer.
> 
> bool ftrace_contains_ip(struct ftrace_hash *hash, unsigned long ip,
> 			bool empty_result)
> {
> 	if (ftrace_hash_empty(hash))
> 		return empty_result;
> 
> 	return !!__ftrace_lookup_ip(hash, ip);
> }
> 
> But after this, it's a little overkill I think. It is not much simpler than before.
> Do you still want this then?
> 
>

Or...

static struct ftrace_func_entry empty_func_entry;
#define EMPTY_FUNC_ENTRY = &empty_func_entry;

[..]
 * @empty_result: return NULL if false or EMPTY_FUNC_ENTRY on true
[..]
 * @empty_result should be false, unless this is used for testing if the ip
 * exists in the hash, and an empty hash should be considered true.
 * This is useful when the empty hash is considered to contain all addresses.
[..]
struct ftrace_func_entry *
ftrace_lookup_ip(struct ftrace_hash *hash, unsigned long ip, bool empty_result)
{
	if (ftrace_hash_empty(hash))
		return empty_result ? EMPTY_FUNC_ENTRY : NULL;

	return __ftrace_lookup_ip(hash, ip);
}

But looking at this more, I'm going back to not touching the code in
this location, because __ftrace_lookup_ip() is static, where as
ftrace_lookup_ip() is not, and this is in a very fast path, and I
rather keep it open coded.

Lets just drop the first hunk of your patch. The second hunk is fine.


-- Steve

  reply	other threads:[~2019-09-10  9:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-09  0:31 Changbin Du
2019-09-09 14:54 ` Steven Rostedt
2019-09-09 23:39   ` Changbin Du
2019-09-10  0:33   ` Changbin Du
2019-09-10  9:28     ` Steven Rostedt [this message]
2019-09-10 14:29       ` Changbin Du

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190910052804.57308909@oasis.local.home \
    --to=rostedt@goodmis.org \
    --cc=changbin.du@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --subject='Re: [PATCH v2] ftrace: simplify ftrace hash lookup code' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).