DPDK-dev Archive on lore.kernel.org
 help / color / Atom feed
* [dpdk-dev] [PATCH] eal/stack: fix 'pointer-sign' warning
@ 2019-06-14 16:54 Phil Yang
  2019-06-14 19:49 ` Eads, Gage
  2019-06-17  7:41 ` [dpdk-dev] [PATCH v2] " Phil Yang
  0 siblings, 2 replies; 6+ messages in thread
From: Phil Yang @ 2019-06-14 16:54 UTC (permalink / raw)
  To: dev; +Cc: nd, gage.eads, honnappa.nagarahalli, gavin.hu, phil.yang

clang raise 'pointer-sign' warnings in __atomic_compare_exchange
when passing 'uint64_t *' to parameter of type 'int64_t *' converts
between pointers to integer types with different sign.

Fixes: 7e6e609939a8 ("stack: add C11 atomic implementation")

Signed-off-by: Phil Yang <phil.yang@arm.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>

---
 lib/librte_stack/rte_stack_lf_c11.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_stack/rte_stack_lf_c11.h b/lib/librte_stack/rte_stack_lf_c11.h
index a316e9a..e3b9eff 100644
--- a/lib/librte_stack/rte_stack_lf_c11.h
+++ b/lib/librte_stack/rte_stack_lf_c11.h
@@ -97,7 +97,7 @@ __rte_stack_lf_pop_elems(struct rte_stack_lf_list *list,
 	return NULL;
 #else
 	struct rte_stack_lf_head old_head;
-	uint64_t len;
+	int64_t len;
 	int success;
 
 	/* Reserve num elements, if available */
-- 
2.7.4


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH] eal/stack: fix 'pointer-sign' warning
  2019-06-14 16:54 [dpdk-dev] [PATCH] eal/stack: fix 'pointer-sign' warning Phil Yang
@ 2019-06-14 19:49 ` Eads, Gage
  2019-06-17  7:49   ` Phil Yang (Arm Technology China)
  2019-06-17  7:41 ` [dpdk-dev] [PATCH v2] " Phil Yang
  1 sibling, 1 reply; 6+ messages in thread
From: Eads, Gage @ 2019-06-14 19:49 UTC (permalink / raw)
  To: Phil Yang, dev; +Cc: nd, honnappa.nagarahalli, gavin.hu

> clang raise 'pointer-sign' warnings in __atomic_compare_exchange when
> passing 'uint64_t *' to parameter of type 'int64_t *' converts between
> pointers to integer types with different sign.
> 
> Fixes: 7e6e609939a8 ("stack: add C11 atomic implementation")
> 
> Signed-off-by: Phil Yang <phil.yang@arm.com>
> Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
> 
> ---
>  lib/librte_stack/rte_stack_lf_c11.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/librte_stack/rte_stack_lf_c11.h
> b/lib/librte_stack/rte_stack_lf_c11.h
> index a316e9a..e3b9eff 100644
> --- a/lib/librte_stack/rte_stack_lf_c11.h
> +++ b/lib/librte_stack/rte_stack_lf_c11.h
> @@ -97,7 +97,7 @@ __rte_stack_lf_pop_elems(struct rte_stack_lf_list *list,
>  	return NULL;
>  #else
>  	struct rte_stack_lf_head old_head;
> -	uint64_t len;
> +	int64_t len;

This works, but I'd prefer to keep 'len' unsigned. How about changing the definition of 'len' in struct rte_stack_lf_list to uint64_t, and in rte_stack_lf_generic.h casting it to rte_atomic64_t* when its address is passed to the rte_atomic64_...() functions?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [dpdk-dev] [PATCH v2] eal/stack: fix 'pointer-sign' warning
  2019-06-14 16:54 [dpdk-dev] [PATCH] eal/stack: fix 'pointer-sign' warning Phil Yang
  2019-06-14 19:49 ` Eads, Gage
@ 2019-06-17  7:41 ` " Phil Yang
  2019-06-18 15:43   ` Eads, Gage
  1 sibling, 1 reply; 6+ messages in thread
From: Phil Yang @ 2019-06-17  7:41 UTC (permalink / raw)
  To: dev; +Cc: nd, gage.eads, honnappa.nagarahalli, gavin.hu, phil.yang

clang raise 'pointer-sign' warnings in __atomic_compare_exchange
when passing 'uint64_t *' to parameter of type 'int64_t *' converts
between pointers to integer types with different sign.

Fixes: 7e6e609939a8 ("stack: add C11 atomic implementation")

Suggested-by: Gage Eads <gage.eads@intel.com>
Signed-off-by: Phil Yang <phil.yang@arm.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Reviewed-by: Gavin Hu <gavin.hu@arm.com>

