Re: [PATCH v3 06/20] seqlock: Extend seqcount API with associated locks

2020-07-08 Thread Peter Zijlstra
On Wed, Jul 08, 2020 at 05:58:13PM +0200, Ahmed S. Darwish wrote: > > I even considered: > > > > #define __SEQPROP(name, prop, expr) \ > > static __always_inline __seqprop_##prop##_t \ > > __seqprop##name##_##prop(seqcount##name##_t *s) \ > > { \ > > expr; \ > > } > > > > Such that we could wri

Re: [PATCH v3 06/20] seqlock: Extend seqcount API with associated locks

2020-07-08 Thread Peter Zijlstra
On Wed, Jul 08, 2020 at 05:58:13PM +0200, Ahmed S. Darwish wrote: > On Wed, Jul 08, 2020 at 05:35:22PM +0200, Peter Zijlstra wrote: > ... > > > > And while the gcc-4.8 code is horrendous crap, the rest should be pretty > > straight forward and concentrates on the pieces where there are > > differen

Re: [PATCH v3 06/20] seqlock: Extend seqcount API with associated locks

2020-07-08 Thread Peter Zijlstra
On Wed, Jul 08, 2020 at 05:35:22PM +0200, Peter Zijlstra wrote: > But I figured _that_ might've been one step too far ;-) Damn, now you made me do it... and it's not too horrible. Included the -rt part. --- diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h index 8b97204f35a7..cc15a6a

Re: [PATCH v3 06/20] seqlock: Extend seqcount API with associated locks

2020-07-08 Thread Ahmed S. Darwish
On Wed, Jul 08, 2020 at 05:35:22PM +0200, Peter Zijlstra wrote: ... > > And while the gcc-4.8 code is horrendous crap, the rest should be pretty > straight forward and concentrates on the pieces where there are > differences. > Is there any possibility of upgrading the minimum gcc version to 4.9?

Re: [PATCH v3 06/20] seqlock: Extend seqcount API with associated locks

2020-07-08 Thread Peter Zijlstra
On Wed, Jul 08, 2020 at 05:09:30PM +0200, Ahmed S. Darwish wrote: > On Wed, Jul 08, 2020 at 02:29:38PM +0200, Peter Zijlstra wrote: > > How about something disguisting like this then? > > > ... > > #define __SEQ_RTIS_BUILTIN(CONFIG_PREEMPT_RT) > > > > SEQCOUNT_LOCKTYPE(raw_spinlock, raw_spinlo

Re: [PATCH v3 06/20] seqlock: Extend seqcount API with associated locks

2020-07-08 Thread Ahmed S. Darwish
On Wed, Jul 08, 2020 at 02:29:38PM +0200, Peter Zijlstra wrote: > On Wed, Jul 08, 2020 at 12:33:14PM +0200, Ahmed S. Darwish wrote: > > > > +#define read_seqcount_begin(s) > > > do_read_seqcount_begin(__to_seqcount_t(s)) > > > + > > > +static inline unsigned do_read_seqcount_begin(const seqcount

Re: [PATCH v3 06/20] seqlock: Extend seqcount API with associated locks

2020-07-08 Thread Peter Zijlstra
On Wed, Jul 08, 2020 at 04:13:32PM +0200, Peter Zijlstra wrote: > On Wed, Jul 08, 2020 at 02:29:38PM +0200, Peter Zijlstra wrote: > > > #define SEQCOUNT_LOCKTYPE(name, locktype, preempt, lockmember) > > \ > > typedef struct seqcount_##name {\ > >

Re: [PATCH v3 06/20] seqlock: Extend seqcount API with associated locks

2020-07-08 Thread Peter Zijlstra
On Wed, Jul 08, 2020 at 02:29:38PM +0200, Peter Zijlstra wrote: > #define SEQCOUNT_LOCKTYPE(name, locktype, preempt, lockmember) > \ > typedef struct seqcount_##name { \ > seqcount_t seqcount; \ >

Re: [PATCH v3 06/20] seqlock: Extend seqcount API with associated locks

