From: John Stultz <john.stultz@linaro.org>
To: Peter Zijlstra <peterz@infradead.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 09:32:35 -0700 [thread overview]
Message-ID: <522F49A3.5000700@linaro.org> (raw)
In-Reply-To: <20130910085545.GM26785@twins.programming.kicks-ass.net>
On 09/10/2013 01:55 AM, Peter Zijlstra wrote:
> 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().
So since reader->writer recurision is ok, as is reader->reader
recurision, I wanted to avoid lockdep false positives if an irq lands in
between the aquire/release calls. So by doing the acquire/release w/
irqs off on the read side, we only trap the writer->reader recursion issues.
And agreed, the preempt_disable is overdoing it :)
Thanks for the review!
-john
prev parent reply other threads:[~2013-09-10 16:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-10 4:42 [PATCH] [RFC] seqcount: Add lockdep functionality to seqcount/seqlock structures 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
2013-09-10 16:32 ` John Stultz [this message]
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=522F49A3.5000700@linaro.org \
--to=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.