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 7B2FEA0503; Thu, 31 Mar 2022 11:05:35 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1CB1B410FA; Thu, 31 Mar 2022 11:05:35 +0200 (CEST) Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00057.outbound.protection.outlook.com [40.107.0.57]) by mails.dpdk.org (Postfix) with ESMTP id AB96940DF6 for ; Thu, 31 Mar 2022 11:05:33 +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=vA4AI49XG6dZSaNLKG20eE5ecagFSvtasAxzb3+wQbE=; b=87GP7TsMmaGqklbWubICyN6/7GgKxSRK7CFIb8+GxUcP87Iymv2srBdgGDFEuTJ51cPtpgMapeUYudyXzXFAZO85H9wdL00UNgv9vNHyxqmQnB/ZI+v6DLxFnjBzesD/8VDN5cWU9gY5cyH9RIA4bZmxv9X5hxR8ezI7KY2opl0= Received: from AM7PR02CA0015.eurprd02.prod.outlook.com (2603:10a6:20b:100::25) by AM6PR08MB3496.eurprd08.prod.outlook.com (2603:10a6:20b:4e::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.19; Thu, 31 Mar 2022 09:05:24 +0000 Received: from AM5EUR03FT051.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:100:cafe::1e) by AM7PR02CA0015.outlook.office365.com (2603:10a6:20b:100::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.22 via Frontend Transport; Thu, 31 Mar 2022 09:05:24 +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 AM5EUR03FT051.mail.protection.outlook.com (10.152.16.246) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.19 via Frontend Transport; Thu, 31 Mar 2022 09:05:23 +0000 Received: ("Tessian outbound facaf1373bbd:v118"); Thu, 31 Mar 2022 09:05:22 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 8a766bf670d2a568 X-CR-MTA-TID: 64aa7808 Received: from 2580def8cc73.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 9509DD94-2593-4359-A70B-8424823214CE.1; Thu, 31 Mar 2022 09:05:21 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 2580def8cc73.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 31 Mar 2022 09:05:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ky7Q3gNh+mPQHjclDeMGIPT11C7TyAB6eSa+A5pi71YLecqGOPhj5lhrLeaVHkqA5fXaKUikqU6kD4B5rd5krc4gTe6+s4Bv6VyUMHXzGm+uOVDoxi6Qcz6FCQugyrJ30+d55CEEo+gyjve4unTNAj6pxp1sipj2Hpy1VkAOJWnOMeKHmr8oegEOvwIOuB2cfJDjDCBEES4KzxTBFvaCHa+9JxjJlcEQlUMlvK3+AFWqvBfcokMrlN3TkGetPVvXkm63OgLaTTadEHQEfrj5X/EqTHYMYqQwSG+phVkWH82YbKWt0rzX7csBU4RFCuDU1eHOPp64unqOMI7eeS2fnw== 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=vA4AI49XG6dZSaNLKG20eE5ecagFSvtasAxzb3+wQbE=; b=WeG1aDADeYo7F5ZF22d44WLsrY+y/6NUOpPR5InB+hIYQ0fMTfK1Ohm8o3KuFIBT12JFgn1QHww1t0g1YxEUt0WIJl8LnSF2wTuKaqUMK9y9WCtF66gKl8dMwXHEl392wfe07yYDnhQF1mPs/yp51s2cr4daDVjiyIXkbKE6YABi9ZM9s/+mclApZE80bxaCWMCgjFaup5MV4t8hHTS5C0McfalsZq5moqSqSNtqu5fJG8X+J7aw3w6UKNTnNEFWYcaEcm9eBQXQkUGTuqd2w/SyzU6sDbYVIRJzEXz4wP0dt9XpXorBcdSUiOJ1fZjOVIyzqyuZmMFunJVcpJ8yZw== 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=vA4AI49XG6dZSaNLKG20eE5ecagFSvtasAxzb3+wQbE=; b=87GP7TsMmaGqklbWubICyN6/7GgKxSRK7CFIb8+GxUcP87Iymv2srBdgGDFEuTJ51cPtpgMapeUYudyXzXFAZO85H9wdL00UNgv9vNHyxqmQnB/ZI+v6DLxFnjBzesD/8VDN5cWU9gY5cyH9RIA4bZmxv9X5hxR8ezI7KY2opl0= 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 AM0PR08MB4068.eurprd08.prod.outlook.com (2603:10a6:208:12b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.19; Thu, 31 Mar 2022 09:05:05 +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.019; Thu, 31 Mar 2022 09:05:05 +0000 Message-ID: <37d60d0f-9911-7692-cdb6-62cd5da540ac@arm.com> Date: Thu, 31 Mar 2022 11:04:55 +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: =?UTF-8?Q?Mattias_R=c3=b6nnblom?= , "dev@dpdk.org" Cc: Thomas Monjalon , David Marchand , Onar Olsen , "Honnappa.Nagarahalli@arm.com" , "nd@arm.com" , "konstantin.ananyev@intel.com" , "mb@smartsharesystems.com" , "stephen@networkplumber.org" References: <98CBD80474FA8B44BF855DF32C47DC35D86F84@smartserver.smartshare.dk> <20220330142602.108061-1-mattias.ronnblom@ericsson.com> <3888e595-de18-3cf0-707b-309b153c2b02@ericsson.com> From: Ola Liljedahl In-Reply-To: <3888e595-de18-3cf0-707b-309b153c2b02@ericsson.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SN4PR0501CA0020.namprd05.prod.outlook.com (2603:10b6:803:40::33) To AM8PR08MB6498.eurprd08.prod.outlook.com (2603:10a6:20b:364::11) MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 53d666f2-f1ee-4397-fc85-08da12f596ab X-MS-TrafficTypeDiagnostic: AM0PR08MB4068:EE_|AM5EUR03FT051:EE_|AM6PR08MB3496: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: iP2fWFsUea6QQFxi8kUO3osD506t5OCbj2OEbrrzdikL3mf9IDWQCNah4q1pPPi51T6uwWH+C3w9aM4DalZxX7NDmDCXgyBJT1+WPvbQ5///Z/QA8YSdKuBaiI7yoV7sAjeJmIS/PXvFHgipfL3Np6Fe6zhfUDkZSNkVfDPlUX5UOl4J4Mub/NB1M3ofac/ykafAwrNHcMoDT+gkvd7wzdI1HwxcoXLgiKB8Fj5PLkfC7IGvkCIP+atQU/IEOqrmCsuOe4BESkmR+bdaonRIjG67JhxpI2fkCZN/pSEQyFLanUd17t3wW7h+64/tWmK18EIKBUsPyOrDas0WgcdbCRF66QAXbqcbtgSAHRyBUnR+Mk98r9UlmpNHYDMVRdYbvdIr2kcwTM+5Ly11LRAURcWVQesKiTc7qkyJXISttH8zVU7h4MyRRlRjHM4rj+wY/VRICzC1zhmvQyjXgaxBwqOdpo6mQy6gPXkZIcJScEASz2qyMwbFxpl4EEfg9xMZbLzZ/SM9OzCQXnOg/iwOqbVUldiYVsyLsY8w/nbdWBKz/U4n8iYiRStId+nb+yTCBqVM+j83Y1cz5Xx/DN3ITnz12WDd4SFbdTZnUTw7WwWp9+nHnJEKMgXX2jobWXM0cpGYIz/1jL27dPvyQUUmN1eupLMYLSPUb+Xd/Iwwkd3MBQCvwgzsydeudENrOrqfJn5Z/oMpu2tq0DU8b4aC4AlWnSZA6NmOwE6/3MDcuz8= 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)(2616005)(6512007)(6506007)(44832011)(8936002)(2906002)(36756003)(53546011)(31686004)(5660300002)(54906003)(110136005)(83380400001)(38100700002)(508600001)(31696002)(86362001)(8676002)(66476007)(4326008)(6486002)(26005)(66574015)(186003)(316002)(66946007)(66556008)(6666004)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB4068 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: AM5EUR03FT051.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: a34ea4fd-917e-4748-c62f-08da12f58bf2 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: seqQpiaoGLVZU8v3PWAk7KgkrWUby6NJ3T1onKc8tWsaIKfFYQTOHmbZj03OXTvA4G2kTUdEefGGLflnWfdDRsdemV3F5XIEgfByo1YkweX0xKdV/aDgUjoGSoQu43dKPfR6sH7wz03ReIJPoMwJMkeg414j+SihUO/+A4PKiflu9wAQyedsGF0Zg/jIzXrUuHZ2lEhWJ6J3WqL5n+EAelAbfNRShDPBpHN22EtvHqD0Uf5OjybZt9ttxnuzINZ6D7iKNbmf+hTjb0o++GHgfOdEHc1P8mNMMEi4Jvw7dwRh+uIhAvRJgwvBMeppC5hIw4kHftJxYQvB6Gbix8y5BkOWklhptILBIazOqUnNG8aJXvq6h+1mTgoUttObCk4crkESd1Svams6qpl3qAvlqsxKuUzwZUV02FDR4osNAG+jnplmxzEhmpnkw3u8lgF2DW9uY/pjOndjQma6gFLKAzih3+1pYoyXQ9FXu7izS3eKvK1H0XBySfSi8xS2Z31C3KlGWLidO2sDRG4/bsGnI6kGJUqmYYClduSFcPqVxXtmRRGqseC9QWnIZPW5zaz79DrBelpMpf752SWEvdkIeJGqi1utlzQD94G0SJ3FarLh7/+xgKNYL31Q4ptcPhvB+X7ErVfrtXUyhVmt4n785K7fJI6nxvKDmRoyUOqFPMXxT6rK9u7qSQiuaxB+aFINDfFC/wr+6AR/aClC+Ehuow== 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)(46966006)(36840700001)(40470700004)(70206006)(2616005)(336012)(86362001)(66574015)(81166007)(356005)(107886003)(4326008)(31696002)(82310400004)(186003)(8936002)(8676002)(54906003)(26005)(316002)(5660300002)(44832011)(70586007)(6666004)(110136005)(83380400001)(47076005)(53546011)(36756003)(6506007)(40460700003)(6512007)(2906002)(6486002)(31686004)(508600001)(36860700001)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2022 09:05:23.0018 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 53d666f2-f1ee-4397-fc85-08da12f596ab 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: AM5EUR03FT051.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3496 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 3/31/22 09:46, Mattias Rönnblom wrote: > On 2022-03-30 16:26, Mattias Rönnblom wrote: >> A sequence lock (seqlock) is synchronization primitive which allows >> for data-race free, low-overhead, high-frequency reads, especially for >> data structures shared across many cores and which are updated with >> relatively infrequently. >> >> > > > > Some questions I have: > > Is a variant of the seqlock without the spinlock required? The reason I > left such out was that I thought that in most cases where only a single > writer is used (or serialization is external to the seqlock), the > spinlock overhead is negligible, since updates are relatively infrequent. You can combine the spinlock and the sequence number. Odd sequence number means the seqlock is busy. That would replace a non-atomic RMW of the sequence number with an atomic RMW CAS and avoid the spin lock atomic RMW operation. Not sure how much it helps. > > Should the rte_seqlock_read_retry() be called rte_seqlock_read_end(), or > some third alternative? I wanted to make clear it's not just a "release > the lock" function. You could use > the|||__attribute__((warn_unused_result)) annotation to make clear the > return value cannot be ignored, although I'm not sure DPDK ever use that > attribute. We have to decide how to use the seqlock API from the application perspective. Your current proposal: do { sn = rte_seqlock_read_begin(&seqlock) //read protected data } while (rte_seqlock_read_retry(&seqlock, sn)); or perhaps sn = rte_seqlock_read_lock(&seqlock); do { //read protected data } while (!rte_seqlock_read_tryunlock(&seqlock, &sn)); Tryunlock should signal to the user that the unlock operation might not succeed and something needs to be repeated. -- Ola