Skip to content

Commit

Permalink
ftrace: Simplify the hash calculation
Browse files Browse the repository at this point in the history
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: Steven Rostedt (VMware) <rostedt@goodmis.org>
  • Loading branch information
Steven Rostedt (VMware) committed Oct 8, 2020
1 parent 59e65b3 commit be49313
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions kernel/trace/ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -1368,11 +1368,10 @@ static struct ftrace_hash *dup_hash(struct ftrace_hash *src, int size)
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);
if (bits)
bits--;
bits = fls(size / 2);

/* Don't allocate too much */
if (bits > FTRACE_HASH_MAX_BITS)
Expand Down

0 comments on commit be49313

Please sign in to comment.