mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ftrace: simplify ftrace hash lookup code
@ 2019-09-08 12:05 Changbin Du
  2019-09-09  0:05 ` Changbin Du
  0 siblings, 1 reply; 2+ messages in thread
From: Changbin Du @ 2019-09-08 12:05 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: Ingo Molnar, linux-kernel, Changbin Du

Function ftrace_lookup_ip() will check empty hash table. So we don't
need extra check outside.

Signed-off-by: Changbin Du <changbin.du@gmail.com>
---
 kernel/trace/ftrace.c | 15 ++++-----------
 kernel/trace/trace.h  |  6 ------
 2 files changed, 4 insertions(+), 17 deletions(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index f9821a3374e9..85115deca667 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1461,10 +1461,8 @@ static bool hash_contains_ip(unsigned long ip,
 	 * considered a match for the filter hash, but an empty
 	 * notrace hash is considered not in the notrace hash.
 	 */
-	return (ftrace_hash_empty(hash->filter_hash) ||
-		__ftrace_lookup_ip(hash->filter_hash, ip)) &&
-		(ftrace_hash_empty(hash->notrace_hash) ||
-		 !__ftrace_lookup_ip(hash->notrace_hash, ip));
+	return ftrace_lookup_ip(hash->filter_hash, ip) &&
+	       !ftrace_lookup_ip(hash->notrace_hash, ip);
 }
 
 /*
@@ -2890,8 +2888,7 @@ ops_references_rec(struct ftrace_ops *ops, struct dyn_ftrace *rec)
 		return true;
 
 	/* The function must be in the filter */
-	if (!ftrace_hash_empty(ops->func_hash->filter_hash) &&
-	    !__ftrace_lookup_ip(ops->func_hash->filter_hash, rec->ip))
+	if (!ftrace_lookup_ip(ops->func_hash->filter_hash, rec->ip))
 		return false;
 
 	/* If in notrace hash, we ignore it too */
@@ -6036,11 +6033,7 @@ clear_func_from_hash(struct ftrace_init_func *func, struct ftrace_hash *hash)
 {
 	struct ftrace_func_entry *entry;
 
-	if (ftrace_hash_empty(hash))
-		return;
-
-	entry = __ftrace_lookup_ip(hash, func->ip);
-
+	entry = ftrace_lookup_ip(hash, func->ip);
 	/*
 	 * Do not allow this rec to match again.
 	 * Yeah, it may waste some memory, but will be removed
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 005f08629b8b..74162bc4024d 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -941,11 +941,6 @@ static inline int ftrace_graph_addr(struct ftrace_graph_ent *trace)
 
 	preempt_disable_notrace();
 
-	if (ftrace_hash_empty(ftrace_graph_hash)) {
-		ret = 1;
-		goto out;
-	}
-
 	if (ftrace_lookup_ip(ftrace_graph_hash, addr)) {
 
 		/*
@@ -967,7 +962,6 @@ static inline int ftrace_graph_addr(struct ftrace_graph_ent *trace)
 		ret = 1;
 	}
 
-out:
 	preempt_enable_notrace();
 	return ret;
 }
-- 
2.20.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ftrace: simplify ftrace hash lookup code
  2019-09-08 12:05 [PATCH] ftrace: simplify ftrace hash lookup code Changbin Du
@ 2019-09-09  0:05 ` Changbin Du
  0 siblings, 0 replies; 2+ messages in thread
From: Changbin Du @ 2019-09-09  0:05 UTC (permalink / raw)
  To: Changbin Du; +Cc: Steven Rostedt, Ingo Molnar, linux-kernel

On Sun, Sep 08, 2019 at 08:05:45PM +0800, Changbin Du wrote:
> diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
> index 005f08629b8b..74162bc4024d 100644
> --- a/kernel/trace/trace.h
> +++ b/kernel/trace/trace.h
> @@ -941,11 +941,6 @@ static inline int ftrace_graph_addr(struct ftrace_graph_ent *trace)
>  
>  	preempt_disable_notrace();
>  
> -	if (ftrace_hash_empty(ftrace_graph_hash)) {
> -		ret = 1;
> -		goto out;
> -	}
> -
Sorry, This remove is wrong. Will update change.

>  	if (ftrace_lookup_ip(ftrace_graph_hash, addr)) {
>  
>  		/*
> @@ -967,7 +962,6 @@ static inline int ftrace_graph_addr(struct ftrace_graph_ent *trace)
>  		ret = 1;
>  	}
>  
> -out:
>  	preempt_enable_notrace();
>  	return ret;
>  }
> -- 
> 2.20.1
> 

-- 
Cheers,
Changbin Du

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-09-09  0:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-08 12:05 [PATCH] ftrace: simplify ftrace hash lookup code Changbin Du
2019-09-09  0:05 ` Changbin Du

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome