From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0058.outbound.protection.outlook.com [104.47.34.58]) by dpdk.org (Postfix) with ESMTP id 242CA1B3AA for ; Thu, 2 Nov 2017 15:31:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Te+kWJjd5Y3sWQh6GoqUhCGGlIbsa7woqQ22NK4ckNg=; b=Sv+2mnQYvVKXM5bgx+PzzPc96O9/xKKxqowtzb98cnzb5GXG0Al8nIw68QGVAFgJ4fxljtx1UhZbumd+ALtr5Gyw5gsKIx7jD600XOceg1RhHABfVmP0f5QFkOJXem+A6AszuTZ+pCgOBqcR2gCl7vk5pgVyvTVnTyOv7/3b/9I= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Guduri.Prathyusha@cavium.com; Received: from prathyusha-Precision-Tower-5810.caveonetworks.com (111.93.218.67) by CY1PR07MB1510.namprd07.prod.outlook.com (10.161.168.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.178.6; Thu, 2 Nov 2017 14:31:42 +0000 From: Guduri Prathyusha To: tomasz.kantecki@intel.com Cc: Jianbo.Liu@arm.com, guduriprathyusha@gmail.com, konstantin.ananyev@intel.com, dev@dpdk.org, Guduri Prathyusha Date: Thu, 2 Nov 2017 20:01:14 +0530 Message-Id: <20171102143114.24380-1-gprathyusha@caviumnetworks.com> X-Mailer: git-send-email 2.14.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: PN1PR01CA0106.INDPRD01.PROD.OUTLOOK.COM (10.174.144.22) To CY1PR07MB1510.namprd07.prod.outlook.com (10.161.168.139) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9559ffe1-002e-43b6-486a-08d521fe713e X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603199); SRVR:CY1PR07MB1510; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB1510; 3:NSrTaRifZjHsn50xQIxCQnu34LUByqY7eZVJdN3GKkCL/yn85/So/I/tHLHqzoIOd9e/rdv9wOs2qg1tjRFtYQYBTv+7SDKugnvaWWDbyfJBGprUrfeFWFQbLMXRN0KYIQJOD7UEKKvWXPm42t35YG/LrH+WRfrWpNLbswonaG1Jeqcx4JgyP+DcivxKQJi38S2CgB3wxvykGxtoTvE00wzunOUy2hSeyaRelpiql8/6BXaUovTfde1Hx6C+SlPQ; 25:3xEAFhn8KZVBy56tzW+EqAK2hioEjRpWldhMqU28YbxItCP+UlZKYg1uPL6zcN87gxj4tAKDpdcogytk8oUJuO/cH+3WjR656PmS5F5WoaytC1lrYR6urJYfyqQzX3PQ43pEpQAU+2zLSYeNcU7b5X7bPeabEoR6Nw1hPQ/bMlbfuaLNn1k/svPViZFxSMyjgo5mpZsBjVOXsxXOg4ncdjI2QZxJbZsmA6CSMUDLnp9C0kJNBUuYNbK2EffbapTS5SpIfzt6eQQiZ2UlRfMrsUGazR7ZZkc+9AEEsphQsZb2T9ZvbRnssyVhSC1rDMj2pB0v/bHAHcmQR10wYuIPsw==; 31:lQ2WGAm9u8/6mKCfz7Fuhx47C+8xir9RMFDYDhzpVAR0uXsPVdKidTkE7x7pC//vJ4YILlQELwhlQEmrJVd70CcDDdXVvkWMzf7b6xRd1InnWhpwcYoQWvKjPZxFUPBUQv20QdEUb3A4m1ZWCrFh7LtFnurt8KvRu/bS5IKB5Y87wwXa2LASf1fKlqIu1n4CDy11pox1uz3MqTMUb5pXCRfgWw9qwXC6GXXdFthigRM= X-MS-TrafficTypeDiagnostic: CY1PR07MB1510: X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB1510; 20:GbY7CEpFHMdIByqrPTqHRa/QzrtGaVVDfreKbL1DYqUkUy3I76wsZ7v2tqsnqWG8GYEzRNDe+kI4vMX9nYYPffhOmwZinT1VAW9bNM5Ny84G53tohxu442I9iZm3SLRWq4eung9rSU5QP2eSjXuj8w/T1lLcp2vh855Da+5wWBr7CAcGZ27e/MLFqL6tefuJkUzBmLVeAAi/EXX1s3ukuK41OpJJZZahmlCNuOipVX6M8+TJYwO3pil9lKR0QbTLtS+bT4dmCuG9BX/rUSAUNGIE/zjpOO9bSbHXxXxIlvOt5MEEq17vCDHm5KtCS9PnRv2GGhdu9R9TjXkHMlupRT7Sqs28pHqa/sobq7jNz3Ht/YPSM6L8+iIuv6O8U7zsdgoGaiw6ertZKBC+QBLS9jQqFK7TqXqSGMdIBOV6Ddz/fR5S4UaoOqybZI1R0n08QsCGEtmAgIJYUkSG28VPbpR61MmTfIc6ISY/R4y3OevcqFvugWaLn/wHoIdSQx+L4mq8S1XjJS8FSEcAfRsVfEHQqiQegIy0ja3gnY2kT/vD2wzGdbWzZESq7WnTf08eSMfdZYDRS3RCULfq3OtJr5L2UCQvwyJijufePrI+9vY=; 4:T+phYbL3ikE+Y9+lgEg5docE5o5dyt9fnS1kIVGh+4g8Zw7StxesFqxuTbSToCeSeLDiK32Z0JvadSOwQLrjO3+gLsx/vBtSVjWLWhmjnE4ZPjOZLC+IcZNH/RmoQxsPGNVPqxCwq8RgOz+53fc75TnokZ6sHtLGmQUnRc4h0qVR6aRS9MmK8+Vc5SYzlpt4aL2Me/4BIC9t1oMbepyivRPlBLG54s7IFiHqb5Mduagcr/snDxIKLcUNmjCjSbwFb7dsQ87kQuCJR4fYlkq7Aw== X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(93006095)(3231020)(3002001)(100000703101)(100105400095)(10201501046)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123560025)(20161123562025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:CY1PR07MB1510; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:CY1PR07MB1510; X-Forefront-PRVS: 047999FF16 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(376002)(346002)(189002)(199003)(36756003)(305945005)(8676002)(16586007)(8936002)(7736002)(6666003)(6916009)(42882006)(6486002)(97736004)(6506006)(69596002)(5660300001)(105586002)(107886003)(33646002)(6512007)(53416004)(5009440100003)(189998001)(5003940100001)(53936002)(3846002)(6116002)(50986999)(68736007)(39060400002)(4326008)(25786009)(81166006)(81156014)(316002)(50226002)(16526018)(2351001)(101416001)(48376002)(2906002)(72206003)(106356001)(2361001)(47776003)(1076002)(66066001)(50466002)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR07MB1510; H:prathyusha-Precision-Tower-5810.caveonetworks.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR07MB1510; 23:DYMypWKXAxNF4p2zw7bbWtWZkl8KkoSNdkT59DTsc?= =?us-ascii?Q?fBt5ruuqu183Jw7M935M9cQ9LxJECrGJR4DTEbXIVqwx9wDzZM4P0fGpoc2W?= =?us-ascii?Q?XUzQfOWcg/tjTz+9DA5lwqOuHBczhdd+z1mUBzrbBmPJYEZ6c2njvnWxFQX/?= =?us-ascii?Q?Rfygw8WmUiMUqWccqkBRKF2w5w7K+3UdeD3ePsTu8l+QPTOOVc7EFPxq7NXQ?= =?us-ascii?Q?hAs7AGNEXYjyvQdK3a155p64xc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lhG6AywMsPpuXjX7Mnz1+2I7sjrCUFbx5AEV4E2XWxnKq4VNMegj9o5L/P8ED SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Nov 2017 14:31:42.5765 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9559ffe1-002e-43b6-486a-08d521fe713e X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB1510 Subject: [dpdk-dev] [PATCH ] examples/l3fwd: fix aliasing in port grouping X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Nov 2017 14:31:50 -0000 With -f-strict-aliasing enabled by default from -O2, gcc > 5.x gives undefined behavior in port_groupx4. '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 usage of union and uses memcpy for copying gptbl[v].pnum to pn. memcpy when applied on built_in constant size does not call its library implementation but uses appropriate LD and ST instructions directly and hence no performance overhead. Fixes: 569b290cdb36 ("examples/l3fwd: add NEON implementation") Fixes: af1694d94bf1 ("examples/l3fwd: fix crash with gcc 5") Signed-off-by: Guduri Prathyusha --- examples/l3fwd/l3fwd_neon.h | 11 +++-------- examples/l3fwd/l3fwd_sse.h | 11 +++-------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/examples/l3fwd/l3fwd_neon.h b/examples/l3fwd/l3fwd_neon.h index 4bc161394..10a602a04 100644 --- a/examples/l3fwd/l3fwd_neon.h +++ b/examples/l3fwd/l3fwd_neon.h @@ -100,11 +100,6 @@ static inline uint16_t * port_groupx4(uint16_t pn[FWDSTEP + 1], uint16_t *lp, uint16x8_t dp1, uint16x8_t dp2) { - union { - uint16_t u16[FWDSTEP + 1]; - uint64_t u64; - } *pnum = (void *)pn; - int32_t v; uint16x8_t mask = {1, 2, 4, 8, 0, 0, 0, 0}; @@ -117,9 +112,9 @@ port_groupx4(uint16_t pn[FWDSTEP + 1], uint16_t *lp, uint16x8_t dp1, /* if dest port value has changed. */ if (v != GRPMSK) { - pnum->u64 = gptbl[v].pnum; - pnum->u16[FWDSTEP] = 1; - lp = pnum->u16 + gptbl[v].idx; + rte_memcpy(pn, &gptbl[v].pnum, sizeof(gptbl[v].pnum)); + pn[FWDSTEP] = 1; + lp = pn + gptbl[v].idx; } return lp; diff --git a/examples/l3fwd/l3fwd_sse.h b/examples/l3fwd/l3fwd_sse.h index 831760f02..79a71d77e 100644 --- a/examples/l3fwd/l3fwd_sse.h +++ b/examples/l3fwd/l3fwd_sse.h @@ -98,11 +98,6 @@ processx4_step3(struct rte_mbuf *pkt[FWDSTEP], uint16_t dst_port[FWDSTEP]) static inline uint16_t * port_groupx4(uint16_t pn[FWDSTEP + 1], uint16_t *lp, __m128i dp1, __m128i dp2) { - union { - uint16_t u16[FWDSTEP + 1]; - uint64_t u64; - } *pnum = (void *)pn; - int32_t v; dp1 = _mm_cmpeq_epi16(dp1, dp2); @@ -114,9 +109,9 @@ port_groupx4(uint16_t pn[FWDSTEP + 1], uint16_t *lp, __m128i dp1, __m128i dp2) /* if dest port value has changed. */ if (v != GRPMSK) { - pnum->u64 = gptbl[v].pnum; - pnum->u16[FWDSTEP] = 1; - lp = pnum->u16 + gptbl[v].idx; + rte_memcpy(pn, &gptbl[v].pnum, sizeof(gptbl[v].pnum)); + pn[FWDSTEP] = 1; + lp = pn + gptbl[v].idx; } return lp; -- 2.14.1