public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: [for-linus][PATCH 10/15] ftrace: Simplify the hash calculation
Date: Tue, 06 Oct 2020 10:34:56 -0400	[thread overview]
Message-ID: <20201006143512.202764346@goodmis.org> (raw)
In-Reply-To: 20201006143446.182666356@goodmis.org

From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

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>
---
 kernel/trace/ftrace.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 5633d37d8806..c51a91aea1fd 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -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)
-- 
2.28.0



  parent reply	other threads:[~2020-10-06 14:35 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-06 14:34 [for-linus][PATCH 00/15] tracing: Some final updates for 5.10 Steven Rostedt
2020-10-06 14:34 ` [for-linus][PATCH 01/15] ftrace: Fix some typos in comment Steven Rostedt
2020-10-06 14:34 ` [for-linus][PATCH 02/15] tracing: Change STR_VAR_MAX_LEN Steven Rostedt
2020-10-06 14:34 ` [for-linus][PATCH 03/15] tracing: Fix parse_synth_field() error handling Steven Rostedt
2020-10-06 14:34 ` [for-linus][PATCH 04/15] tracing: Save normal string variables Steven Rostedt
2020-10-06 14:34 ` [for-linus][PATCH 05/15] tracing: Add support for dynamic strings to synthetic events Steven Rostedt
2020-10-06 14:34 ` [for-linus][PATCH 06/15] tracing: Add README information for synthetic_events file Steven Rostedt
2020-10-06 14:34 ` [for-linus][PATCH 07/15] selftests/ftrace: Add test case for synthetic event dynamic strings Steven Rostedt
2020-10-06 14:34 ` [for-linus][PATCH 08/15] tracing: Change synthetic event string format to limit printed length Steven Rostedt
2020-10-06 14:34 ` [for-linus][PATCH 09/15] ftrace: Use fls() to get the bits for dup_hash() Steven Rostedt
2020-10-06 14:34 ` Steven Rostedt [this message]
2020-10-06 14:34 ` [for-linus][PATCH 11/15] ftrace: Simplify the dyn_ftrace->flags macro Steven Rostedt
2020-10-06 14:34 ` [for-linus][PATCH 12/15] ftrace: Simplify the calculation of page number for ftrace_page->records Steven Rostedt
2020-10-06 14:34 ` [for-linus][PATCH 13/15] ftrace: Format variable declarations of ftrace_allocate_records Steven Rostedt
2020-10-06 14:35 ` [for-linus][PATCH 14/15] ftrace: ftrace_global_list is renamed to ftrace_ops_list Steven Rostedt
2020-10-06 14:35 ` [for-linus][PATCH 15/15] tracing: Remove a pointless assignment Steven Rostedt
2020-10-06 15:01 ` [for-linus][PATCH 00/15] tracing: Some final updates for 5.10 Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201006143512.202764346@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox