The effect here is to get the number of bits, lets use fls() to do
this job.

Signed-off-by: Wei Yang <[email protected]>
---
 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)

Reply via email to