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 948C4A0507; Thu, 31 Mar 2022 16:53:38 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5782E410FA; Thu, 31 Mar 2022 16:53:38 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2062.outbound.protection.outlook.com [40.107.20.62]) by mails.dpdk.org (Postfix) with ESMTP id 383BF4014F for ; Thu, 31 Mar 2022 16:53:37 +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=3G2l60qVu/7fAHvhS3HDFxxEWQ0BPXC5ADMvFGLbvdc=; b=xb4f4uvqtaw1zENlw6HYmGxZUsH2L3fb4zOCZuJIPQ3F3ZoqBFU9F4dRX85jQ30rt0y/BUd+RRiZqw8W7ECJrBTtl1BOLNuUAKbaAP5DeVZOeyhubkCJXkyqB/pIkZVdovVVT8v5q7nw5g75pz7ubC2N6pOhHjzgarQBVAqTSWs= Received: from AS8PR04CA0199.eurprd04.prod.outlook.com (2603:10a6:20b:2f3::24) by VI1PR08MB3184.eurprd08.prod.outlook.com (2603:10a6:803:41::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.16; Thu, 31 Mar 2022 14:53:16 +0000 Received: from VE1EUR03FT018.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:2f3:cafe::9b) by AS8PR04CA0199.outlook.office365.com (2603:10a6:20b:2f3::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.13 via Frontend Transport; Thu, 31 Mar 2022 14:53:16 +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 VE1EUR03FT018.mail.protection.outlook.com (10.152.18.135) 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 14:53:16 +0000 Received: ("Tessian outbound 9613c00560a5:v118"); Thu, 31 Mar 2022 14:53:15 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: da3b3d49b211d1ea X-CR-MTA-TID: 64aa7808 Received: from ab58bd61a9ce.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 869E5F45-1681-40C3-87DA-182FACF8CE1C.1; Thu, 31 Mar 2022 14:53:09 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id ab58bd61a9ce.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 31 Mar 2022 14:53:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W/Ekt4bdF6ecn4sTeIQRODg3bAH3siTJBHynPoIZEp/Yld7PIgqGRRD0Qx2HZeystbLh2qaVLP/dx8cv/d1qD6LQkgft0ZswNohQKdja6Vnd1nVIih4DzSucigNKP2VBKdEAEuiAEr4eQCatiYffF4d7UttDIfz+P+rmRtS+rZBuqE99A/o9geoNrh+C249Ky3mH7wjVTRprV+sI2WaDRi/AnTSaS+CDz3nOKfqnXVSjTHge6jGwUCb7o6qW8TilGNoyav54Z8M0eP5yB8xThcitrtJ/xhXUlyuH81gEzz+vLT6rCHOIot/VZAotGrBSoUYDXwa26yW37IiOqecNXg== 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=3G2l60qVu/7fAHvhS3HDFxxEWQ0BPXC5ADMvFGLbvdc=; b=U03n/i1t3oM7sbvfF9J89r8J4g7mZMJhIr7yOxZq9/h/YuZxkpEYfabe8pKMdwG/hFkHGQ8Xo7SmN52usNBJxMiJnt1DPuMW192OKH+5jB7dnDQzsz2p/VxiZmFwcUM4oYMdQhf295fhFgQmvJTLxvqSFXoGLrTn8df+ljJQYK0qwMGtUriyJwzcg2banlHjapR19fOKaH4GJVpQq+Z3LZJhrAzHHO87EwVJt905V+6nWs66Jv/QAECkwCvjq2fJUgUZim2sdavJzfhIZ3BaPhHZCeXUitgD7z0JKc+CmeUlkUO0vtTzT+5l+8NVXxGoh78vUYhrwU/swQ6GUDnDmA== 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=3G2l60qVu/7fAHvhS3HDFxxEWQ0BPXC5ADMvFGLbvdc=; b=xb4f4uvqtaw1zENlw6HYmGxZUsH2L3fb4zOCZuJIPQ3F3ZoqBFU9F4dRX85jQ30rt0y/BUd+RRiZqw8W7ECJrBTtl1BOLNuUAKbaAP5DeVZOeyhubkCJXkyqB/pIkZVdovVVT8v5q7nw5g75pz7ubC2N6pOhHjzgarQBVAqTSWs= 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 DBAPR08MB5576.eurprd08.prod.outlook.com (2603:10a6:10:1ae::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5102.17; Thu, 31 Mar 2022 14:53: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 14:53:04 +0000 Message-ID: <1094901f-ee27-8c49-d71f-825ec5bfe2ad@arm.com> Date: Thu, 31 Mar 2022 16:53:00 +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> <37d60d0f-9911-7692-cdb6-62cd5da540ac@arm.com> From: Ola Liljedahl In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: LO2P265CA0166.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9::34) To AM8PR08MB6498.eurprd08.prod.outlook.com (2603:10a6:20b:364::11) MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 179c283c-c33c-4fc1-f74d-08da13263022 X-MS-TrafficTypeDiagnostic: DBAPR08MB5576:EE_|VE1EUR03FT018:EE_|VI1PR08MB3184: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: NXo0fWXGvuPLH05nnr51X7kL3EaDsgc6a2VUOcMw/6gTrGA8T33DgJ6IF7tbR480V4XzBi6XANE6T7MC5sDlzn3yPHk/AbpuwelYbCpWcj7ms7W5vE+D48SUBntU74724aR5jTgEadGi3peQID0g30eKhFFI3nSVQN2JcQzKQxGMHNIXE0oJt8BNL+RHINKdgcDTCMx14NSgVPGADaItU7bODRFDjnzNDPbqgBb8yVu9g+m/UXMBoeKVvFV/eQ2/zduQsOECSF8czORGwOhOXdUxfLNKlKSvdeeCAtotOrJX9TZUN5aJR2ka8aq4FGPGhkd0yuDcGhUhuu4FeesjxhWexrQJnpViIeAE8RMLp4oXjKlIJPYfdRs/XCuAIqRjoXchrn+mk9Mm1kHTf2e+pMnQ/kDncikqXJ/3o+IfV1xpLq3OksE8QpEkXySNWabdRDUOWMKb87O2Cw4dF4FQNvs+Q+qvbASxoLkk13PVf6/Dp5DPutTcPTE1b1Lytc+AZAjuQuR5J+WduDVWvbWwzf/6c/8Jhrjcp3AmFU5V/jH+lenAnRthKQTTUmQQ79SJNMt2cZdCf3k4SxKxRcYNZ2F4fdzYX5JFW6qQ1StI9l8fwbQ5Z5iDTvAYieOrD3gzFctPeFtN/llZFvcBvCCcHDnEFspSLDsZ+YcoIvMXr2Pl+fKycYlR+/Z2+Mi6p3yLXqbPqGjUjuYC08xLL1JUVqZiUW+rRY8t6Oj1lcKJ930+MprxN7pmC8EX1B3SYyx/rt2biaZoCDIfKcBcIncikaGLduqrFPwouOgLdIPuZRiTu129hwkrXy81JO/4BCJ4 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)(6506007)(8936002)(5660300002)(4326008)(31686004)(6666004)(66574015)(2906002)(36756003)(83380400001)(66476007)(44832011)(66556008)(31696002)(66946007)(38100700002)(316002)(86362001)(53546011)(966005)(186003)(54906003)(508600001)(110136005)(26005)(8676002)(2616005)(6512007)(6486002)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5576 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: VE1EUR03FT018.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 23842cc8-47c6-4cb4-3833-08da13262820 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ApkTHfcsGiQ9L5SptVgy9WDEn6oF/IDzo2d3bJ7uGa8tz+YmriUlY0KkMhI5/ieqwHJkkW1HfI+HTBzMhUt3HZ0etkRYkKba93lavbtYoX0avOovxGgAOLXFBmeTyJNVy1UizAsumYkA4dU3WN8+wyXtIyfSlwlelB3rZ1soRPQHN3ASLOOlTDN6Iau8I/j9HY8XLj0u0roPq2xgQdOEF75j89AIbtYo5y2T8e1O4pNHJXtT3RQd5XDj/dU7NTrUvCIqxRjZyvJHAWanXgiJdEskV0K781EwqDcMBmzmYFHe05jRUCq8OaRGa7bDuL9yOmnYHz/ZlKOSkPAzCR3qe5znli79pr/6KwpbPY99HkYbdWrAd+hPDXgywUBU7AjSynj3MtlsGjmhJiKNjWjbz6WrE8y51eeamxMPUMTFVymZfEWxxopGFsnePJSEBwVhotbznKW3OnB7fUjV52rnQ0oEgxCnYc2cwagJx0oC3D1etiawapswA6lYK4XLYVrnr+CdUczX7dO9t1RzwMexRjUAQYDYPs+DkgP0no+HIXuEpOfRA8z/cDKPTihjLcOqrdQnEpEX2p6bausv9KZNmMkjCdKelDl4sbPmhYOUJYA9OhCkjTGGkICMRg42L8A1fWCNjiPt58VJPZlCCwJ2GnwQpuJ138SeNBchkQgXwUJMcPcVMn8Dh4RJiYFVAhwkANihcaD6a4q66WOXXdeCx7SwmPhMvlidyo925zqkH5ISjw5ho9NiGXtt3Pgekc4BNZS2H6+MliXPKKIHqe/BKiOn7c9NaBoF4eSnkxctZok= 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)(8936002)(70206006)(70586007)(356005)(8676002)(186003)(26005)(81166007)(4326008)(2906002)(6506007)(6666004)(2616005)(44832011)(53546011)(107886003)(82310400004)(508600001)(40460700003)(86362001)(31696002)(966005)(6512007)(6486002)(47076005)(36860700001)(316002)(83380400001)(5660300002)(66574015)(36756003)(336012)(110136005)(54906003)(31686004)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2022 14:53:16.2535 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 179c283c-c33c-4fc1-f74d-08da13263022 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: VE1EUR03FT018.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3184 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 (Thunderbird suddenly refuses to edit in plain text mode, hope the mail gets sent as text anyway) On 3/31/22 15:38, Mattias Rönnblom wrote: > On 2022-03-31 11:04, Ola Liljedahl wrote: >> On 3/31/22 09:46, Mattias Rönnblom wrote: >>> On 2022-03-30 16:26, Mattias Rönnblom wrote: >>> >>> 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. >> > I like that your proposal is consistent with rwlock API, although I tend > to think about a seqlock more like an arbitrary-size atomic load/store, > where begin() is the beginning of the read transaction. I can see the evolution of an application where is starts to use plain spin locks, moves to reader/writer locks for better performance and eventually moves to seqlocks. The usage is the same, only the characteristics (including performance) differ. > > What I don't like so much with "tryunlock" is that it's not obvious what > return type and values it should have. I seem not to be the only one > which suffers from a lack of intuition here, since the DPDK spinlock > trylock() function returns '1' in case lock is taken (using an int, but > treating it like a bool), while the rwlock equivalent returns '0' (also > int, but treating it as an error code). Then you have two different ways of doing it! Or invent a third since there seems to be no consistent pattern. > > "lock" also suggests you prevent something from occurring, which is not > the case on the reader side. That's why my implementations in Progress64 use the terms acquire and release. Locks are acquired and released (with acquire and release semantics!). Hazard pointers are acquired and released (with acquire and release semantics!). Slots in reorder buffers are acquired and released. Etc. https://github.com/ARM-software/progress64 > A calling application also need not call > the reader unlock (or retry) function for all seqlocks it has locked, > although I don't see a point why it wouldn't. (I don't see why a > read-side critical section should contain much logic at all, since you > can't act on the just-read data.) Lock without unlock/retry is meaningless and not something we need to consider IMO. - Ola