Skip to content

Commit

Permalink
ftrace: Use fls() to get the bits for dup_hash()
Browse files Browse the repository at this point in the history
The effect here is to get the number of bits, lets use fls() to do
this job.

Link: https://lkml.kernel.org/r/20200831031104.23322-3-richard.weiyang@linux.alibaba.com

Signed-off-by: Wei Yang <richard.weiyang@linux.alibaba.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
  • Loading branch information
Wei Yang authored and Steven Rostedt (VMware) committed Oct 8, 2020
1 parent 8db4d6b commit 59e65b3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions kernel/trace/ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 59e65b3

Please sign in to comment.