All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] examples/l3fwd: fix aliasing in port grouping
@ 2017-11-03 10:43 Guduri Prathyusha
  2017-11-06  4:29 ` Jerin Jacob
  0 siblings, 1 reply; 4+ messages in thread
From: Guduri Prathyusha @ 2017-11-03 10:43 UTC (permalink / raw)
  To: tomasz.kantecki
  Cc: Jianbo.Liu, guduriprathyusha, konstantin.ananyev, dev, Guduri Prathyusha

With -f-strict-aliasing enabled by default from -O2, gcc > 5.x gives
undefined behavior in port_groupx4 in ARM. 'pn' and 'pnum' are
two different pointers pointing to same chunk of memory and
with -f-strict-aliasing the pointers are assumed to be pointing to
different memory and compiler reorders instructions that depend on
pnum and pn. This breaks port grouping algorithm.

This patch eliminates the above problem by introducing a compiler
barrier between the instructions that depend on pnum, pn and lp.

Fixes: 569b290cdb36 ("examples/l3fwd: add NEON implementation")

Signed-off-by: Guduri Prathyusha <gprathyusha@caviumnetworks.com>
---
 examples/l3fwd/l3fwd_neon.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/examples/l3fwd/l3fwd_neon.h b/examples/l3fwd/l3fwd_neon.h
index 4bc161394..b319b5a92 100644
--- a/examples/l3fwd/l3fwd_neon.h
+++ b/examples/l3fwd/l3fwd_neon.h
@@ -114,6 +114,7 @@ port_groupx4(uint16_t pn[FWDSTEP + 1], uint16_t *lp, uint16x8_t dp1,
 
 	/* update last port counter. */
 	lp[0] += gptbl[v].lpv;
+	rte_compiler_barrier();
 
 	/* if dest port value has changed. */
 	if (v != GRPMSK) {
-- 
2.14.1

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

* Re: [PATCH v2] examples/l3fwd: fix aliasing in port grouping
  2017-11-03 10:43 [PATCH v2] examples/l3fwd: fix aliasing in port grouping Guduri Prathyusha
@ 2017-11-06  4:29 ` Jerin Jacob
  2017-11-06  8:18   ` Jianbo Liu
  0 siblings, 1 reply; 4+ messages in thread
From: Jerin Jacob @ 2017-11-06  4:29 UTC (permalink / raw)
  To: Guduri Prathyusha
  Cc: tomasz.kantecki, Jianbo.Liu, guduriprathyusha, konstantin.ananyev, dev

-----Original Message-----
> Date: Fri,  3 Nov 2017 16:13:51 +0530
> From: Guduri Prathyusha <gprathyusha@caviumnetworks.com>
> To: tomasz.kantecki@intel.com
> CC: Jianbo.Liu@arm.com, guduriprathyusha@gmail.com,
>  konstantin.ananyev@intel.com, dev@dpdk.org, Guduri Prathyusha
>  <gprathyusha@caviumnetworks.com>
> Subject: [dpdk-dev] [PATCH v2] examples/l3fwd: fix aliasing in port grouping
> X-Mailer: git-send-email 2.14.1
> 
> With -f-strict-aliasing enabled by default from -O2, gcc > 5.x gives
> undefined behavior in port_groupx4 in ARM. 'pn' and 'pnum' are
> two different pointers pointing to same chunk of memory and
> with -f-strict-aliasing the pointers are assumed to be pointing to
> different memory and compiler reorders instructions that depend on
> pnum and pn. This breaks port grouping algorithm.
> 
> This patch eliminates the above problem by introducing a compiler
> barrier between the instructions that depend on pnum, pn and lp.
> 
> Fixes: 569b290cdb36 ("examples/l3fwd: add NEON implementation")
> 
> Signed-off-by: Guduri Prathyusha <gprathyusha@caviumnetworks.com>

Acked-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>

> ---
>  examples/l3fwd/l3fwd_neon.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/examples/l3fwd/l3fwd_neon.h b/examples/l3fwd/l3fwd_neon.h
> index 4bc161394..b319b5a92 100644
> --- a/examples/l3fwd/l3fwd_neon.h
> +++ b/examples/l3fwd/l3fwd_neon.h
> @@ -114,6 +114,7 @@ port_groupx4(uint16_t pn[FWDSTEP + 1], uint16_t *lp, uint16x8_t dp1,
>  
>  	/* update last port counter. */
>  	lp[0] += gptbl[v].lpv;
> +	rte_compiler_barrier();
>  
>  	/* if dest port value has changed. */
>  	if (v != GRPMSK) {
> -- 
> 2.14.1
> 

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

* Re: [PATCH v2] examples/l3fwd: fix aliasing in port grouping
  2017-11-06  4:29 ` Jerin Jacob
