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 04599A0503; Fri, 25 Mar 2022 22:10:40 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9C4DE40687; Fri, 25 Mar 2022 22:10:40 +0100 (CET) Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) by mails.dpdk.org (Postfix) with ESMTP id 974B540140 for ; Fri, 25 Mar 2022 22:10:38 +0100 (CET) Received: by mail-pg1-f169.google.com with SMTP id c11so7372193pgu.11 for ; Fri, 25 Mar 2022 14:10:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DQlks1R7t57OY82l/+Sw6nm4/4xNR01ypzEHeBZEhKA=; b=GVo7/cXC6x7yeRQt0Ahp3hGydwqUYpDFQW7P5maUCy9TEJ2dst9LclA7jY/sbDQGJI KlO0Dum+eTcA0+cXGALt0KPbPIVjwKCDpPEGaANDeJsGWqp0Dd2wcBwhNTUWdKXELYxI jO0VWcCbgH/A8rvW6yF5uutjS5euJk7hZ6CZ3P+ET8MfEjz3Dh6v5LybSTigJfDMQOm+ FYsAYv8gzDeZEdIpdldGvFcjEFXr4tZsVQRWEF+2uTZ5BFAf+/DY/mS+0SEZkF6QRjpE 6I3FMmloidhudkvxvoeAfMJtP61HUrb2b3uscnqBeaoamq+koC9KhEd6QTA90xNq2lHO Ge1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DQlks1R7t57OY82l/+Sw6nm4/4xNR01ypzEHeBZEhKA=; b=HOzGShSLMR4CPcbtB88vdu9CqgiHBYqLXEutEAefwc+qWgCD6Y9qw7nfGLXEUfOC/N DMTJDAjj4ck98QS7gBbIlD0PwTmUMQC+aB0Z2WCNplEu1wTp4V1U+hGE60Uk4B/ltw9a ce4FqxCfvEWiNgejNISFQGBum+ctw4Ck15HeWYlXk+VRBMivpm7pbLpacO7TPflSqlI3 tWQ4/EIFgJlsmGT0mXQbUQMUIscn/5DAMDOmpuiyOw+K/FIJcVc3CGhp8NbSazvfqzJQ illVW4HNw53m5WEH6QLI34xhTOb6vB5R1e2aOjhvtGUfzu67J1DRriPy563hxvzlgfkp 2U4Q== X-Gm-Message-State: AOAM533WW3zVR4iY7VRNLOcmQXgmcgpO/x49D+wXWAFhBB5CVPBEZi4s DErXFAZHqbaG/Exd+xroPTg05A== X-Google-Smtp-Source: ABdhPJxNnOb2zNeMFb8Hn2BRfPRiBiCJ6Nk//8aicERjotSIQbTmKJEPxNIeq59Qd8T2D0AR2NYqkw== X-Received: by 2002:a05:6a00:140f:b0:4e0:6995:9c48 with SMTP id l15-20020a056a00140f00b004e069959c48mr11953757pfu.59.1648242637505; Fri, 25 Mar 2022 14:10:37 -0700 (PDT) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id k17-20020a056a00135100b004fa9df39517sm8282277pfu.198.2022.03.25.14.10.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 14:10:36 -0700 (PDT) Date: Fri, 25 Mar 2022 14:10:33 -0700 From: Stephen Hemminger To: Mattias =?UTF-8?B?UsO2bm5ibG9t?= Cc: , Thomas Monjalon , David Marchand , , , , , , "Ola Liljedahl" Subject: Re: [RFC] eal: add seqlock Message-ID: <20220325141033.3cbdcb8d@hermes.local> In-Reply-To: <20220325202428.94628-1-mattias.ronnblom@ericsson.com> References: <20220325202428.94628-1-mattias.ronnblom@ericsson.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 Fri, 25 Mar 2022 21:24:28 +0100 Mattias R=C3=B6nnblom wrote: > diff --git a/lib/eal/include/rte_seqlock.h b/lib/eal/include/rte_seqlock.h > new file mode 100644 > index 0000000000..b975ca848a > --- /dev/null > +++ b/lib/eal/include/rte_seqlock.h > @@ -0,0 +1,84 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(c) 2022 Ericsson AB > + */ > + > +#ifndef _RTE_SEQLOCK_H_ > +#define _RTE_SEQLOCK_H_ > + > +#include > +#include > + > +#include > +#include > +#include > + > +struct rte_seqlock { > + uint64_t sn; > + rte_spinlock_t lock; > +}; > + > +typedef struct rte_seqlock rte_seqlock_t; > + Add a reference to Wikipedia and/or Linux since not every DPDK user maybe familar with this. > + > + sn =3D seqlock->sn + 1; > + > + __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); Could this just be __atomic_fetch_add() with __ATOMIC_RELEASE?