---
 lib/librte_stack/rte_stack.h            | 2 +-
 lib/librte_stack/rte_stack_lf_c11.h     | 8 ++++----
 lib/librte_stack/rte_stack_lf_generic.h | 7 ++++---
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/lib/librte_stack/rte_stack.h b/lib/librte_stack/rte_stack.h
index fe048f0..93c360c 100644
--- a/lib/librte_stack/rte_stack.h
+++ b/lib/librte_stack/rte_stack.h
@@ -47,7 +47,7 @@ struct rte_stack_lf_list {
 	/** List head */
 	struct rte_stack_lf_head head __rte_aligned(16);
 	/** List len */
-	rte_atomic64_t len;
+	uint64_t len;
 };
 
 /* Structure containing two lock-free LIFO lists: the stack itself and a list
diff --git a/lib/librte_stack/rte_stack_lf_c11.h b/lib/librte_stack/rte_stack_lf_c11.h
index a316e9a..3d677ae 100644
--- a/lib/librte_stack/rte_stack_lf_c11.h
+++ b/lib/librte_stack/rte_stack_lf_c11.h
@@ -26,7 +26,7 @@ __rte_stack_lf_count(struct rte_stack *s)
 	 * elements. If the mempool is near-empty to the point that this is a
 	 * concern, the user should consider increasing the mempool size.
 	 */
-	return (unsigned int)__atomic_load_n(&s->stack_lf.used.len.cnt,
+	return (unsigned int)__atomic_load_n(&s->stack_lf.used.len,
 					     __ATOMIC_RELAXED);
 }
 
@@ -78,7 +78,7 @@ __rte_stack_lf_push_elems(struct rte_stack_lf_list *list,
 	/* Ensure the stack modifications are not reordered with respect
 	 * to the LIFO len update.
 	 */
-	__atomic_add_fetch(&list->len.cnt, num, __ATOMIC_RELEASE);
+	__atomic_add_fetch(&list->len, num, __ATOMIC_RELEASE);
 #endif
 }
 
