From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0081.outbound.protection.outlook.com [104.47.40.81]) by dpdk.org (Postfix) with ESMTP id BB4CD1D90 for ; Sun, 3 Dec 2017 15:21:17 +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=kfhrQG3cMAQ7v6mkotfYsc3QuVgYoYUFEze/Gcmx54Y=; b=UF4SP3kQDR6H8scu/dM/7Zx6jLaTQC9yJT5lsja+dXqAckF/oN5pZhRNGx+P7wz/ofCEkPAmiivv4sqh8YuE/DmUHSiQvp4y3ooBor10nUvtOykZ2JmyPaOHc3R0fGZE2aUuFjFUGjqlN/o4sIJ3/l9TGClkLTlrNpu2trLIuow= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Pavan.Bhagavatula@cavium.com; Received: from Pavan-LT (103.16.71.47) by CY4PR07MB3462.namprd07.prod.outlook.com (10.171.252.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.282.5; Sun, 3 Dec 2017 14:21:13 +0000 Date: Sun, 3 Dec 2017 19:50:50 +0530 From: Pavan Nikhilesh Bhagavatula To: Herbert Guan , jianbo.liu@arm.com Cc: dev@dpdk.org Message-ID: <20171203142049.m7moapt7msxrwacs@Pavan-LT> References: <1511768985-21639-1-git-send-email-herbert.guan@arm.com> <20171202073300.yozet72nnvlwrkgj@Pavan-LT> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170609 (1.8.3) X-Originating-IP: [103.16.71.47] X-ClientProxiedBy: HK2PR04CA0046.apcprd04.prod.outlook.com (10.170.154.14) To CY4PR07MB3462.namprd07.prod.outlook.com (10.171.252.143) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a1589a7d-9d6e-4ad7-c504-08d53a591c7a X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603286); SRVR:CY4PR07MB3462; X-Microsoft-Exchange-Diagnostics: 1; CY4PR07MB3462; 3:YAFiAA4Fo++A0lQFCAERIXxkpOT1aUmnwoE9Ovlg+B1vlPh4EruDLYLSLIUkccMQdXy026ov/IK6snMF0Hy/470D59xqObfqRxEz/g89alCc+gULMlI9fnCTHm7wF06vybh94T0jwiptb10gGOqjQVNumHoZMOgCxEYp8xSlvpfnghbgq2j34KdPcQYFUMBQ9f860/Jnoa+Lx0u8JvocwOmyd++TgycBYncw0Wad4Eudasqq17B+I/tiRiRffJKY; 25:jMpThL8hcaP+9daxy5peN5homndAOGufnPE23sDLiM+rqmagT7gf/j4/BC6pw6ALdBuzOpP06VM75R46woRui45OQaf/OxpOd7lISK+A7j+SLChJWL/+aRMr7klwkuC1hmiX27p/cuUWIE/3lMYqHCxwa/u38trvphZxYbb48MgcVCss2fc452ktRSOKc6kqCCZTV3notLKGzh04HDwwr4ZzCwaVlL72/H8Q6mr5FFSzNluWHiKBSeCaNVv57RZqhtbLrdclafoxtEHoA9DTbMv45Bj9X767xixyyeWU3EtIQLA0+1WJOClQdd7P0vRtROB85Dzkx7w7K+fFvWKaBg==; 31:+xPIunjdo2qGqIBuLqzlkdqPU3gUVrhyjA74Br3H7AsSNWptsuKiTxP0WL/pc0c67nPZf/TWgTsJWDzYuw7mJAHpJx5LlHE3esTEWVbtPTZTIt8ziPeGzkyem5rm5Y25j9H6Cx3QLlQbrZbC7SZksM/eS1sqkhr2oMWvrJhGNsjIKnFihKfs9XZnUe4358WE4TtxlKx5F7L3QKZHR/ciuVMuGS3Ic1stZnVYN/Dcgu0= X-MS-TrafficTypeDiagnostic: CY4PR07MB3462: X-Microsoft-Exchange-Diagnostics: 1; CY4PR07MB3462; 20:v3iYAaIRm72hdmUbYNPJxQzZCDr+fRhPJdRXKX9hGahEps0q5jT2Q0Tc+RCiCJoRc4O58dxD717LPBQBgf4CrmdUmY0oJZC2QZHGO0/8EiTA+77hJIiLAnKZIiBVrqOZCCEzvlyxFWGLPJLVcWQfp4kEvUsyoSPupEM/jJB2l4RrEKlkxmjcsU+2gyCIH8mn4GtdfgGAN6yxTv7fWxavHQy6xCHdm+2SL7iUpkm8OTky5Nm2bzJFgSqwfYwJMOziV8uMCSoCUNoKefE7hTw3lLnNE15EBJPORGu1C6XkLfZLpBN96L8xIIUAsoGHhWTvNewQ/GMWpi/VouRBseXAR801llVy0xK0SkPr61nbUu2GLbq7Fcz9G5NXDl5m620o36aCCiA16ZTikG1KQmBE08zJrWKyPkjPlNob/0U+wo/vtbXD+2nVeMcgwAYxCk8NY+RfDikNrQqlTbf7x5ji5NOVQXJKQC3upU6ViOzenb4X5+TZd/idnBSGXrPjHXxwstHTGE9y0bfYxb/XHQA2EJ0fNwuY2pGPN6O9C/oCI5zkKhDkMOHE51bTKEdRKSolIlFhuPFHFhFjiLsVA/TtneXIM+3IrMjq4RY4WEdpbP4=; 4:aE7668RnODd2+51OGYZF+sknCXDnlmjL/xIojgMmXi0QXQ282eS5BxnfKX339LwMNVrAgCSDEoGReDoHgIPr8YwGhmdLak/EXkuyDhk9RmVnr+QjpA9gSJr2MIymIWSS7QibtZQrLdmCMzHPLQOqNRfo4fGPLKc7uVhYNmgp7ajh6oF3/Jkp7WIP2k+AllPRuCFVnvIJfF8T2m2y2cBBVmPDOH6UsLKkDmbCGiqrM67XLSybDUT0krm9lass8CFq2TRNzR+F66SdiRHnkSaBRA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(2401047)(8121501046)(5005006)(10201501046)(3231022)(93006095)(3002001)(6041248)(20161123564025)(20161123562025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123555025)(6072148)(201708071742011); SRVR:CY4PR07MB3462; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:CY4PR07MB3462; X-Forefront-PRVS: 05102978A2 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(376002)(346002)(366004)(189002)(199003)(24454002)(305945005)(101416001)(6496006)(1076002)(2906002)(97736004)(7736002)(68736007)(4326008)(478600001)(53936002)(106356001)(105586002)(52116002)(54356011)(8936002)(72206003)(6246003)(83506002)(76176011)(33646002)(6666003)(6116002)(50466002)(2950100002)(42882006)(47776003)(5660300001)(229853002)(9686003)(3846002)(23726003)(81156014)(81166006)(8676002)(25786009)(55016002)(575784001)(66066001)(58126008)(33716001)(316002)(16586007)(189998001)(16526018)(107986001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR07MB3462; H:Pavan-LT; 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; CY4PR07MB3462; 23:QPiDhlqHl54dg7OwO8ZbripuwLaawvw/eit0Nwq59?= =?us-ascii?Q?F0yaeEI/9slXxCSaB/iNonGq4ksBaoM7OemXdPfGGH+kK2pmm/7X8vnqW54L?= =?us-ascii?Q?q5HpBzaVYRe5jA/U+t9TxHuFFkKVLN6+tcSJ95EFv72aT32Tomw9qrmjUph+?= =?us-ascii?Q?FXmWzz2NZRu7FC7nbGYQzTbKZ5YbwR0uef05+vcfo7ao7Ea+98CDTkw7LfzZ?= =?us-ascii?Q?pUlwJ+iVzsHTdjfwQHVBOtgPMi8XPBJMhf+6udcDBAgUvaQIvTrRlf3/Opo6?= =?us-ascii?Q?3XmDG/jZ1hrlsierw0sFZPnj6io9L/Hv9mlR+3aNyj93GnQfa63/HVeZCuN0?= =?us-ascii?Q?dkJBSj8t7E83acnP9AQbO99LvHOjhH2bunyTRE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fnfKfB98 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2017 14:21:13.3507 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a1589a7d-9d6e-4ad7-c504-08d53a591c7a X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR07MB3462 Subject: Re: [dpdk-dev] [PATCH] arch/arm: optimization for memcpy on AArch64 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: Sun, 03 Dec 2017 14:21:18 -0000 On Sun, Dec 03, 2017 at 12:38:35PM +0000, Herbert Guan wrote: > Pavan, > > Thanks for review and comments. Please find my comments inline below. > > Best regards, > Herbert > > > There is an existing flag for arm32 to enable neon based memcpy > > RTE_ARCH_ARM_NEON_MEMCPY we could reuse that here as restrict does > > the same. > > > This implementation is actually not using ARM NEON instructions so the existing flag is not describing the option exactly. It'll be good if the existing flag is "RTE_ARCH_ARM_MEMCPY" but unfortunately it might be too late now to get the flags aligned. > Correct me if I'm wrong but doesn't restrict tell the compiler to do SIMD optimization? Anyway can we put RTE_ARCH_ARM64_MEMCPY into config/common_base as CONFIG_RTE_ARCH_ARM64_MEMCPY=n so that it would be easier to enable/disable. > > > +#include > > > +#include > > > + > > > > > +/********************************************************* > > *********** > > > +*********** > > > + * The memory copy performance differs on different AArch64 micro- > > architectures. > > > + * And the most recent glibc (e.g. 2.23 or later) can provide a > > > +better memcpy() > > > + * performance compared to old glibc versions. It's always suggested > > > +to use a > > > + * more recent glibc if possible, from which the entire system can get > > benefit. > > > + * > > > + * This implementation improves memory copy on some aarch64 > > > +micro-architectures, > > > + * when an old glibc (e.g. 2.19, 2.17...) is being used. It is > > > +disabled by > > > + * default and needs "RTE_ARCH_ARM64_MEMCPY" defined to activate. > > > +It's not > > > + * always providing better performance than memcpy() so users need to > > > +run unit > > > + * test "memcpy_perf_autotest" and customize parameters in > > > +customization section > > > + * below for best performance. > > > + * > > > + * Compiler version will also impact the rte_memcpy() performance. > > > +It's observed > > > + * on some platforms and with the same code, GCC 7.2.0 compiled > > > +binaries can > > > + * provide better performance than GCC 4.8.5 compiled binaries. > > > + > > > > > +********************************************************* > > ************ > > > +*********/ > > > + > > > +/************************************** > > > + * Beginning of customization section > > > +**************************************/ > > > +#define ALIGNMENT_MASK 0x0F > > > +#ifndef RTE_ARCH_ARM64_MEMCPY_STRICT_ALIGN > > > +// Only src unalignment will be treaed as unaligned copy #define > > > +IS_UNALIGNED_COPY(dst, src) ((uintptr_t)(dst) & ALIGNMENT_MASK) > > > > We can use existing `rte_is_aligned` function instead. > > The exising 'rte_is_aligned()' inline function is defined in a relatively complex way, and there will be more instructions generated (using GCC 7.2.0): > > 0000000000000000 : // using rte_is_aligned() > 0:91003c01 addx1, x0, #0xf > 4:927cec21 andx1, x1, #0xfffffffffffffff0 > 8:eb01001f cmpx0, x1 > c:1a9f07e0 csetw0, ne // ne = any > 10:d65f03c0 ret > 14:d503201f nop > > 0000000000000018 : // using above expression > 18:12000c00 andw0, w0, #0xf > 1c:d65f03c0 ret > > So to get better performance, it's better to use the simple logic. Agreed, I have noticed that too maybe we could change rte_is_aligned to be simpler (Not in this patch). > > Would doing this still benifit if size is compile time constant? i.e. when > > __builtin_constant_p(n) is true. > > > Yes, performance margin is observed if size is compile time constant on some tested platforms. > Sorry I didn't get you but which is better? If size is compile time constant is using libc memcpy is better or going with restrict implementation better. If the former then we could do what 32bit rte_memcpy is using i.e. #define rte_memcpy(dst, src, n) \ __extension__ ({ \ (__builtin_constant_p(n)) ? \ memcpy((dst), (src), (n)) : \ rte_memcpy_func((dst), (src), (n)); }) Regards, Pavan.