DPDK CI discussions
 help / color / mirror / Atom feed
* CI test system not catching truncation bugs for 32-bit architectures?
       [not found]   ` <1699400300-22545-8-git-send-email-roretzla@linux.microsoft.com>
@ 2023-11-08  8:47     ` Morten Brørup
  0 siblings, 0 replies; only message in thread
From: Morten Brørup @ 2023-11-08  8:47 UTC (permalink / raw)
  To: dev, ci
  Cc: Bruce Richardson, Cristian Dumitrescu, David Hunt,
	Honnappa Nagarahalli, Ruifeng Wang, Sameh Gobriel,
	Vladimir Medvedkin, Yipeng Wang, Tyler Retzlaff

> From: Tyler Retzlaff [mailto:roretzla@linux.microsoft.com]
> Sent: Wednesday, 8 November 2023 00.38
> 
> Use rte_popcount64 instead of __builtin_popcountl where the argument
> type passed to the intrinsic was 64-bits.

Can someone please explain why our CI test system accepted passing a 64-bit value to __builtin_popcountl(unsigned long) when building for 32-bit architectures, where an unsigned long is 32 bit? The 32 most significant bits were blindly truncated here.

It looks like this patch also fixes a bug (which should have been caught by the CI system) for 32-bit architectures.

> 
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> ---
>  lib/hash/rte_cuckoo_hash.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/hash/rte_cuckoo_hash.c b/lib/hash/rte_cuckoo_hash.c
> index 19ee53a..ccdc3b9 100644
> --- a/lib/hash/rte_cuckoo_hash.c
> +++ b/lib/hash/rte_cuckoo_hash.c
> @@ -2357,7 +2357,7 @@ struct rte_hash *
>  	__rte_hash_lookup_bulk(h, keys, num_keys, positions, hit_mask,
> data);
> 
>  	/* Return number of hits */
> -	return __builtin_popcountl(*hit_mask);
> +	return rte_popcount64(*hit_mask);
>  }
> 
> 
> @@ -2474,7 +2474,7 @@ struct rte_hash *
>  			positions, hit_mask, data);
> 
>  	/* Return number of hits */
> -	return __builtin_popcountl(*hit_mask);
> +	return rte_popcount64(*hit_mask);
>  }
> 
>  int32_t
> --
> 1.8.3.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-11-08  8:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1698887132-5347-1-git-send-email-roretzla@linux.microsoft.com>
     [not found] ` <1699400300-22545-1-git-send-email-roretzla@linux.microsoft.com>
     [not found]   ` <1699400300-22545-8-git-send-email-roretzla@linux.microsoft.com>
2023-11-08  8:47     ` CI test system not catching truncation bugs for 32-bit architectures? Morten Brørup

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).