From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0062.outbound.protection.outlook.com [104.47.33.62]) by dpdk.org (Postfix) with ESMTP id C0C91160; Mon, 8 Oct 2018 12:00:33 +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=q86sLXoQ+YvSE0UTZjb1OJsUz1ZsbgjycFLZmRRVESo=; b=L7i+Hz8hXsJ1klMVSSyIbhEOwpnaEfSbxB4GW7adnZupSfbbmL+TqUTw6HfEp3dqpwhL2CF2KfMidIQAWTOyixRatV11kDQG30SFV4QNWCa1yg1PwsR9GG5Y7TmFMrtF4dZfvvYXJQoGUK5m4y4LA5/iRl5s6Vx1+U4iaHnoHYo= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jerin.JacobKollanukkaran@cavium.com; Received: from jerin (115.113.156.3) by BL0PR07MB4994.namprd07.prod.outlook.com (2603:10b6:208:49::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1207.18; Mon, 8 Oct 2018 10:00:26 +0000 Date: Mon, 8 Oct 2018 15:30:05 +0530 From: Jerin Jacob To: Ola Liljedahl Cc: "dev@dpdk.org" , Honnappa Nagarahalli , "Ananyev, Konstantin" , "Gavin Hu (Arm Technology China)" , Steve Capper , nd , "stable@dpdk.org" Message-ID: <20181008100004.GB11081@jerin> References: <1555626C-F2B8-44EB-98A3-79B1F7002587@arm.com> <60055965-A7C8-4E9F-8668-0AE1DCE57515@arm.com> <20181006074126.GA16715@jerin> <20181007040243.GA1850@jerin> <7A156041-23EC-4CCB-B129-3607AF34A992@arm.com> <20181008060629.GA5228@jerin> <063A95EC-CFC1-42F7-B864-DFB9C6718AC8@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <063A95EC-CFC1-42F7-B864-DFB9C6718AC8@arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Originating-IP: [115.113.156.3] X-ClientProxiedBy: PN1PR0101CA0030.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:c::16) To BL0PR07MB4994.namprd07.prod.outlook.com (2603:10b6:208:49::23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ea779638-a857-443c-49ed-08d62d04e213 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:BL0PR07MB4994; X-Microsoft-Exchange-Diagnostics: 1; BL0PR07MB4994; 3:l2I48l4Rm7l2vEzz84alRDt4Fkq4neaDeo11Jk5u/VgS1UADYCSkh4lIWTUlIVxsoJcXDDsnaEs2cun8/ZTjCxPa/qexTM4TwbY+nGRnYzYva+NBb3WwT33IDsc8e9EX391SvITDxFIGjUEbVYpKWuLppm7u8dDth7T9fqp3lkSs6JW2lMgbdXX4ZkqBckU91utVfFvvhGm3/26/4JKCchCKbo2n1HDLu1u/5nozcpXR6NvnbL6i817MC8Fur4//; 25:rdlMTLRf46q593V6+q8k8C/gq82MDCFNM/JI1yYUc+0Mpi6P0mGQOHFnRDvGswz+ny57YgA06h2DQLkdb2N9OhQtl2XB+hf1eVI5XP1FD9tq5kfIy8Q7QFxlYUixozNH/jazbOs3sVTk0uaV8xwWxTDcnYQsYd6VK/qxnNucNr9G5klJTFy+mSyuEl9N0Cf2zjm4XL9S7qwzXi9BA8K8hg8A/t6CASt1qmvQPxZxP0FMUQFptLJKREPgxmu1a2mFaeOqTdvI23Uezz8b+8ScNhW8SMYPQ5+HV37YYKOCskvCs5jylbGbw+Ya+R6eOjRSJxlNci4RVDwXGOUFLSKhEA==; 31:9BstPljvXWXuKyEA6JDd2O9TklakGeZtCyLCxARwlM6y8mN6lW7VitUIi1C0wa3QVhPAF2e7TU8+0QmrfHF0MwYprv0iNDwvujPToJs8CGtKCKvuVj393rGtIns3rmrveabnbFZQnz0cznU1Spq9vppFAQDo/ncsS5gwhJvebWdHAn9JLAbhSXV+yUN49SCkyuWHgb4LmDhEHD1QZe/kU2DJk6C75cmLQJREaa/9v+k= X-MS-TrafficTypeDiagnostic: BL0PR07MB4994: X-Microsoft-Exchange-Diagnostics: 1; BL0PR07MB4994; 20:w878S1LOdf57Rp027IO47B7bIK4ujSHsT3Wwg4c5GzZx/IM+Lxk/DXYgVEa23sLaouX71rmXrzh25Enh1xKURo+feZ7/5W9QHXWDkp3TCTX01Xn1CCI838MhBtAo0Ce4ievdr7k/D/8Xh6R/A14WRfDiziFdRrnZfH6Axs9FZUSG+Mq3Guslfj8eObcK61F4qbVoPO/T7UKfNKMPywhiobk+jSk0+nUY6sFynxN4JxjXQq+w+tslynha/6zqhQIcu/h52Wb5IIEuMuxnXTJpaCeHZnPxxtXUKelOUAqmfiv490EatYsB17KkoAOmozUlQ4++/ZNACmkJRCfZsJ/Q2RTYBuGADtQOVVAoLLtX0nnio7ly15fzzWKG/XU8TYRfIS1yzpuoo+bIB3UZllZUO74jfkYl+w6nMb8Gl6Qvg1GbBz8KVsdoWo+sjeRICwvN+HuzGcGdjV6b/vXcgOZgt4gk8ZKPurB9mPt53M+SrW1fD3Gl5cYf4fTuPEXUZcOJSYAyTVtGlZbBRvYhV8sljC2qWn/J5HFUMG+Q7+TOskmofhhHD/aOeEEaN98QDOaLRQr6+TFtmyNiP4FCWrjvYL7MX/bj5HG4f/T2hjbAF/c= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917)(228905959029699)(166708455590820); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(93006095)(3002001)(3231355)(944501410)(52105095)(149066)(150057)(6041310)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123560045)(201708071742011)(7699051); SRVR:BL0PR07MB4994; BCL:0; PCL:0; RULEID:; SRVR:BL0PR07MB4994; X-Microsoft-Exchange-Diagnostics: 1; BL0PR07MB4994; 4:tSK38P/xQR6IS3JUJIm46LkF4mnXrhaUf6S6v1SVkzKRyJFlKIOzo0Z8lxnAhxSdW/uGUQ48t2Z2LZQMEmleF2I539oARza6UnU8f8H7+2NNBd6bZ1pIeKWWfmEbfCX73G4beauRXqlztaNMBPetJ2gdj9wTcEyZRPWIFE03/d6xyU35OJb4zyPgc1G/lmPXu0TKsIcqYdzwraQ6Q8PoSCovmsIv1Qau+cWl/rptNxHtrS12S8q7HSsCsgntfkwOIDijhXj/8RpSOW5SdVUvljscWK6luN8b5r6jz3RBxXv7MW0UKSKmHq52m9n8j6dP8hfB3muawtDMFVVo72EjgnpRa1pEMDYshviP9VfwhTogzsK6qiT6UpD9+JVOnzuD X-Forefront-PRVS: 081904387B X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(39860400002)(376002)(346002)(136003)(396003)(189003)(199004)(13464003)(8676002)(81166006)(7736002)(6916009)(6666003)(81156014)(8936002)(478600001)(2906002)(6246003)(66066001)(4326008)(47776003)(97736004)(966005)(5660300001)(33656002)(50466002)(25786009)(45080400002)(72206003)(68736007)(42882007)(229853002)(6496006)(486006)(55016002)(956004)(44832011)(6306002)(26005)(9686003)(476003)(446003)(11346002)(3846002)(76176011)(105586002)(1076002)(386003)(6116002)(52116002)(53546011)(55236004)(106356001)(52146003)(2486003)(23676004)(33716001)(19627235002)(33896004)(16526019)(186003)(2870700001)(58126008)(14444005)(93886005)(316002)(305945005)(53936002)(54906003)(18370500001); DIR:OUT; SFP:1101; SCL:1; SRVR:BL0PR07MB4994; H:jerin; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCTDBQUjA3TUI0OTk0OzIzOnVHKzg1SXVQVjY1alkyeGR3RkwwK2xBamU1?= =?utf-8?B?NkUxQXhFSEFXa0Y0Y1ZER1NLM21Sakc3WUZaZFliaVlYWDZpUnA2R0dqZmV6?= =?utf-8?B?VFBxUmxLaHFxY1lNcnloVWVlS0RrOG9wa3dVZi9IdE1ESGM3T3hUcDlnRWlV?= =?utf-8?B?TVAzTitwZDN2OUJJT2RLL2FnYlppdmZsVzBjZGYyaGZ1MEM1eVJadzlFVEEr?= =?utf-8?B?UWQ0cERuMmRCbVdFcTNQSDdEUU43bmlkS09jQ2V5N01qKzVmd2Z1UTI2K09S?= =?utf-8?B?WjExUDRmQmJsWVdualhLWHBuSmcrV2EvMXVPMWw2ZUxnT01sN25VTjVNUXE3?= =?utf-8?B?TGc1WW1xU2ttTXZoKzRMdEFEUVEvL3VZNCtxR0o3WUl0VDJld0UwQ1hCS2lq?= =?utf-8?B?OTJaVElYU0NHVHpwYUNSWUdmdTQrMElBTTZncFptak5ac1FVZFRsc2tYMnRv?= =?utf-8?B?UUU2VVVlMmlYdWduTGZQcXNmYVlhaElFY3M2NWVrUlU0U1MyUXdDQlp2bUNH?= =?utf-8?B?M1h1REJzZXJ4S0VCWFJ6c0k4dHJYek1rZnRBZ3JZVGloZWkrUi9DNHVXYjhB?= =?utf-8?B?YmxsYm9HUTkzSE5zWkJ1cmV4V0JwMDVweStvTzRGQSsrYUxmMmQvcGZSNkxP?= =?utf-8?B?YXlVTWVKZW0rVVp4TVlTcHRNdDM4eklnWkpkZC9mb0hjNlM0TlFleExmSG5z?= =?utf-8?B?VEZYQVVESGhCeEluclFGVUs4c2RZS1pYb0FubTRsWVhOekFma2VFcENxWUo1?= =?utf-8?B?Y0cyUEpWUU1BV2g4eStwSnNoOU5OY1IveGEzak5uOU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3OPhjBhXYPa8+i8TePo+Bv7XwttkOBm+zzNi1onTAQeWSXZZH0X5LPBFJ5wOZpszoSWrwRp4PDfYZ7gBJWxOHeZWXrxkNypYZPjMy18dgulAeMFOxTBxIusUraZ3ivhZqjkES10UxoRiOjNbgt+h5W1Nc0iMOFM4VcjUbvdkFUMBfCbmBKp7cv+mrZ+ccD9G/o46IM+p4WDOzvRsouIHtV/6dgJTdhlLFT6SZm/+tKurOft0Uf/LhN44IIM5fjgM3T8AcIVtHyXQ54sQK2q6EW/LLixpH6d9Ue9LYOvOXZCLFD1Ti+ScxNBQ==; 5:Fd9mCuSXFV4jMmqIgYYRi2AUhIGzv5OT3dyxYpOwpxn65RE5VtjpLlq7uJ/szu6KrBwOlf0q9zzaoGEcY57F8/WDKZiP54mhO6Nzbk9jAd51avAGdWxypg3NolWAFBfKXOOYC8AOOsFiBn5bbCo1Jek/Bw9ofulS/NJHu1aJpIE=; 7:HPfMgER7QN4pVET6o/L5acDNGbaWjSvVprQvzSDQqcMbOlES6/wH3DD7RcP5+Yy5G+/HJ6kRLYc0oTdAnV9RyjvzNgr88Ymn4Z+lQ7d3dyr5HvQlx2m1srR31JmsPWpvAgiqT+eCbMrlJu0NwLU0AvCPJoaWkeSkH6vOhqRx/GF3S0cu7c7xN9tsnEIAXI0F/EmWnYYUpR0gfvGdOFMh41c3I1GDZ6SoIQWL1itcapmCAdSzpkcirddFGxb7ThtO SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Oct 2018 10:00:26.9912 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ea779638-a857-443c-49ed-08d62d04e213 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR07MB4994 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: Mon, 08 Oct 2018 10:00:34 -0000 -----Original Message----- > Date: Mon, 8 Oct 2018 09:22:05 +0000 > From: Ola Liljedahl > To: Jerin Jacob > CC: "dev@dpdk.org" , Honnappa Nagarahalli > , "Ananyev, Konstantin" > , "Gavin Hu (Arm Technology China)" > , Steve Capper , nd , > "stable@dpdk.org" > Subject: Re: [PATCH v3 1/3] ring: read tail using atomic load > user-agent: Microsoft-MacOutlook/10.11.0.180909 > > External Email > > On 08/10/2018, 08:06, "Jerin Jacob" wrote: > > -----Original Message----- > > Date: Sun, 7 Oct 2018 20:44:54 +0000 > > From: Ola Liljedahl > > To: Jerin Jacob > > CC: "dev@dpdk.org" , Honnappa Nagarahalli > > , "Ananyev, Konstantin" > > , "Gavin Hu (Arm Technology China)" > > , Steve Capper , nd , > > "stable@dpdk.org" > > Subject: Re: [PATCH v3 1/3] ring: read tail using atomic load > > user-agent: Microsoft-MacOutlook/10.11.0.180909 > > > > > Could you please fix the email client for inline reply. > Sorry that doesn't seem to be possible with Outlook for Mac 16 or Office365. The official Office365/Outlook > documentation doesn't match the actual user interface... > > > > https://www.kernel.org/doc/html/v4.19-rc7/process/email-clients.html > > > > > > On 07/10/2018, 06:03, "Jerin Jacob" wrote: > > > > In arm64 case, it will have ATOMIC_RELAXED followed by asm volatile ("":::"memory") of rte_pause(). > > I would n't have any issue, if the generated code code is same or better than the exiting case. but it not the case, Right? > > The existing case is actually not interesting (IMO) as it exposes undefined behaviour which allows the compiler to do anything. But you seem to be satisfied with "works for me, right here right now". I think the cost of avoiding undefined behaviour is acceptable (actually I don't think it even will be noticeable). > > I am not convinced because of use of volatile in head and tail indexes. > For me that brings the defined behavior. > As long as you don't mix in C11 atomic accesses (just use "plain" accesses to volatile objects), > it is AFAIK defined behaviour (but not necessarily using atomic loads and stores). But I quoted > the C11 spec where it explicitly mentions that mixing atomic and non-atomic accesses to the same > object is undefined behaviour. Don't argue with me, argue with the C11 spec. > If you want to disobey the spec, this should at least be called out for in the code with a comment. That's boils down only one question, should we follow C11 spec? Why not only take load acquire and store release semantics only just like Linux kernel and FreeBSD. Does not look like C11 memory model is super efficient in term of gcc implementation. > > > That the reason why I shared > the generated assembly code. If you think other way, Pick any compiler > and see generated output. > This is what one compiler for one architecture generates today. These things change. Other things > that used to work or worked for some specific architecture has stopped working in newer versions of > the compiler. > > > And > > Freebsd implementation of ring buffer(Which DPDK derived from), Don't have > such logic, See https://github.com/freebsd/freebsd/blob/master/sys/sys/buf_ring.h#L108 > It looks like FreeBSD uses some kind of C11 atomic memory model-inspired API although I don't see > exactly how e.g. atomic_store_rel_int() is implemented. The code also mixes in explicit barriers > so definitively not pure C11 memory model usage. And finally, it doesn't establish the proper > load-acquire/store-release relationships (e.g. store-release cons_tail requires a load-acquire cons_tail, > same for prod_tail). > > "* multi-producer safe lock-free ring buffer enqueue" > The comment is also wrong. This design is not lock-free, how could it be when there is spinning > (waiting) for other threads in the code? If a thread must wait for other threads, then by definition > the design is blocking. > > So you are saying that because FreeBSD is doing it wrong, DPDK can also do it wrong? > > > See below too. > > > > > Skipping the compiler memory barrier in rte_pause() potentially allows for optimisations that provide much more benefit, e.g. hiding some cache miss latency for later loads. The DPDK ring buffer implementation is defined so to enable inlining of enqueue/dequeue functions into the caller, any code could immediately follow these calls. > > > > From INTERNATIONAL STANDARD ©ISO/IEC ISO/IEC 9899:201x > > Programming languages — C > > > > 5.1.2.4 > > 4 Two expression evaluations conflict if one of them modifies a memory location and the other one reads or modifies the same memory location. > > > > 25 The execution of a program contains a data race if it contains two conflicting actions in different threads, at least one of which is not atomic, and neither happens before the other. Any such data race results in undefined behavior. > > IMO, Both condition will satisfy if the variable is volatile and 32bit read will atomic > for 32b and 64b machines. If not, the problem persist for generic case > as well(lib/librte_ring/rte_ring_generic.h) > The read from a volatile object is not an atomic access per the C11 spec. It just happens to > be translated to an instruction (on x86-64 and AArch64/A64) that implements an atomic load. > I don't think any compiler would change this code generation and suddenly generate some > non-atomic load instruction for a program that *only* uses volatile to do "atomic" accesses. > But a future compiler could detect the mix of atomic and non-atomic accesses and mark this > expression as causing undefined behaviour and that would have consequences for code generation. > > > I agree with you on C11 memory model semantics usage. The reason why I > propose name for the file as rte_ring_c11_mem.h as DPDK it self did not > had definitions for load acquire and store release semantics. > I was looking for taking load acquire and store release semantics > from C11 instead of creating new API like Linux kernel for FreeBSD(APIs > like atomic_load_acq_32(), atomic_store_rel_32()). If the file name is your > concern then we could create new abstractions as well. That would help > exiting KNI problem as well. > I appreciate your embrace of the C11 memory model. I think it is better for describing > (both to the compiler and to humans) which and how objects are used for synchronisation. > > However, I don't think an API as you suggest (and others have suggested before, e.g. as > done in ODP) is a good idea. There is an infinite amount of possible base types, an > increasing number of operations and a bunch of different memory orderings, a "complete" > API would be very large and difficult to test, and most members of the API would never be used. > GCC and Clang both support the __atomic intrinsics. This API avoids the problems I > described above. Or we could use the official C11 syntax (stdatomic.h). But then we > have the problem with using pre-C11 compilers... I have no objection, if everyone agrees to move C11 memory model with __atomic intrinsics. But if we need to keep both have then atomic_load_acq_32() kind of API make sense. > > > > > I think, currently it mixed usage because, the same variable declaration > used for C11 vs non C11 usage.Ideally we wont need "volatile" for C11 > case. Either we need to change only to C11 mode OR have APIs for > atomic_load_acq_() and atomic_store_rel_() to allow both models like > Linux kernel and FreeBSD. > > > > > -- Ola > > > > > > > >