[v2,2/4] test/hash: change multiwriter test to use jhash

Message ID 1540404570-102126-3-git-send-email-yipeng1.wang@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series hash: improve multiple places |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Wang, Yipeng1 Oct. 24, 2018, 6:09 p.m. UTC
  With sequential key, the test will cover more corner
cases with jhash instead of crc hash, since jhash
generates more random hash pattern on sequential key.
It is useful for functional verification.

Signed-off-by: Yipeng Wang <yipeng1.wang@intel.com>
---
 test/test/test_hash_multiwriter.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
  

Comments

Bruce Richardson Oct. 25, 2018, 9:32 a.m. UTC | #1
On Wed, Oct 24, 2018 at 11:09:28AM -0700, Yipeng Wang wrote:
> With sequential key, the test will cover more corner
> cases with jhash instead of crc hash, since jhash
> generates more random hash pattern on sequential key.
> It is useful for functional verification.
> 
> Signed-off-by: Yipeng Wang <yipeng1.wang@intel.com>
> ---
>  test/test/test_hash_multiwriter.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/test/test/test_hash_multiwriter.c b/test/test/test_hash_multiwriter.c
> index 6a3eb10..456bc5f 100644
> --- a/test/test/test_hash_multiwriter.c
> +++ b/test/test/test_hash_multiwriter.c
> @@ -12,6 +12,7 @@
>  #include <rte_malloc.h>
>  #include <rte_random.h>
>  #include <rte_spinlock.h>
> +#include <rte_jhash.h>
>  
>  #include "test.h"
>  
> @@ -31,6 +32,9 @@
>  
>  #define RTE_APP_TEST_HASH_MULTIWRITER_FAILED 0
>  
> +/* Use jhash or crc hash */
> +#define USE_JHASH 1
> +
>  struct {
>  	uint32_t *keys;
>  	uint32_t *found;
> @@ -108,10 +112,14 @@ test_hash_multiwriter(void)
>  	struct rte_hash_parameters hash_params = {
>  		.entries = nb_entries,
>  		.key_len = sizeof(uint32_t),
> -		.hash_func = rte_hash_crc,
>  		.hash_func_init_val = 0,
>  		.socket_id = rte_socket_id(),
>  	};
> +	if (USE_JHASH)
> +		hash_params.hash_func = rte_jhash;
> +	else
> +		hash_params.hash_func = rte_hash_crc;
> +
>  	if (use_htm)
>  		hash_params.extra_flag =
>  			RTE_HASH_EXTRA_FLAGS_TRANS_MEM_SUPPORT
> -- 
As I commented on v1, rather than having a macro at the top hard-coded to
jhash, why not just do a straight replacement of crc to jhash in the
structure definition. Since changing the hash function will involve editing
the source code anyway, I see little point in using the macro at the top -
especially since there is no indication to the user what effect removing it
or changing it to zero has.

/Bruce
  

Patch

diff --git a/test/test/test_hash_multiwriter.c b/test/test/test_hash_multiwriter.c
index 6a3eb10..456bc5f 100644
--- a/test/test/test_hash_multiwriter.c
+++ b/test/test/test_hash_multiwriter.c
@@ -12,6 +12,7 @@ 
 #include <rte_malloc.h>
 #include <rte_random.h>
 #include <rte_spinlock.h>
+#include <rte_jhash.h>
 
 #include "test.h"
 
@@ -31,6 +32,9 @@ 
 
 #define RTE_APP_TEST_HASH_MULTIWRITER_FAILED 0
 
+/* Use jhash or crc hash */
+#define USE_JHASH 1
+
 struct {
 	uint32_t *keys;
 	uint32_t *found;
@@ -108,10 +112,14 @@  test_hash_multiwriter(void)
 	struct rte_hash_parameters hash_params = {
 		.entries = nb_entries,
 		.key_len = sizeof(uint32_t),
-		.hash_func = rte_hash_crc,
 		.hash_func_init_val = 0,
 		.socket_id = rte_socket_id(),
 	};
+	if (USE_JHASH)
+		hash_params.hash_func = rte_jhash;
+	else
+		hash_params.hash_func = rte_hash_crc;
+
 	if (use_htm)
 		hash_params.extra_flag =
 			RTE_HASH_EXTRA_FLAGS_TRANS_MEM_SUPPORT