From: Wei Yang Date: Mon, 31 Aug 2020 03:11:00 +0000 (+0800) Subject: ftrace: Use fls() to get the bits for dup_hash() X-Git-Tag: iomap-folio-5.17-old~2952^2~19 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=59e65b3358f44d4d0134eca3b6c269f359f21cd5;p=users%2Fwilly%2Flinux.git ftrace: Use fls() to get the bits for dup_hash() 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 Signed-off-by: Steven Rostedt (VMware) --- diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 123d520b9261..5633d37d8806 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)