From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 783ACA0501; Sat, 2 Apr 2022 19:54:53 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2D2B34067E; Sat, 2 Apr 2022 19:54:53 +0200 (CEST) Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10070.outbound.protection.outlook.com [40.107.1.70]) by mails.dpdk.org (Postfix) with ESMTP id 6C6414003F for ; Sat, 2 Apr 2022 19:54:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YCBLPt2w0Q8sp4Lt5PrU+a/9+hkr/mePe5fEQ4mbunw=; b=cR9mxZHELk7OMMklxIW/lCBQsCHK99YJghf43gPacbypLp85wIxNWPLCMC1n0xCc9ml0W7pn4ChzKgKHTV+ruV4KNHjqXO1b7G7pnBD62q9TnMFsG5lGG+AP3fh6cLC3k3cnyUHfbaKX0uRC6qXUhuNDD/wN+NjDbMrSAWwZbgc= Received: from AM6PR08CA0029.eurprd08.prod.outlook.com (2603:10a6:20b:c0::17) by PAXPR08MB7140.eurprd08.prod.outlook.com (2603:10a6:102:208::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.19; Sat, 2 Apr 2022 17:54:49 +0000 Received: from VE1EUR03FT041.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:c0:cafe::e7) by AM6PR08CA0029.outlook.office365.com (2603:10a6:20b:c0::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.30 via Frontend Transport; Sat, 2 Apr 2022 17:54:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT041.mail.protection.outlook.com (10.152.19.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.19 via Frontend Transport; Sat, 2 Apr 2022 17:54:48 +0000 Received: ("Tessian outbound 78191104f1b7:v118"); Sat, 02 Apr 2022 17:54:48 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 606d1b7ebfff2dc9 X-CR-MTA-TID: 64aa7808 Received: from 3fce15e13a8a.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 204F8C06-0B55-4572-BF2F-1DA0E17A9552.1; Sat, 02 Apr 2022 17:54:48 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 3fce15e13a8a.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Sat, 02 Apr 2022 17:54:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZqAZbXdECAvjXbxqFtarDkpQyTy5ideToS9rGOFWq/flExGovudOKdibOyRNCbmpb5Bj7sy7sdNtFiJEi5dwTPTMqDpY+b8k6QhXAOZlYRv9Wcs0T1e1cpK9Lwt0drRC1D0g3RPn8KVu6Wg3wu3o80xaJVbIx5osxLsyW5RoA3TW2tbFivumWdpieIMut2nbl6QOMdxuV1E0TJGOnlyovNGh+dqXXJnoEJukAi6D5AfgveYthErDtkEoHZzgibQfJ6h/o1FEn3VT+MIoQM8wk5M28StDTThwWgyoMAShSrwXtX233u6Q7JJvh3DsWAgJvbxU0JqXkH5NgXQSCzSFwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=YCBLPt2w0Q8sp4Lt5PrU+a/9+hkr/mePe5fEQ4mbunw=; b=hJUoUBAWQGNNJeEM8h/pzIcMbVMfoxQWZK5P6LCEXt6pRxYrbwHqUqVJSmorGgMWtcMrf5YznArUxLiu68Az+ta7im38H85QX2KMjwOcjAjgv2qIKWAZ0/JjvaNWGNz4sw6xhidqWGjALJypwcNa4lbj05w4kMDRw/yF9ziHd6ZTRhGcjgncC9+FF8281G0olA5YtvrYZaVXp/Duh/ojs2D04PoVfk1kC1fL08gdOPQqx1cAlGFCoKlLBUii13rkLzGVaW3WFQ9Bb60fAwamohMAHjts+Ti7XR+FrD27TcxQCfaqTpfrHpY2USrMATi9f5HcANmRbYIoNJhThH9B9w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YCBLPt2w0Q8sp4Lt5PrU+a/9+hkr/mePe5fEQ4mbunw=; b=cR9mxZHELk7OMMklxIW/lCBQsCHK99YJghf43gPacbypLp85wIxNWPLCMC1n0xCc9ml0W7pn4ChzKgKHTV+ruV4KNHjqXO1b7G7pnBD62q9TnMFsG5lGG+AP3fh6cLC3k3cnyUHfbaKX0uRC6qXUhuNDD/wN+NjDbMrSAWwZbgc= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from AM8PR08MB6498.eurprd08.prod.outlook.com (2603:10a6:20b:364::11) by DB7PR08MB3803.eurprd08.prod.outlook.com (2603:10a6:10:7f::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.30; Sat, 2 Apr 2022 17:54:33 +0000 Received: from AM8PR08MB6498.eurprd08.prod.outlook.com ([fe80::ec4f:1ad:e332:9f39]) by AM8PR08MB6498.eurprd08.prod.outlook.com ([fe80::ec4f:1ad:e332:9f39%5]) with mapi id 15.20.5123.030; Sat, 2 Apr 2022 17:54:33 +0000 Message-ID: <422fc5ba-8835-777e-2a3a-6ce599963001@arm.com> Date: Sat, 2 Apr 2022 19:54:28 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH v2] eal: add seqlock Content-Language: en-US To: Stephen Hemminger , =?UTF-8?Q?Mattias_R=c3=b6nnblom?= Cc: dev@dpdk.org, Thomas Monjalon , David Marchand , onar.olsen@ericsson.com, Honnappa.Nagarahalli@arm.com, nd@arm.com, konstantin.ananyev@intel.com, mb@smartsharesystems.com References: <98CBD80474FA8B44BF855DF32C47DC35D86F84@smartserver.smartshare.dk> <20220330142602.108061-1-mattias.ronnblom@ericsson.com> <20220401145008.25e1c9f5@shemminger-XPS-13-9360> From: Ola Liljedahl In-Reply-To: <20220401145008.25e1c9f5@shemminger-XPS-13-9360> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: LO2P265CA0083.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:8::23) To AM8PR08MB6498.eurprd08.prod.outlook.com (2603:10a6:20b:364::11) MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: d92f4e3a-cd86-45f3-3cce-08da14d1e18a X-MS-TrafficTypeDiagnostic: DB7PR08MB3803:EE_|VE1EUR03FT041:EE_|PAXPR08MB7140:EE_ X-LD-Processed: f34e5979-57d9-4aaa-ad4d-b122a662184d,ExtAddr X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: YBmEVG7w8Al4qsH98JXDOiq5scI0nvCILiQIJ9GkTcM9m5zroSfUntAItee1ORbzi/BKLB2wwEXHX0aN6znDewHY/c8nhi3M69fRYc1znEDY5ke4NgYPsIVtdpgl9HjFigol5quKnYa5cwyAJks+vHrufYUT20iGW6XVKhiDHTldRNLjf3wgARvjAOkg4VK73ksvy5JB8vLFLLWDn+5o2Hmvb6Gc4kVaUdFGtJO2JIq7VZOWvE6wKyTAxB9fHt1jd57jtrpj4JFWqJ1W9DvVqIcj16h73P6v7Z/Tj6Z4LlnWZo9qOO/zpaDdUAJxlFCTBsdGyE/AsNu4mYVRxEEtMHfPJbqvZPB/xUOtZIkp6bbasFmSFEa25hFleLGLeBECR3lrR/2RKLBZ3O4HZA8xaWtGsUUWbYdcwuk8+nFVR6o/jYr8YD8ZsxDieQRqWDo3lHkU+YhwK/RZMiSe1tOABONkxX9vyUUcW0YYn6uhZMPbx96jfmCTRyacVpBfQMYA45E7nPs/Mmrmu8gUcE4HafRb4BJ5m5SJMZ4AUHeocNnpKX81VU51II3Q++j4AR/JynEjQfejMalkBh+BK1iL/eLYfp8682mcMlW+uMsT8uIfwyUziy5XVR6WuEoZlmLNv0uP5/k9xawU2rWp2hg/FvEAauoPCKK9gdHAoARYMbDlV/wRfdx0tl2+tAke7g9Ygrlbh5WGMKi91xJfcj0R+teiRVjVsdhHW13JXoVkjRs= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM8PR08MB6498.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(83380400001)(6666004)(5660300002)(6506007)(44832011)(6486002)(31686004)(508600001)(2906002)(8936002)(53546011)(36756003)(66574015)(186003)(316002)(38100700002)(2616005)(26005)(110136005)(8676002)(4326008)(31696002)(66556008)(66476007)(86362001)(54906003)(66946007)(6512007)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3803 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT041.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 6500ff7c-232f-4f2b-6621-08da14d1d7ff X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zGd4tsRohPJtDsfVawLKPl6ypcJlgxuyCZlAAGjvIIFGcOxXqGAMcIHvOFqk+JJKYZK6XOVEgBWIboI3bQWULzhuf+ltdRPV5y+5HDt/8aYIc1RM19Gqfm4wBh5PPrZFii9dUa1y64jjo/QrmVe1KJCbq2Th85zneuQ6XJxo8X66dFxdTXHNcYoxGnMaoYVAYa01KK65M4lbYCfA85weuijE92c3ovoLyipMVtIm05nN5vAG1yI9yR66Qh3DDuSj4I8OMHquh6mg3p7dys6fvciRTBq1+UzY5k2CDCMOFKDGfrmdj4xBkF3/5UjqW6HVE7HKBx0CtipU9Mwo8F/UIxhtWQYug3FO0KGEUzCAJYNyI2LPgkKNdhpj0LIlL7LmpyRbVixt6XdftkuoxWckYjf0qRF1QvRyquqwZG/BEuFuZ++YuvIjxvAOTVUcVC81IK2zcW3i11yFh40vvkIC9ep5wJClMX8+NmU0bu7TQlsDp3/UaNp8CQA78AVG5p1BqG8npApTDZPheNxu8ZN1sMehfsxERD1OkuqcDdquyVu5RAxBsOy8rWqZb54Mj9d3ZX74SJVP+CuGsnWzlstoTJvADHLuDlLOqwQvm0WSsCqH++9xw7nXTa+A4/R6oRXlddh+lYegjJ1cQsc0oUCI5woXD6GonO86eCXMHmxdxpTguwLOA7B0w89mY72nVtm4Y7fGjQWffgYNsbzJFtRK7A== X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230001)(4636009)(40470700004)(36840700001)(46966006)(5660300002)(356005)(4326008)(36756003)(81166007)(47076005)(70206006)(8936002)(44832011)(31686004)(40460700003)(8676002)(2906002)(70586007)(53546011)(6512007)(186003)(6506007)(316002)(6486002)(36860700001)(83380400001)(66574015)(110136005)(54906003)(107886003)(336012)(6666004)(26005)(2616005)(82310400004)(31696002)(86362001)(508600001)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Apr 2022 17:54:48.9971 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d92f4e3a-cd86-45f3-3cce-08da14d1e18a X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT041.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB7140 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On 4/2/22 02:50, Stephen Hemminger wrote: > On Wed, 30 Mar 2022 16:26:02 +0200 > Mattias Rönnblom wrote: > >> + __atomic_store_n(&seqlock->sn, sn, __ATOMIC_RELAXED); >> + >> + /* __ATOMIC_RELEASE to prevent stores after (in program >> order) >> + * from happening before the sn store. >> + */ >> + rte_atomic_thread_fence(__ATOMIC_RELEASE); > Couldn't atomic store with __ATOMIC_RELEASE do same thing? No, store-release wouldn't prevent later stores from moving up. It only ensures that earlier loads and stores have completed before store-release completes. If later stores could move before a supposed store-release(seqlock->sn), readers could see inconsistent (torn) data with a valid sequence number. >> +static inline void >> +rte_seqlock_write_end(rte_seqlock_t *seqlock) >> +{ >> + uint32_t sn; >> + >> + sn = seqlock->sn + 1; >> + >> + /* synchronizes-with the load acquire in rte_seqlock_begin() >> */ >> + __atomic_store_n(&seqlock->sn, sn, __ATOMIC_RELEASE); >> + >> + rte_spinlock_unlock(&seqlock->lock); > Atomic store is not necessary here, the atomic operation in > spinlock_unlock wil assure theat the seqeuence number update is > ordered correctly. Load-acquire(seqlock->sn) in rte_seqlock_begin() must be paired with store-release(seqlock->sn) in rte_seqlock_write_end() or there wouldn't exist any synchronize-with relationship. Readers don't access the spin lock so any writer-side updates to the spin lock don't mean anything to readers.