@@ -101,7 +101,7 @@ __rte_stack_lf_pop_elems(struct rte_stack_lf_list *list,
 	int success;
 
 	/* Reserve num elements, if available */
-	len = __atomic_load_n(&list->len.cnt, __ATOMIC_ACQUIRE);
+	len = __atomic_load_n(&list->len, __ATOMIC_ACQUIRE);
 
 	while (1) {
 		/* Does the list contain enough elements? */
@@ -109,7 +109,7 @@ __rte_stack_lf_pop_elems(struct rte_stack_lf_list *list,
 			return NULL;
 
 		/* len is updated on failure */
-		if (__atomic_compare_exchange_n(&list->len.cnt,
+		if (__atomic_compare_exchange_n(&list->len,
 						&len, len - num,
 						0, __ATOMIC_ACQUIRE,
 						__ATOMIC_ACQUIRE))
diff --git a/lib/librte_stack/rte_stack_lf_generic.h b/lib/librte_stack/rte_stack_lf_generic.h
index 1191406..3182151 100644
--- a/lib/librte_stack/rte_stack_lf_generic.h
+++ b/lib/librte_stack/rte_stack_lf_generic.h
@@ -26,7 +26,8 @@ __rte_stack_lf_count(struct rte_stack *s)
 	 * elements. If the mempool is near-empty to the point that this is a
 	 * concern, the user should consider increasing the mempool size.
 	 */
-	return (unsigned int)rte_atomic64_read(&s->stack_lf.used.len);
+	return (unsigned int)rte_atomic64_read((rte_atomic64_t *)
+			&s->stack_lf.used.len);
 }
 
 static __rte_always_inline void
@@ -73,7 +74,7 @@ __rte_stack_lf_push_elems(struct rte_stack_lf_list *list,
 				__ATOMIC_RELAXED);
 	} while (success == 0);
 
-	rte_atomic64_add(&list->len, num);
+	rte_atomic64_add((rte_atomic64_t *)&list->len, num);
 #endif
 }
 
@@ -96,7 +97,7 @@ __rte_stack_lf_pop_elems(struct rte_stack_lf_list *list,
 
 	/* Reserve num elements, if available */
 	while (1) {
-		uint64_t len = rte_atomic64_read(&list->len);
+		uint64_t len = rte_atomic64_read((rte_atomic64_t *)&list->len);
 
 		/* Does the list contain enough elements? */
 		if (unlikely(len < num))
-- 
2.7.4


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH] eal/stack: fix 'pointer-sign' warning
  2019-06-14 19:49 ` Eads, Gage
@ 2019-06-17  7:49   ` Phil Yang (Arm Technology China)
  0 siblings, 0 replies; 6+ messages in thread
From: Phil Yang (Arm Technology China) @ 2019-06-17  7:49 UTC (permalink / raw)
  To: Eads, Gage, dev
  Cc: nd, Honnappa Nagarahalli, Gavin Hu (Arm Technology China), nd

> -----Original Message-----
> From: Eads, Gage <gage.eads@intel.com>
> Sent: Saturday, June 15, 2019 3:50 AM
> To: Phil Yang (Arm Technology China) <Phil.Yang@arm.com>; dev@dpdk.org
> Cc: nd <nd@arm.com>; Honnappa Nagarahalli
> <Honnappa.Nagarahalli@arm.com>; Gavin Hu (Arm Technology China)
> <Gavin.Hu@arm.com>
> Subject: RE: [PATCH] eal/stack: fix 'pointer-sign' warning
> 
> > clang raise 'pointer-sign' warnings in __atomic_compare_exchange when
> > passing 'uint64_t *' to parameter of type 'int64_t *' converts between
> > pointers to integer types with different sign.
> >
> > Fixes: 7e6e609939a8 ("stack: add C11 atomic implementation")
> >
> > Signed-off-by: Phil Yang <phil.yang@arm.com>
> > Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
> >
> > ---
> >  lib/librte_stack/rte_stack_lf_c11.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/lib/librte_stack/rte_stack_lf_c11.h
> > b/lib/librte_stack/rte_stack_lf_c11.h
> > index a316e9a..e3b9eff 100644
> > --- a/lib/librte_stack/rte_stack_lf_c11.h
> > +++ b/lib/librte_stack/rte_stack_lf_c11.h
> > @@ -97,7 +97,7 @@ __rte_stack_lf_pop_elems(struct rte_stack_lf_list
> *list,
> >  	return NULL;
> >  #else
> >  	struct rte_stack_lf_head old_head;
> > -	uint64_t len;
> > +	int64_t len;
> 
> This works, but I'd prefer to keep 'len' unsigned. How about changing the
> definition of 'len' in struct rte_stack_lf_list to uint64_t, and in
> rte_stack_lf_generic.h casting it to rte_atomic64_t* when its address is
> passed to the rte_atomic64_...() functions?

It is better I think. I have upstreamed the v2, please review it. 

Thanks,
Phil

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH v2] eal/stack: fix 'pointer-sign' warning
  2019-06-17  7:41 ` [dpdk-dev] [PATCH v2] " Phil Yang
@ 2019-06-18 15:43   ` Eads, Gage
  2019-06-27 16:04     ` Thomas Monjalon
  0 siblings, 1 reply; 6+ messages in thread
From: Eads, Gage @ 2019-06-18 15:43 UTC (permalink / raw)
  To: Phil Yang, dev; +Cc: nd, honnappa.nagarahalli, gavin.hu

> clang raise 'pointer-sign' warnings in __atomic_compare_exchange when
> passing 'uint64_t *' to parameter of type 'int64_t *' converts between
> pointers to integer types with different sign.
> 
> Fixes: 7e6e609939a8 ("stack: add C11 atomic implementation")
> 
> Suggested-by: Gage Eads <gage.eads@intel.com>
> Signed-off-by: Phil Yang <phil.yang@arm.com>
> Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
> Reviewed-by: Gavin Hu <gavin.hu@arm.com>

Acked-By: Gage Eads <gage.eads@intel.com>

Thanks,
Gage

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH v2] eal/stack: fix 'pointer-sign' warning
  2019-06-18 15:43   ` Eads, Gage
@ 2019-06-27 16:04     ` Thomas Monjalon
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Monjalon @ 2019-06-27 16:04 UTC (permalink / raw)
  To: Phil Yang; +Cc: dev, Eads, Gage, nd, honnappa.nagarahalli, gavin.hu

Title changed to "stack: fix sign of list length"
(it does not belong to EAL)

18/06/2019 17:43, Eads, Gage:
> > clang raise 'pointer-sign' warnings in __atomic_compare_exchange when
> > passing 'uint64_t *' to parameter of type 'int64_t *' converts between
> > pointers to integer types with different sign.
> > 
> > Fixes: 7e6e609939a8 ("stack: add C11 atomic implementation")

Cc: stable@dpdk.org

> > Suggested-by: Gage Eads <gage.eads@intel.com>
> > Signed-off-by: Phil Yang <phil.yang@arm.com>
> > Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
> > Reviewed-by: Gavin Hu <gavin.hu@arm.com>
> 
> Acked-By: Gage Eads <gage.eads@intel.com>

Applied, thanks




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, back to index

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-14 16:54 [dpdk-dev] [PATCH] eal/stack: fix 'pointer-sign' warning Phil Yang
2019-06-14 19:49 ` Eads, Gage
2019-06-17  7:49   ` Phil Yang (Arm Technology China)
2019-06-17  7:41 ` [dpdk-dev] [PATCH v2] " Phil Yang
2019-06-18 15:43   ` Eads, Gage
2019-06-27 16:04     ` Thomas Monjalon

DPDK-dev Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/dpdk-dev/0 dpdk-dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dpdk-dev dpdk-dev/ https://lore.kernel.org/dpdk-dev \
		dev@dpdk.org dpdk-dev@archiver.kernel.org
	public-inbox-index dpdk-dev


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/ public-inbox