From: Peter Zijlstra <peterz@infradead.org>
To: John Stultz <john.stultz@linaro.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
Ingo Molnar <mingo@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH] [RFC] seqcount: Add lockdep functionality to seqcount/seqlock structures
Date: Tue, 10 Sep 2013 10:55:45 +0200 [thread overview]
Message-ID: <20130910085545.GM26785@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <1378788166-18474-1-git-send-email-john.stultz@linaro.org>
On Mon, Sep 09, 2013 at 09:42:46PM -0700, John Stultz wrote:
> @@ -38,10 +39,58 @@
> */
> typedef struct seqcount {
> unsigned sequence;
> +#ifdef CONFIG_DEBUG_LOCK_ALLOC
> + struct lockdep_map dep_map;
> +#endif
> } seqcount_t;
>
> -#define SEQCNT_ZERO { 0 }
> -#define seqcount_init(x) do { *(x) = (seqcount_t) SEQCNT_ZERO; } while (0)
> +
> +
> +
> +static inline void __seqcount_init(seqcount_t *s, const char *name,
> + struct lock_class_key *key)
> +{
> +#ifdef CONFIG_DEBUG_LOCK_ALLOC
> + /*
> + * Make sure we are not reinitializing a held lock:
> + */
> + lockdep_init_map(&s->dep_map, name, key, 0);
> +#endif
> + s->sequence = 0;
> +}
> +
> +
> +#ifdef CONFIG_DEBUG_LOCK_ALLOC
> +# define SEQCOUNT_DEP_MAP_INIT(lockname) \
> + .dep_map = { .name = #lockname } \
> +
> +# define seqcount_init(s) \
> + do { \
> + static struct lock_class_key __key; \
> + __seqcount_init((s), #s, &__key); \
> + } while (0)
> +
> +static inline void seqcount_reader_access(const seqcount_t *s)
> +{
> + seqcount_t *l = (seqcount_t *)s;
> + unsigned long flags;
> +
> + preempt_disable();
> + local_irq_save(flags);
> + seqcount_acquire_read(&l->dep_map, 0, 0, _RET_IP_);
> + seqcount_release(&l->dep_map, 1, _RET_IP_);
> + local_irq_restore(flags);
> + preempt_enable();
> +}
Why the preempt and local_irq thing? Also preempt_disable is quite
superfluous if you do local_irq_disable().
> +
> +#else
> +# define SEQCOUNT_DEP_MAP_INIT(lockname)
> +# define seqcount_init(s) __seqcount_init(s, NULL, NULL)
> +# define seqcount_reader_access(x)
> +#endif
> +
> +#define SEQCNT_ZERO(lockname) { .sequence = 0, SEQCOUNT_DEP_MAP_INIT(lockname)}
> +
next prev parent reply other threads:[~2013-09-10 8:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-10 4:42 John Stultz
2013-09-10 8:11 ` Peter Zijlstra
2013-09-10 9:19 ` Peter Zijlstra
2013-09-10 8:43 ` Peter Zijlstra
2013-09-10 16:28 ` John Stultz
2013-09-10 8:55 ` Peter Zijlstra [this message]
2013-09-10 16:32 ` John Stultz
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=20130910085545.GM26785@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/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
all inboxes | Powered by JetHome®