From: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
To: Greg Thelen <gthelen@google.com>, Steven Rostedt <rostedt@goodmis.org>
Cc: linux-trace-devel@vger.kernel.org
Subject: Re: [PATCH v2] trace-cmd: remove ununsed knuth_hash*() routines
Date: Mon, 1 Jul 2019 15:23:55 +0300 [thread overview]
Message-ID: <79567c76-868f-edef-de1b-dd3f62a66f6a@gmail.com> (raw)
In-Reply-To: <20190629062752.204113-1-gthelen@google.com>
On 29.06.19 г. 9:27 ч., Greg Thelen wrote:
> Neither 16-bit knuth_hash16() nor the 32-bit knuth_hash() are used.
> Delete them both.
>
> And rename the remaining function: knuth_hash8() => knuth_hash()
>
Thanks!
Reviewed-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
> Signed-off-by: Greg Thelen <gthelen@google.com>
> ---
> kernel-shark/src/libkshark.c | 12 +++++-----
> lib/trace-cmd/trace-filter-hash.c | 40 +++++++------------------------
> 2 files changed, 14 insertions(+), 38 deletions(-)
>
> diff --git a/kernel-shark/src/libkshark.c b/kernel-shark/src/libkshark.c
> index 0f0a1bab4d5c..d2764e813194 100644
> --- a/kernel-shark/src/libkshark.c
> +++ b/kernel-shark/src/libkshark.c
> @@ -252,13 +252,13 @@ void kshark_free(struct kshark_context *kshark_ctx)
> free(kshark_ctx);
> }
>
> -static inline uint8_t knuth_hash8(uint32_t val)
> +static inline uint8_t knuth_hash(uint32_t val)
> {
> /*
> - * Hashing functions, based on Donald E. Knuth's Multiplicative
> - * hashing. See The Art of Computer Programming (TAOCP).
> - * Multiplication by the Prime number, closest to the golden
> - * ratio of 2^8.
> + * Small table hashing function adapted from Donald E. Knuth's 32 bit
> + * multiplicative hash. See The Art of Computer Programming (TAOCP).
> + * Multiplication by the Prime number, closest to the golden ratio of
> + * 2^8.
> */
> return UINT8_C(val) * UINT8_C(157);
> }
> @@ -282,7 +282,7 @@ kshark_add_task(struct kshark_context *kshark_ctx, int pid)
> struct kshark_task_list *list;
> uint8_t key;
>
> - key = knuth_hash8(pid);
> + key = knuth_hash(pid);
> list = kshark_find_task(kshark_ctx, key, pid);
> if (list)
> return list;
> diff --git a/lib/trace-cmd/trace-filter-hash.c b/lib/trace-cmd/trace-filter-hash.c
> index 39b28790e0bc..45ca68c2959e 100644
> --- a/lib/trace-cmd/trace-filter-hash.c
> +++ b/lib/trace-cmd/trace-filter-hash.c
> @@ -14,45 +14,21 @@
>
> #define FILTER_HASH_SIZE 256
>
> -/*
> - * Hashing functions, based on Donald E. Knuth's Multiplicative hashing.
> - * See The Art of Computer Programming (TAOCP).
> - */
> -
> -static inline uint8_t knuth_hash8(uint32_t val)
> +static inline uint8_t knuth_hash(uint32_t val)
> {
> /*
> - * Multiplicative hashing function.
> - * Multiplication by the Prime number, closest to the golden
> - * ratio of 2^8.
> + * Small table hashing function adapted from Donald E. Knuth's 32 bit
> + * multiplicative hash. See The Art of Computer Programming (TAOCP).
> + * Multiplication by the Prime number, closest to the golden ratio of
> + * 2^8.
> */
> return UINT8_C(val) * UINT8_C(157);
> }
>
> -static inline uint16_t knuth_hash16(uint32_t val)
> -{
> - /*
> - * Multiplicative hashing function.
> - * Multiplication by the Prime number, closest to the golden
> - * ratio of 2^16.
> - */
> - return UINT16_C(val) * UINT16_C(40507);
> -}
> -
> -static inline uint32_t knuth_hash(uint32_t val)
> -{
> - /*
> - * Multiplicative hashing function.
> - * Multiplication by the Prime number, closest to the golden
> - * ratio of 2^32.
> - */
> - return val * UINT32_C(2654435761);
> -}
> -
> struct tracecmd_filter_id_item *
> tracecmd_filter_id_find(struct tracecmd_filter_id *hash, int id)
> {
> - int key = knuth_hash8(id);
> + int key = knuth_hash(id);
> struct tracecmd_filter_id_item *item = hash->hash[key];
>
> while (item) {
> @@ -66,7 +42,7 @@ tracecmd_filter_id_find(struct tracecmd_filter_id *hash, int id)
>
> void tracecmd_filter_id_add(struct tracecmd_filter_id *hash, int id)
> {
> - int key = knuth_hash8(id);
> + int key = knuth_hash(id);
> struct tracecmd_filter_id_item *item;
>
> item = calloc(1, sizeof(*item));
> @@ -81,7 +57,7 @@ void tracecmd_filter_id_add(struct tracecmd_filter_id *hash, int id)
>
> void tracecmd_filter_id_remove(struct tracecmd_filter_id *hash, int id)
> {
> - int key = knuth_hash8(id);
> + int key = knuth_hash(id);
> struct tracecmd_filter_id_item **next = &hash->hash[key];
> struct tracecmd_filter_id_item *item;
>
>
next prev parent reply other threads:[~2019-07-01 12:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-26 6:01 [PATCH] trace-cmd: remove ununsed knuth_hash*() routines Greg Thelen
2019-06-26 19:34 ` Steven Rostedt
2019-06-27 15:40 ` Yordan Karadzhov (VMware)
2019-06-27 16:15 ` Steven Rostedt
2019-06-28 15:55 ` Greg Thelen
2019-06-29 6:27 ` [PATCH v2] " Greg Thelen
2019-07-01 12:23 ` Yordan Karadzhov (VMware) [this message]
2019-07-05 13:31 ` 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=79567c76-868f-edef-de1b-dd3f62a66f6a@gmail.com \
--to=y.karadz@gmail.com \
--cc=gthelen@google.com \
--cc=linux-trace-devel@vger.kernel.org \
--cc=rostedt@goodmis.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;
as well as URLs for NNTP newsgroup(s).