lkml.org 
[lkml]   [2020]   [Aug]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/6] ftrace: use fls() to get the bits for dup_hash()
Date
The effect here is to get the number of bits, lets use fls() to do
this job.

Signed-off-by: Wei Yang <richard.weiyang@linux.alibaba.com>
---
kernel/trace/ftrace.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 12cb535769bc..9021e16fa079 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1370,8 +1370,9 @@ static struct ftrace_hash *dup_hash(struct ftrace_hash *src, int size)
/*
* Make the hash size about 1/2 the # found
*/
- for (size /= 2; size; size >>= 1)
- bits++;
+ bits = fls(size);
+ if (bits)
+ bits--;

/* Don't allocate too much */
if (bits > FTRACE_HASH_MAX_BITS)
--
2.20.1 (Apple Git-117)
\
 
 \ /
  Last update: 2020-08-31 05:12    [W:0.105 / U:27.164 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site