@ 2017-11-06  8:18   ` Jianbo Liu
  2017-11-07  8:12     ` Ferruh Yigit
  0 siblings, 1 reply; 4+ messages in thread
From: Jianbo Liu @ 2017-11-06  8:18 UTC (permalink / raw)
  To: Jerin Jacob
  Cc: Guduri Prathyusha, tomasz.kantecki, guduriprathyusha,
	konstantin.ananyev, dev

The 11/06/2017 09:59, Jerin Jacob wrote:
> -----Original Message-----
> > Date: Fri,  3 Nov 2017 16:13:51 +0530
> > From: Guduri Prathyusha <gprathyusha@caviumnetworks.com>
> > To: tomasz.kantecki@intel.com
> > CC: Jianbo.Liu@arm.com, guduriprathyusha@gmail.com,
> >  konstantin.ananyev@intel.com, dev@dpdk.org, Guduri Prathyusha
> >  <gprathyusha@caviumnetworks.com>
> > Subject: [dpdk-dev] [PATCH v2] examples/l3fwd: fix aliasing in port grouping
> > X-Mailer: git-send-email 2.14.1
> >
> > With -f-strict-aliasing enabled by default from -O2, gcc > 5.x gives
> > undefined behavior in port_groupx4 in ARM. 'pn' and 'pnum' are
> > two different pointers pointing to same chunk of memory and
> > with -f-strict-aliasing the pointers are assumed to be pointing to
> > different memory and compiler reorders instructions that depend on
> > pnum and pn. This breaks port grouping algorithm.
> >
> > This patch eliminates the above problem by introducing a compiler
> > barrier between the instructions that depend on pnum, pn and lp.
> >
> > Fixes: 569b290cdb36 ("examples/l3fwd: add NEON implementation")
> >
> > Signed-off-by: Guduri Prathyusha <gprathyusha@caviumnetworks.com>
>
> Acked-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
>

Acked-by: Jianbo Liu <jianbo.liu@arm.com>
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

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

* Re: [PATCH v2] examples/l3fwd: fix aliasing in port grouping
  2017-11-06  8:18   ` Jianbo Liu
@ 2017-11-07  8:12     ` Ferruh Yigit
  0 siblings, 0 replies; 4+ messages in thread
From: Ferruh Yigit @ 2017-11-07  8:12 UTC (permalink / raw)
  To: Jianbo Liu, Jerin Jacob
  Cc: Guduri Prathyusha, tomasz.kantecki, guduriprathyusha,
	konstantin.ananyev, dev

On 11/6/2017 12:18 AM, Jianbo Liu wrote:
> The 11/06/2017 09:59, Jerin Jacob wrote:
>> -----Original Message-----
>>> Date: Fri,  3 Nov 2017 16:13:51 +0530
>>> From: Guduri Prathyusha <gprathyusha@caviumnetworks.com>
>>> To: tomasz.kantecki@intel.com
>>> CC: Jianbo.Liu@arm.com, guduriprathyusha@gmail.com,
>>>  konstantin.ananyev@intel.com, dev@dpdk.org, Guduri Prathyusha
>>>  <gprathyusha@caviumnetworks.com>
>>> Subject: [dpdk-dev] [PATCH v2] examples/l3fwd: fix aliasing in port grouping
>>> X-Mailer: git-send-email 2.14.1
>>>
>>> With -f-strict-aliasing enabled by default from -O2, gcc > 5.x gives
>>> undefined behavior in port_groupx4 in ARM. 'pn' and 'pnum' are
>>> two different pointers pointing to same chunk of memory and
>>> with -f-strict-aliasing the pointers are assumed to be pointing to
>>> different memory and compiler reorders instructions that depend on
>>> pnum and pn. This breaks port grouping algorithm.
>>>
>>> This patch eliminates the above problem by introducing a compiler
>>> barrier between the instructions that depend on pnum, pn and lp.
>>>
>>> Fixes: 569b290cdb36 ("examples/l3fwd: add NEON implementation")
>>>
>>> Signed-off-by: Guduri Prathyusha <gprathyusha@caviumnetworks.com>
>>
>> Acked-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> 
> Acked-by: Jianbo Liu <jianbo.liu@arm.com>

Applied to dpdk/master, thanks.

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

end of thread, other threads:[~2017-11-07  8:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-03 10:43 [PATCH v2] examples/l3fwd: fix aliasing in port grouping Guduri Prathyusha
2017-11-06  4:29 ` Jerin Jacob
2017-11-06  8:18   ` Jianbo Liu
2017-11-07  8:12     ` Ferruh Yigit

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.