Messages in this thread Patch in this message |  | | From | Wei Yang <> | Subject | [PATCH 2/6] ftrace: use fls() to get the bits for dup_hash() | Date | Mon, 31 Aug 2020 11:11:00 +0800 |
| |
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)
|  |