linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Timofey Titovets <nefelim4ag@gmail.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: linux-mm@kvack.org, Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 1/2] xxHash: create arch dependent 32/64-bit xxhash()
Date: Mon, 25 Sep 2017 19:17:48 +0300	[thread overview]
Message-ID: <CAGqmi77wkSyHQiVj23Gfqw1drYi52f72LXVP6Do4Aje+Rq0apg@mail.gmail.com> (raw)
In-Reply-To: <20170925145932.GA17029@bombadil.infradead.org>

2017-09-25 17:59 GMT+03:00 Matthew Wilcox <willy@infradead.org>:
> On Fri, Sep 22, 2017 at 02:18:17AM +0300, Timofey Titovets wrote:
>> diff --git a/include/linux/xxhash.h b/include/linux/xxhash.h
>> index 9e1f42cb57e9..195a0ae10e9b 100644
>> --- a/include/linux/xxhash.h
>> +++ b/include/linux/xxhash.h
>> @@ -76,6 +76,7 @@
>>  #define XXHASH_H
>>
>>  #include <linux/types.h>
>> +#include <linux/bitops.h> /* BITS_PER_LONG */
>>
>>  /*-****************************
>>   * Simple Hash Functions
>
> Huh?  linux/types.h already brings in BITS_PER_LONG.  Look:
>
> linux/types.h
>   uapi/linux/types.h
>   uapi/asm/types.h
>   uapi/asm-generic/types.h
>   uapi/asm-generic/int-ll64.h
>   asm/bitsperlong.h

Will fix that, thanks.

>> @@ -107,6 +108,29 @@ uint32_t xxh32(const void *input, size_t length, uint32_t seed);
>>   */
>>  uint64_t xxh64(const void *input, size_t length, uint64_t seed);
>>
>> +#if BITS_PER_LONG == 64
>> +typedef      u64     xxhash_t;
>> +#else
>> +typedef      u32     xxhash_t;
>> +#endif
>
> This is a funny way to spell 'unsigned long' ...

i'm just want some strict and obvious types for in memory hashing.
And that just looks pretty for my eye (IMHO),
I will replace that with 'unsigned long' of course and drop xxhash_t completely,
as you find that unacceptable.

>> +/**
>> + * xxhash() - calculate 32/64-bit hash based on cpu word size
>> + *
>> + * @input:  The data to hash.
>> + * @length: The length of the data to hash.
>> + * @seed:   The seed can be used to alter the result predictably.
>> + *
>> + * This function always work as xxh32() for 32-bit systems
>> + * and as xxh64() for 64-bit systems.
>> + * Because result depends on cpu work size,
>> + * the main proporse of that function is for  in memory hashing.
>> + *
>> + * Return:  32/64-bit hash of the data.
>> + */
>> +
>
>> +xxhash_t xxhash(const void *input, size_t length, uint64_t seed)
>> +{
>> +#if BITS_PER_LONG == 64
>> +     return xxh64(input, length, seed);
>> +#else
>> +     return xxh32(input, length, seed);
>> +#endif
>> +}
>
> Let's move that to the header file and make it a static inline.  That way
> it doesn't need to be an EXPORT_SYMBOL.

Agreed, thanks.

> Also, I think the kerneldoc could do with a bit of work.  Try this:
>
> /**
>  * xxhash() - calculate wordsize hash of the input with a given seed
>  * @input:  The data to hash.
>  * @length: The length of the data to hash.
>  * @seed:   The seed can be used to alter the result predictably.
>  *
>  * If the hash does not need to be comparable between machines with
>  * different word sizes, this function will call whichever of xxh32()
>  * or xxh64() is faster.
>  *
>  * Return:  wordsize hash of the data.
>  */

Replace with your version, thanks.

> static inline
> unsigned long xxhash(const void *input, size_t length, unsigned long seed)
> {
> #if BITS_PER_LONG == 64
>         return xxh64(input, length, seed);
> #else
>         return xxh32(input, length, seed);
> #endif
> }


-- 
Have a nice day,
Timofey.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2017-09-25 16:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-21 23:18 [PATCH v2 0/2] KSM: Replace jhash2 with xxhash Timofey Titovets
2017-09-21 23:18 ` [PATCH v2 1/2] xxHash: create arch dependent 32/64-bit xxhash() Timofey Titovets
2017-09-25 14:59   ` Matthew Wilcox
2017-09-25 16:17     ` Timofey Titovets [this message]
2017-09-21 23:18 ` [PATCH v2 2/2] KSM: Replace jhash2 with xxhash Timofey Titovets
2017-09-22  9:52 [PATCH v2 0/2] " Timofey Titovets
2017-09-22  9:52 ` [PATCH v2 1/2] xxHash: create arch dependent 32/64-bit xxhash() Timofey Titovets

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=CAGqmi77wkSyHQiVj23Gfqw1drYi52f72LXVP6Do4Aje+Rq0apg@mail.gmail.com \
    --to=nefelim4ag@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=willy@infradead.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