Re: [PATCH v3] eal: add seqlock

2022-04-08 Thread Mattias Rönnblom
On 2022-04-03 19:37, Honnappa Nagarahalli wrote: + * Example usage: + * @code{.c} + * #define MAX_Y_LEN (16) + * // Application-defined example data structure, protected by a seqlock. + * struct config { + * rte_seqlock_t lock; + * int param_x; + * char param_y[MAX_Y_

RE: [PATCH v3] eal: add seqlock

2022-04-04 Thread Honnappa Nagarahalli
> > > +__rte_experimental > +static inline void > +rte_seqlock_write_lock(rte_seqlock_t *seqlock) { > + uint32_t sn; > + > + /* to synchronize with other writers */ > + rte_spinlock_lock(&seqlock->lock); > + > + sn = seqlock->sn + 1; > >>> The load

Re: [PATCH v3] eal: add seqlock

2022-04-03 Thread Ola Liljedahl
+__rte_experimental +static inline void +rte_seqlock_write_lock(rte_seqlock_t *seqlock) { + uint32_t sn; + + /* to synchronize with other writers */ + rte_spinlock_lock(&seqlock->lock); + + sn = seqlock->sn + 1; >>> The load of seqlock->sn could use

Re: [PATCH v3] eal: add seqlock

2022-04-03 Thread Ola Liljedahl
(Now using macOS Mail program in plain text mode, hope this works) > On 2 Apr 2022, at 21:31, Honnappa Nagarahalli > wrote: > > > >>> +__rte_experimental >>> +static inline bool >>> +rte_seqlock_read_tryunlock(const rte_seqlock_t *seqlock, uint32_t >>> +*begin_sn) { >>> + uint32_t end_sn; >

RE: [PATCH v3] eal: add seqlock

2022-04-03 Thread Honnappa Nagarahalli
> > >> + * Example usage: > >> + * @code{.c} > >> + * #define MAX_Y_LEN (16) > >> + * // Application-defined example data structure, protected by a seqlock. > >> + * struct config { > >> + * rte_seqlock_t lock; > >> + * int param_x; > >> + * char param_y[MAX_Y_LEN]; > >>

RE: [PATCH v3] eal: add seqlock

2022-04-03 Thread Honnappa Nagarahalli
> >> a/app/test/test_seqlock.c b/app/test/test_seqlock.c new file mode > >> 100644 index 00..54fadf8025 > >> --- /dev/null > >> +++ b/app/test/test_seqlock.c > >> @@ -0,0 +1,202 @@ > >> +/* SPDX-License-Identifier: BSD-3-Clause > >> + * Copyright(c) 2022 Ericsson AB > >> + */ > >> + > >>

Re: [PATCH v3] eal: add seqlock

2022-04-02 Thread Mattias Rönnblom
On 2022-04-02 20:15, Ola Liljedahl wrote: On 4/1/22 17:07, Mattias Rönnblom wrote: + +/** + * End a read-side critical section. + * + * A call to this function marks the end of a read-side critical + * section, for @p seqlock. The application must supply the sequence + * number produced by the c

Re: [PATCH v3] eal: add seqlock

2022-04-02 Thread Mattias Rönnblom
I missed some of your comments. On 2022-04-02 02:21, Honnappa Nagarahalli wrote: + * Example usage: + * @code{.c} + * #define MAX_Y_LEN (16) + * // Application-defined example data structure, protected by a seqlock. + * struct config { + * rte_seqlock_t lock; + * int param_x;

Re: [PATCH v3] eal: add seqlock

2022-04-02 Thread Mattias Rönnblom
; konstantin.anan...@intel.com; m...@smartsharesystems.com; step...@networkplumber.org; Mattias Rönnblom ; Ola Liljedahl Subject: [PATCH v3] eal: add seqlock A sequence lock (seqlock) is synchronization primitive which allows for data- race free, low-overhead, high-frequency reads, especially for data

RE: [PATCH v3] eal: add seqlock

2022-04-02 Thread Honnappa Nagarahalli
> > > > > > +__rte_experimental > > > > +static inline bool > > > > +rte_seqlock_read_tryunlock(const rte_seqlock_t *seqlock, uint32_t > > > > +*begin_sn) { > > > > + uint32_t end_sn; > > > > + > > > > + /* make sure the data loads happens before the sn load */ > > > > + rte_atom

RE: [PATCH v3] eal: add seqlock

2022-04-02 Thread Morten Brørup
> From: Honnappa Nagarahalli [mailto:honnappa.nagaraha...@arm.com] > Sent: Saturday, 2 April 2022 21.31 > > > > > > +__rte_experimental > > > +static inline bool > > > +rte_seqlock_read_tryunlock(const rte_seqlock_t *seqlock, uint32_t > > > +*begin_sn) { > > > + uint32_t end_sn; > > > + > > > +

RE: [PATCH v3] eal: add seqlock

2022-04-02 Thread Honnappa Nagarahalli
> > > > +__rte_experimental > > > +static inline bool > > > +rte_seqlock_read_tryunlock(const rte_seqlock_t *seqlock, uint32_t > > > +*begin_sn) { > > Did anyone object to adding the __attribute__((warn_unused_result))? > > Otherwise, I think you should add it. +1

RE: [PATCH v3] eal: add seqlock

2022-04-02 Thread Honnappa Nagarahalli
> > +__rte_experimental > > +static inline bool > > +rte_seqlock_read_tryunlock(const rte_seqlock_t *seqlock, uint32_t > > +*begin_sn) { > > + uint32_t end_sn; > > + > > + /* make sure the data loads happens before the sn load */ > > + rte_atomic_thread_fence(__ATOMIC_ACQUIRE); > > + > > +

Re: [PATCH v3] eal: add seqlock

2022-04-02 Thread Ola Liljedahl
On 4/1/22 17:07, Mattias Rönnblom wrote: + +/** + * End a read-side critical section. + * + * A call to this function marks the end of a read-side critical + * section, for @p seqlock. The application must supply the sequence + * number produced by the corresponding rte_seqlock_read_lock() (or, +

RE: [PATCH v3] eal: add seqlock

2022-04-02 Thread Morten Brørup
> From: Honnappa Nagarahalli [mailto:honnappa.nagaraha...@arm.com] > Sent: Saturday, 2 April 2022 02.22 > > > From: Mattias Rönnblom > > Sent: Friday, April 1, 2022 10:08 AM > > > > diff --git a/lib/eal/include/rte_seqlock.h > > b/lib/eal/include/rte_seqlock.h new file > Other lock implementation

RE: [PATCH v3] eal: add seqlock

2022-04-01 Thread Honnappa Nagarahalli
tin.anan...@intel.com; m...@smartsharesystems.com; > step...@networkplumber.org; Mattias Rönnblom > ; Ola Liljedahl > Subject: [PATCH v3] eal: add seqlock > > A sequence lock (seqlock) is synchronization primitive which allows for data- > race free, low-overhead, high-frequency read

[PATCH v3] eal: add seqlock

2022-04-01 Thread Mattias Rönnblom
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. A seqlock permits multiple parallel readers. The variant of seqloc