From: Peter Zijlstra <peterz@infradead.org>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Boqun Feng <boqun.feng@gmail.com>, Ingo Molnar <mingo@redhat.com>,
Rik van Riel <riel@surriel.com>,
Thomas Gleixner <tglx@linutronix.de>,
Waiman Long <longman@redhat.com>, Will Deacon <will@kernel.org>,
Alexey Gladkov <legion@kernel.org>,
"Eric W. Biederman" <ebiederm@xmission.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/5] seqlock: simplify SEQCOUNT_LOCKNAME()
Date: Sat, 16 Sep 2023 10:51:17 +0200 [thread overview]
Message-ID: <20230916085117.GA35156@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20230913154953.GA26242@redhat.com>
On Wed, Sep 13, 2023 at 05:49:53PM +0200, Oleg Nesterov wrote:
> 1. Kill the "lockmember" argument. It is always s->lock plus
> __seqprop_##lockname##_sequence() already uses s->lock and
> ignores "lockmember".
>
> 2. Kill the "lock_acquire" argument. __seqprop_##lockname##_sequence()
> can use the same "lockbase" prefix for _lock and _unlock.
>
> Apart from line numbers, gcc -E outputs the same code.
With seqlock_ww_mutex gone, yes this is a nice cleanup.
>
> Signed-off-by: Oleg Nesterov <oleg@redhat.com>
> ---
> include/linux/seqlock.h | 18 ++++++++----------
> 1 file changed, 8 insertions(+), 10 deletions(-)
>
> diff --git a/include/linux/seqlock.h b/include/linux/seqlock.h
> index 987a59d977c5..ac6631bd5706 100644
> --- a/include/linux/seqlock.h
> +++ b/include/linux/seqlock.h
> @@ -191,11 +191,9 @@ static inline void seqcount_lockdep_reader_access(const seqcount_t *s)
> * @lockname: "LOCKNAME" part of seqcount_LOCKNAME_t
> * @locktype: LOCKNAME canonical C data type
> * @preemptible: preemptibility of above locktype
> - * @lockmember: argument for lockdep_assert_held()
> - * @lockbase: associated lock release function (prefix only)
> - * @lock_acquire: associated lock acquisition function (full call)
> + * @lockbase: prefix for associated lock/unlock
> */
> -#define SEQCOUNT_LOCKNAME(lockname, locktype, preemptible, lockmember, lockbase, lock_acquire) \
> +#define SEQCOUNT_LOCKNAME(lockname, locktype, preemptible, lockbase) \
> typedef struct seqcount_##lockname { \
> seqcount_t seqcount; \
> __SEQ_LOCK(locktype *lock); \
> @@ -216,7 +214,7 @@ __seqprop_##lockname##_sequence(const seqcount_##lockname##_t *s) \
> return seq; \
> \
> if (preemptible && unlikely(seq & 1)) { \
> - __SEQ_LOCK(lock_acquire); \
> + __SEQ_LOCK(lockbase##_lock(s->lock)); \
> __SEQ_LOCK(lockbase##_unlock(s->lock)); \
> \
> /* \
> @@ -242,7 +240,7 @@ __seqprop_##lockname##_preemptible(const seqcount_##lockname##_t *s) \
> static __always_inline void \
> __seqprop_##lockname##_assert(const seqcount_##lockname##_t *s) \
> { \
> - __SEQ_LOCK(lockdep_assert_held(lockmember)); \
> + __SEQ_LOCK(lockdep_assert_held(s->lock)); \
> }
>
> /*
> @@ -271,10 +269,10 @@ static inline void __seqprop_assert(const seqcount_t *s)
>
> #define __SEQ_RT IS_ENABLED(CONFIG_PREEMPT_RT)
>
> -SEQCOUNT_LOCKNAME(raw_spinlock, raw_spinlock_t, false, s->lock, raw_spin, raw_spin_lock(s->lock))
> -SEQCOUNT_LOCKNAME(spinlock, spinlock_t, __SEQ_RT, s->lock, spin, spin_lock(s->lock))
> -SEQCOUNT_LOCKNAME(rwlock, rwlock_t, __SEQ_RT, s->lock, read, read_lock(s->lock))
> -SEQCOUNT_LOCKNAME(mutex, struct mutex, true, s->lock, mutex, mutex_lock(s->lock))
> +SEQCOUNT_LOCKNAME(raw_spinlock, raw_spinlock_t, false, raw_spin)
> +SEQCOUNT_LOCKNAME(spinlock, spinlock_t, __SEQ_RT, spin)
> +SEQCOUNT_LOCKNAME(rwlock, rwlock_t, __SEQ_RT, read)
> +SEQCOUNT_LOCKNAME(mutex, struct mutex, true, mutex)
>
> /*
> * SEQCNT_LOCKNAME_ZERO - static initializer for seqcount_LOCKNAME_t
> --
> 2.25.1.362.g51ebf55
>
next prev parent reply other threads:[~2023-09-16 8:54 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-13 15:49 [PATCH 0/5] turn signal_struct.stats_lock into seqcount_rwlock_t Oleg Nesterov
2023-09-13 15:49 ` [PATCH 1/5] seqlock: simplify SEQCOUNT_LOCKNAME() Oleg Nesterov
2023-09-15 17:36 ` Alexey Gladkov
2023-09-16 8:51 ` Peter Zijlstra [this message]
2023-09-21 11:48 ` Oleg Nesterov
2023-09-21 14:04 ` Peter Zijlstra
2023-09-21 14:31 ` Oleg Nesterov
2023-09-13 15:49 ` [PATCH 2/5] seqlock: change __seqprop() to return the function pointer Oleg Nesterov
2023-09-13 17:37 ` kernel test robot
2023-09-13 18:30 ` Oleg Nesterov
2023-09-13 17:59 ` kernel test robot
2023-09-13 19:23 ` kernel test robot
2023-09-13 15:50 ` [PATCH 3/5] seqlock: introduce seqprop_lock/unlock Oleg Nesterov
2023-09-15 18:25 ` Alexey Gladkov
2023-09-15 18:43 ` Oleg Nesterov
2023-09-13 15:50 ` [PATCH 4/5] seqlock: introduce read_seqcount_begin_or_lock() and friends Oleg Nesterov
2023-09-13 15:50 ` [PATCH 5/5] time,signal: turn signal_struct.stats_lock into seqcount_rwlock_t Oleg Nesterov
2023-09-23 12:37 ` Alexey Gladkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230916085117.GA35156@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=boqun.feng@gmail.com \
--cc=ebiederm@xmission.com \
--cc=legion@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mingo@redhat.com \
--cc=oleg@redhat.com \
--cc=riel@surriel.com \
--cc=tglx@linutronix.de \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox