From: Steven Rostedt <rostedt@goodmis.org>
To: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
Cc: linux-trace-devel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] trace-filter: Change the hashing function used when filtering
Date: Wed, 20 Jun 2018 11:21:13 -0400 [thread overview]
Message-ID: <20180620112113.67dbdb4f@gandalf.local.home> (raw)
In-Reply-To: <20180619132259.21387-2-y.karadz@gmail.com>
On Tue, 19 Jun 2018 16:22:59 +0300
"Yordan Karadzhov (VMware)" <y.karadz@gmail.com> wrote:
> diff --git a/kernel-shark/include/trace-filter-hash.h b/kernel-shark/include/trace-filter-hash.h
> index 5cc39dc..98c9ab3 100644
> --- a/kernel-shark/include/trace-filter-hash.h
> +++ b/kernel-shark/include/trace-filter-hash.h
> @@ -20,7 +20,7 @@
> #ifndef _TRACE_FILTER_HASH_H
> #define _TRACE_FILTER_HASH_H
>
> -#include "trace-hash-local.h"
> +#include <stdint.h>
>
> struct filter_id_item {
> struct filter_id_item *next;
> @@ -47,4 +47,39 @@ static inline int filter_task_count(struct filter_id *hash)
> return hash->count;
> }
>
> +/*
> + * 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)
> +{
> + /*
> + * Multiplicative hashing function.
> + * 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)
BTW, is there any reason to have these in the header file? Shouldn't
they be in a C file?
The reason I ask is because this is going to be in a more public file,
and I need to rename the functions for namespace reasons. These are
someone out of place for a library header.
-- Steve
> +{
> + /*
> + * Multiplicative hashing function.
> + * Multiplication by the Prime number, closest to the golden
> + * ratio of 2^32.
> + */
> + return val * UINT32_C(2654435761);
> +}
> +
next prev parent reply other threads:[~2018-06-20 15:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-19 13:22 [PATCH v2 1/2] trace-filter: Change the naming convention used in trace-filter-hash Yordan Karadzhov (VMware)
2018-06-19 13:22 ` [PATCH v2 2/2] trace-filter: Change the hashing function used when filtering Yordan Karadzhov (VMware)
2018-06-19 22:54 ` Steven Rostedt
2018-06-20 11:48 ` Yordan Karadzhov (VMware)
2018-06-20 15:21 ` Steven Rostedt [this message]
2018-06-20 18:04 ` Yordan Karadzhov
2018-06-20 18:13 ` 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=20180620112113.67dbdb4f@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=linux-trace-devel@vger.kernel.org \
--cc=y.karadz@gmail.com \
/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).