2020-07-08 Thread Peter Zijlstra
On Wed, Jul 08, 2020 at 12:33:14PM +0200, Ahmed S. Darwish wrote: > > +#define read_seqcount_begin(s) > > do_read_seqcount_begin(__to_seqcount_t(s)) > > + > > +static inline unsigned do_read_seqcount_begin(const seqcount_t *s) > > +{ > ... > > Hmm, the __to_seqcount_t(s) force cast is not go

Re: [PATCH v3 06/20] seqlock: Extend seqcount API with associated locks

2020-07-08 Thread Ahmed S. Darwish
On Wed, Jul 08, 2020 at 11:12:01AM +0200, Peter Zijlstra wrote: > On Tue, Jul 07, 2020 at 04:37:26PM +0200, Peter Zijlstra wrote: > > + * Use the ``_irqsave`` and ``_bh`` variants instead if the read side > > + * ``_bh`` variant of write_seqlock(). Use only if the read side section > > + * ``_irq``

Re: [PATCH v3 06/20] seqlock: Extend seqcount API with associated locks

2020-07-08 Thread Ahmed S. Darwish
On Tue, Jul 07, 2020 at 04:37:26PM +0200, Peter Zijlstra wrote: > > How's this? it removes a level of indirection and a bunch of repetition. ACK, for the extra level of indirection removed. > It's also more than 200 lines shorter. ... > +#define __to_seqcount_t(s) (seqcount_t *)(s) ... > +#defi

Re: [PATCH v3 06/20] seqlock: Extend seqcount API with associated locks

2020-07-08 Thread Peter Zijlstra
On Tue, Jul 07, 2020 at 04:37:26PM +0200, Peter Zijlstra wrote: > + * Use the ``_irqsave`` and ``_bh`` variants instead if the read side > + * ``_bh`` variant of write_seqlock(). Use only if the read side section > + * ``_irq`` variant of write_sequnlock(). The write side section of > + * ``_irqsav

Re: [PATCH v3 06/20] seqlock: Extend seqcount API with associated locks

2020-07-07 Thread Peter Zijlstra
On Tue, Jul 07, 2020 at 03:04:10PM +0200, Peter Zijlstra wrote: > Anyway, let me muck around with that a bit. How's this? it removes a level of indirection and a bunch of repetition. It doesn't provide SEQCNT_LOCKTYPE_ZERO() for each LOCKTYPE, but you can use this one macro for any LOCKTYPE. It

Re: [PATCH v3 06/20] seqlock: Extend seqcount API with associated locks

2020-07-07 Thread Peter Zijlstra
On Tue, Jul 07, 2020 at 10:40:24AM +0200, Ahmed S. Darwish wrote: > On Mon, Jul 06, 2020 at 11:21:48PM +0200, Peter Zijlstra wrote: > > On Tue, Jun 30, 2020 at 07:44:38AM +0200, Ahmed S. Darwish wrote: > > > +#include > > > > Why? why not include those lines directly here? Having it in a separate

Re: [PATCH v3 06/20] seqlock: Extend seqcount API with associated locks

2020-07-07 Thread Ahmed S. Darwish
On Mon, Jul 06, 2020 at 11:21:48PM +0200, Peter Zijlstra wrote: > On Tue, Jun 30, 2020 at 07:44:38AM +0200, Ahmed S. Darwish wrote: > > +#include > > Why? why not include those lines directly here? Having it in a separate > file actually makes it harder to read. > The seqlock_types_internal.h fil

Re: [PATCH v3 06/20] seqlock: Extend seqcount API with associated locks

2020-07-06 Thread Peter Zijlstra
On Tue, Jun 30, 2020 at 07:44:38AM +0200, Ahmed S. Darwish wrote: > +#include Why? why not include those lines directly here? Having it in a separate file actually makes it harder to read.

[PATCH v3 06/20] seqlock: Extend seqcount API with associated locks

2020-06-29 Thread Ahmed S. Darwish
A sequence counter write side critical section must be protected by some form of locking to serialize writers. If the serialization primitive is not disabling preemption implicitly, preemption has to be explicitly disabled before entering the write side critical section. There is no built-in debug