From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM04-SN1-obe.outbound.protection.outlook.com (mail-eopbgr700088.outbound.protection.outlook.com [40.107.70.88]) by dpdk.org (Postfix) with ESMTP id 526AA1B159; Fri, 5 Oct 2018 19:07:46 +0200 (CEST) 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:X-MS-Exchange-SenderADCheck; bh=AQ7zCNwYH63X1eU/NHsHYAIogscgD3b/6ASH9q7t56Y=; b=RrPzJ8qotoZh1H6L4HlxR6bZJUJU+xeCDwI3iZIkcemhM9La8Dlz+tvTLeqi50HT7blfaEdlzeWl29JbIoI+y2yHdNOc34ackSSGuI3cBscxEBnzb2C2Ngkbq/RCzzqVQApz+XOQvlUpNarolZzPnyQVnh4KbA//P5UQEI3P19I= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jerin.JacobKollanukkaran@cavium.com; Received: from jerin (115.113.156.3) by SN6PR07MB5006.namprd07.prod.outlook.com (2603:10b6:805:ac::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1207.21; Fri, 5 Oct 2018 17:07:40 +0000 Date: Fri, 5 Oct 2018 22:37:27 +0530 From: Jerin Jacob To: Honnappa Nagarahalli Cc: "Ananyev, Konstantin" , Ola Liljedahl , "Gavin Hu (Arm Technology China)" , "dev@dpdk.org" , Steve Capper , nd , "stable@dpdk.org" Message-ID: <20181005170725.GA18671@jerin> References: <20180807031943.5331-1-gavin.hu@arm.com> <1537172244-64874-1-git-send-email-gavin.hu@arm.com> <20180929104857.GA30457@jerin> <2601191342CEEE43887BDE71AB9772580102FE261A@IRSMSX106.ger.corp.intel.com> <621E373E-048D-4808-8CE8-84373EA98D2F@arm.com> <2601191342CEEE43887BDE71AB9772580102FE2951@IRSMSX106.ger.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Originating-IP: [115.113.156.3] X-ClientProxiedBy: BM1PR0101CA0041.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:1a::27) To SN6PR07MB5006.namprd07.prod.outlook.com (2603:10b6:805:ac::32) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 18d8b6c5-42cf-4b8b-d9d4-08d62ae510dd X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:SN6PR07MB5006; X-Microsoft-Exchange-Diagnostics: 1; SN6PR07MB5006; 3:zEhyG622gOVeY1Afahrg0jCW41vuHQXbUW6qmRmal1vFhd494mc+FVcxbX3cbbtM7RfxyEIhZepe2OupFzX+iu5qBOxKgeT2uKRZAva4ZC/aIXrW3UGlG7Cv4M6TIP0jSGy2iRWnpKb9jyI6LTdjlGZuVAfulBBk/OIcvegBTScqt43RfIooVIGOLdfdB/c+iTJp7svKM9nnbWt9r41RDVT0kMBjmfqaW89YoK3qnHVwv6iqpprpTslCWixAbS6c; 25:CgWXK6l8mves/i8xP+3DZ9I+ap2T4TJP5PpwN+iufRRUsaVQpNljp+7eCW+dXohuLh+43SKcIfpMG2/MdPf+VPdLh8HHnQSip8ThsDYfZ/s9KJLX42hhCa3eVnDa85mbGHq9Rb9JFqBUjaq3WpJTivsADox6GcWs4YhA8C5BpqJgAq1vdf3pkf3apfnTZO2FHDb/wMs9JxhpmQAckT2uiFWovJIdt+14HeADUEcydEDSib0dXwg1HxNUEwuZ+Q3TajQw/uCbSKXeKMR15Z1MB0hHCz9pxxG6VVq9bANDbT77RsH5qkq1KAzPP/kD/ahWXhTgcrmN9J+Cj4SCwztGoQ==; 31:iYcN0Alsx3NYX/HQ1mJwJ4ToKGrz4OHepQUb/HFVQkBQSKhDGmhepTCrjII68NTy7B4o1BqrE11Th3O1NxtZEVcZ2yUYnSTvysrttpGk/4g1+AIJ1pE0yQFcJ+cZYOnTV+KkWCmVAeScDz/aUgS2+PcALODVFr4NJtTj/3n1cuHkkm0NoAu0zg/5aGX7MfUq6rjoxJmEgAd+aNYeVJ9kZq6c/PBESiSzMvsQBl727qk= X-MS-TrafficTypeDiagnostic: SN6PR07MB5006: X-Microsoft-Exchange-Diagnostics: 1; SN6PR07MB5006; 20:USP0nxWUwHCwlHeu4BseTl7pq294LVNTN3YNJiyf/KtVa5E63BN7aqqpRMYRBtMx02Ja7zE+3w/rfzjAEProm16OU7C6/sR2UdUH8O6k1KFShKoPYXudS20NV6g3MID3FZ63t1Hi+BfHcq8AybZXBb55FRBlQBBoQXnKXGqs9zm7HyFZyi8VJOPofCqDrByVUKmpMnCPtTuUU44OlyUc1k5UptoRzWBXIIbxOdm7sS5+wOzEN9mW72v5zlyFknyUkGWjz49DxK+GuQsQLoICuwZCXYwNpN0dfUdysUzpVY0yOSEp+l4SHJFkenBh107Ek+BAkddzVEH+lgjXjh+0bSo1wZcGN7jL65Wz0fzOfx0dhUMXK/z8kufyzPvvIXJ88hbnaKNqhTCz9R1o4H0t1TEjirhT/rnwq86PQX+mTGtZcIMF3/4zVSrDYSOYdIPGjeFTwwbmYhm/sUbdtKElOiWgqX41CmeINXBwlDs4sCHH8lWrhmEtfyYLO5LYRXkN7jssxRSox6PMOGLLP7RgmirJys8fu7Hx/yRcV2SdIr+BXkzc10LdD+lWlhCDcpJmv3KP608XpDU7VqEnY1itKjd/yaJrTgl3L0jbcxZGBoY= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917)(228905959029699)(100405760836317); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(3231355)(944501410)(52105095)(10201501046)(3002001)(149066)(150057)(6041310)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(201708071742011)(7699051); SRVR:SN6PR07MB5006; BCL:0; PCL:0; RULEID:; SRVR:SN6PR07MB5006; X-Microsoft-Exchange-Diagnostics: 1; SN6PR07MB5006; 4:zXCG62lOKRcIZV0R8wzz6uOLJ4LsafAqPxR0g6iamVpV1fEe2bxg6Qz5ElS53l+3+Mc2Epw8oHuwtrg0Wvk8ATYNq6SPgFbf6IrSsjk9dIVKpnM5tGlstI/8KZTnB/tpM/ypp82EuJffcUYjA7Enp0SgB6fCanRdQOaffTDcrwKx9fvIxDlCVxnm9f7dTua3mQZCZeXgaikYhSnX8pFgEjsaSx1OuRRHZ0/1rrPtiuJvsxmsDamTeO6hmajJgL3GURoCkxSePzvkFAX6bNaqROuFul2C5TYrToF8u02PJwhVoWyzKowkx59pZc1D2re6nlCEW6Q1WvpUjr1OtWvJ3i3bPb4ieCn77ySVXowH7g0K8+tRzR5J7VhmjeSTfoLz X-Forefront-PRVS: 0816F1D86E X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(366004)(346002)(39850400004)(136003)(396003)(199004)(189003)(13464003)(93886005)(33656002)(97736004)(966005)(55236004)(305945005)(7736002)(53546011)(6666003)(478600001)(47776003)(386003)(6916009)(33896004)(2870700001)(50466002)(316002)(76176011)(66066001)(186003)(16526019)(5660300001)(42882007)(72206003)(26005)(446003)(486006)(54906003)(476003)(11346002)(956004)(58126008)(8936002)(1076002)(14444005)(3846002)(44832011)(575784001)(6116002)(25786009)(6246003)(8676002)(81166006)(81156014)(9686003)(106356001)(68736007)(105586002)(52116002)(55016002)(52146003)(4326008)(53936002)(2486003)(2906002)(33716001)(6496006)(23676004)(6306002)(229853002)(10126625002)(18370500001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN6PR07MB5006; H:jerin; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtTTjZQUjA3TUI1MDA2OzIzOm9pd2VKV0JqNDlNUGVLZUdKUHEwY3JUZ1Z1?= =?utf-8?B?N1F0NXZaazFFMHRlZS8yUjROWldpZXBiYWRHaWZCek1GZHAzRTZ2MHVpZDlV?= =?utf-8?B?WWFKd2tIUTc5M1cwM1QwejBtUDZhQVphL0xjQTN6dWxpVWc1MTdaZk96SEFi?= =?utf-8?B?dHo4YjZMRWR5TTZjZmVxaUUrZHhUbFVTajJQU1dxL1NqSDB6Ui8xWmNlbklv?= =?utf-8?B?S1VCRS9nNlFlRmdJSkUvWkpBRFdSa2JmZmhKRHlkeWcyQm1Odys4WDNwTE1W?= =?utf-8?B?NUNRbDNqdnlYczI1VmRMNnlOSDZScmFQZnh3UTdKQXJNZlp3MDFpNWtWQXZs?= =?utf-8?B?SEYzZkNmMWc2Kys3cm1YS0RzNzYvQjkySGw3MjdZb0x5cEtkUFR1Sm1Mb2JT?= =?utf-8?B?K0QxY0FSc3RTS1pIME0ydUcxYysyWkthRjBnZFFGOVBBelBIYm1Mc2piMmp0?= =?utf-8?B?THlpMnN1MjllbmhPYzFnd1NWZm1LMDNtYzh6VGZOT25hSnI1dEZ1aURYVUEw?= =?utf-8?B?NkZ5aEJhQ05uU21WY2txWExjUHFVUC91ZlB2UWlZZjVPTVhhamhRK3dsbmtC?= =?utf-8?B?dlVGV0xSWDFHeUZDdUpaM2wvMXNNc1g4LzZpcTFIR1BXSzJCeTlvdU9lUVhP?= =?utf-8?B?aVZiUitJU1VieDF5dWZLNS9RYmt5TEpSNmVBRUpRNEtTZFBFRDdnTlZTY3o2?= =?utf-8?B?clBXSVlEQ0t3M0NNMXJyMHJveS9qNlFxcG9rallXVnI4V3hUaE1XRm5DM1c4?= =?utf-8?B?WGFBSndJUzdWUzNmQXhnL1ExbXptb2ljMlJYOEdmbCs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XDPCT5FllOjE/sY0dwbBViLLmYeqlDHEXjjWrQ7R3+En1meCN7H7CM/tX8H3mkabcOxcI9uo/sUd5+DMNkn5ugW6LCOq503LPzOhhxYxun+yl6iTt6ex/fH/wFYIApmGetIJaJu9rAKYrGodJYpS2XNDHXCb7ZP4xJxYMX5wNjB1xNODIGn1Nq5fRjCnSSyZtI+L+RPXq1j4/kpdWLfN0QH/AKbgH5DePKV5eXFJRwAY4VvuxMxaTtdWNKWVhIOlw8zTZhFsr5D6P3OMLdc0EHAbjyb0RPlh/VKoYM7mHOZdA==; 5:8mOAV6kBhteoQanL3BjngxM9zvWwduXCqlh5nG6MCscMm0v9qTJt7/5p5eXrenDBfNss2MY4pkumfUF9Kg+OebyX9S4Z8qrSQCZ9tK/4Fe8unCwDNkqQg+wYIZMvU63YNPpJyxuSwS6lNhUZQ8xLpx7mQIZnmS2LX16MqBtHhn4=; 7:K7L1MjesmGPaJDMI9PRo+AcFPoCVNEvCkmkRKDXH8cIxezZwRjVSto6qnVsQFdlAoKyKVetmATZsdL1Oy/Y7/rYnVMiUyaW6/dzEZpF94EVxKWyLbMVfvcVasm+gcPMIMV1L4icKZMh+bsS+fsiWJRZzyzj8yTkWNlrGTsDZ8x7qf1DPsYTgdQTJphgspgFSeU/BhqM5cwSGkz1qwxiu+VkJ/syr4laSDqM26rcuwC0v8Bmgt+iBESJwr9d02ImI SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2018 17:07:40.7417 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 18d8b6c5-42cf-4b8b-d9d4-08d62ae510dd X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR07MB5006 Subject: Re: [dpdk-dev] [PATCH v3 1/3] ring: read tail using atomic load 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: Fri, 05 Oct 2018 17:07:46 -0000 -----Original Message----- > Date: Fri, 5 Oct 2018 15:11:44 +0000 > From: Honnappa Nagarahalli > To: "Ananyev, Konstantin" , Ola Liljedahl > , "Gavin Hu (Arm Technology China)" > , Jerin Jacob > CC: "dev@dpdk.org" , Steve Capper , nd > , "stable@dpdk.org" > Subject: RE: [PATCH v3 1/3] ring: read tail using atomic load > > > > > Hi Jerin, > > > > > > > > Thanks for your review, inline comments from our internal > > discussions. > > > > > > > > BR. Gavin > > > > > > > > > -----Original Message----- > > > > > From: Jerin Jacob > > > > > Sent: Saturday, September 29, 2018 6:49 PM > > > > > To: Gavin Hu (Arm Technology China) > > > > > Cc: dev@dpdk.org; Honnappa Nagarahalli > > > > > ; Steve Capper > > > > > ; Ola Liljedahl ; > > nd > > > > > ; stable@dpdk.org > > > > > Subject: Re: [PATCH v3 1/3] ring: read tail using atomic load > > > > > > > > > > -----Original Message----- > > > > > > Date: Mon, 17 Sep 2018 16:17:22 +0800 > > > > > > From: Gavin Hu > > > > > > To: dev@dpdk.org > > > > > > CC: gavin.hu@arm.com, Honnappa.Nagarahalli@arm.com, > > > > > > steve.capper@arm.com, Ola.Liljedahl@arm.com, > > > > > > jerin.jacob@caviumnetworks.com, nd@arm.com, > > stable@dpdk.org > > > > > > Subject: [PATCH v3 1/3] ring: read tail using atomic load > > > > > > X-Mailer: git-send-email 2.7.4 > > > > > > > > > > > > External Email > > > > > > > > > > > > In update_tail, read ht->tail using __atomic_load.Although the > > > > > > compiler currently seems to be doing the right thing even without > > > > > > _atomic_load, we don't want to give the compiler freedom to > > optimise > > > > > > what should be an atomic load, it should not be arbitarily moved > > > > > > around. > > > > > > > > > > > > Fixes: 39368ebfc6 ("ring: introduce C11 memory model barrier > > option") > > > > > > Cc: stable@dpdk.org > > > > > > > > > > > > Signed-off-by: Gavin Hu > > > > > > Reviewed-by: Honnappa Nagarahalli > > > > > > > > Reviewed-by: Steve Capper > > > > > > Reviewed-by: Ola Liljedahl > > > > > > --- > > > > > > lib/librte_ring/rte_ring_c11_mem.h | 3 ++- > > > > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > > > > > The read of ht->tail needs to be atomic, a non-atomic read would not > > be correct. > > > > > > That's a 32bit value load. > > > AFAIK on all CPUs that we support it is an atomic operation. > > > [Ola] But that the ordinary C load is translated to an atomic load for the > > target architecture is incidental. > > > > > > If the design requires an atomic load (which is the case here), we > > > should use an atomic load on the language level. Then we can be sure it will > > always be translated to an atomic load for the target in question or > > compilation will fail. We don't have to depend on assumptions. > > > > We all know that 32bit load/store on cpu we support - are atomic. > > If it wouldn't be the case - DPDK would be broken in dozen places. > > So what the point to pretend that "it might be not atomic" if we do know for > > sure that it is? > > I do understand that you want to use atomic_load(relaxed) here for > > consistency, and to conform with C11 mem-model and I don't see any harm in > > that. > We can continue to discuss the topic, it is a good discussion. But, as far this patch is concerned, can I consider this as us having a consensus? The file rte_ring_c11_mem.h is specifically for C11 memory model and I also do not see any harm in having code that completely conforms to C11 memory model. Have you guys checked the output assembly with and without atomic load? There is an extra "add" instruction with at least the code I have checked. I think, compiler is not smart enough to understand it is a dead code for arm64. ➜ [~] $ aarch64-linux-gnu-gcc -v Using built-in specs. COLLECT_GCC=aarch64-linux-gnu-gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/aarch64-linux-gnu/8.2.0/lto-wrapper Target: aarch64-linux-gnu Configured with: /build/aarch64-linux-gnu-gcc/src/gcc-8.2.0/configure --prefix=/usr --program-prefix=aarch64-linux-gnu- --with-local-prefix=/usr/aarch64-linux-gnu --with-sysroot=/usr/aarch64-linux-gnu --with-build-sysroot=/usr/aarch64-linux-gnu --libdir=/usr/lib --libexecdir=/usr/lib --target=aarch64-linux-gnu --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-nls --enable-languages=c,c++ --enable-shared --enable-threads=posix --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --disable-multilib --disable-werror --enable-checking=release Thread model: posix gcc version 8.2.0 (GCC) # build setup make -j 8 config T=arm64-armv8a-linuxapp-gcc CROSS=aarch64-linux-gnu- make -j 8 test-build CROSS=aarch64-linux-gnu- # generate asm aarch64-linux-gnu-gdb -batch -ex 'file build/app/test ' -ex 'disassemble /rs bucket_enqueue_single' I have uploaded generated file for your convenience with_atomic_load.txt(includes patch 1,2,3) ----------------------- https://pastebin.com/SQ6w1yRu without_atomic_load.txt(includes patch 2,3) ----------------------- https://pastebin.com/BpvnD0CA without_atomic ------------- 23 if (!single) 0x000000000068d290 <+240>: 85 00 00 35 cbnz w5, 0x68d2a0 0x000000000068d294 <+244>: 82 04 40 b9 ldr w2, [x4, #4] 0x000000000068d298 <+248>: 5f 00 01 6b cmp w2, w1 0x000000000068d29c <+252>: 21 01 00 54 b.ne 0x68d2c0 // b.any 24 while (unlikely(ht->tail != old_val)) 25 rte_pause(); with_atomic ----------- 23 if (!single) 0x000000000068ceb0 <+240>: 00 10 04 91 add x0, x0, #0x104 0x000000000068ceb4 <+244>: 84 00 00 35 cbnz w4, 0x68cec4 0x000000000068ceb8 <+248>: 02 00 40 b9 ldr w2, [x0] 0x000000000068cebc <+252>: 3f 00 02 6b cmp w1, w2 0x000000000068cec0 <+256>: 01 09 00 54 b.ne 0x68cfe0 // b.any 24 while (unlikely(old_val != __atomic_load_n(&ht->tail, __ATOMIC_RELAXED))) I don't want to block this series of patches due this patch. Can we make re spin one series with 2 and 3 patches. And Wait for patch 1 to conclude? Thoughts? > > > But argument that we shouldn't assume 32bit load/store ops as atomic > > sounds a bit flaky to me. > > Konstantin > > > > > > > > > > > > > > > > > But there are no memory ordering requirements (with > > > > regards to other loads and/or stores by this thread) so relaxed > > memory order is sufficient. > > > > Another aspect of using __atomic_load_n() is that the > > > compiler cannot "optimise" this load (e.g. combine, hoist etc), it has to be > > done as > > > > specified in the source code which is also what we need here. > > > > > > I think Jerin points that rte_pause() acts here as compiler barrier too, > > > so no need to worry that compiler would optimize out the loop. > > > [Ola] Sorry missed that. But the barrier behaviour of rte_pause() > > > is not part of C11, is it essentially a hand-made feature to support > > > the legacy multithreaded memory model (which uses explicit HW and > > compiler barriers). I'd prefer code using the C11 memory model not to > > depend on such legacy features. > > > > > > > > > > > > Konstantin > > > > > > > > > > > One point worth mentioning though is that this change is for > > > the rte_ring_c11_mem.h file, not the legacy ring. It may be worth persisting > > > > with getting the C11 code right when people are less excited about > > sending a release out? > > > > > > > > We can explain that for C11 we would prefer to do loads and stores > > as per the C11 memory model. In the case of rte_ring, the code is > > > > separated cleanly into C11 specific files anyway. > > > > > > > > I think reading ht->tail using __atomic_load_n() is the most > > appropriate way. We show that ht->tail is used for synchronization, we > > > > acknowledge that ht->tail may be written by other threads > > > without any other kind of synchronization (e.g. no lock involved) and we > > require > > > > an atomic load (any write to ht->tail must also be atomic). > > > > > > > > Using volatile and explicit compiler (or processor) memory barriers > > (fences) is the legacy pre-C11 way of accomplishing these things. > > > There's > > > > a reason why C11/C++11 moved away from the old ways. > > > > > > > > > > > > __atomic_store_n(&ht->tail, new_val, __ATOMIC_RELEASE); > > > > > > -- > > > > > > 2.7.4 > > > > > > > > > > > > > > > >