ftrace: Simplify the hash calculation

No need to add a check to subtract the number of bits if bits is zero after
fls(). Just divide the size by two before calling it. This does give the
same answer for size of 0 and 1, but that's fine.
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
parent 59e65b33
...@@ -1368,11 +1368,10 @@ static struct ftrace_hash *dup_hash(struct ftrace_hash *src, int size) ...@@ -1368,11 +1368,10 @@ static struct ftrace_hash *dup_hash(struct ftrace_hash *src, int size)
int i; int i;
/* /*
* Make the hash size about 1/2 the # found * Use around half the size (max bit of it), but
* a minimum of 2 is fine (as size of 0 or 1 both give 1 for bits).
*/ */
bits = fls(size); bits = fls(size / 2);
if (bits)
bits--;
/* Don't allocate too much */ /* Don't allocate too much */
if (bits > FTRACE_HASH_MAX_BITS) if (bits > FTRACE_HASH_MAX_BITS)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment