public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
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:28:57 -0700	[thread overview]
Message-ID: <522F48C9.3060606@linaro.org> (raw)
In-Reply-To: <20130910084340.GL26785@twins.programming.kicks-ass.net>

On 09/10/2013 01:43 AM, Peter Zijlstra wrote:
> On Mon, Sep 09, 2013 at 09:42:46PM -0700, John Stultz wrote:
>> Currently seqlocks and seqcounts don't support lockdep.
>>
>> After running across a seqcount related deadlock in the timekeeping
>> code, I used a less-refined and more focused varient of this patch
>> to narrow down the cause of the issue.
>>
>> This is a first-pass attempt to properly enable lockdep functionality
>> on seqlocks and seqcounts.
>>
>> Due to seqlocks/seqcounts having slightly different possible semantics
>> then standard locks (ie: reader->reader and reader->writer recursion is
>> fine, but writer->reader is not), this implementation is probably not
>> as exact as I'd like (currently using a hack by only spot checking
>> readers), and may be overly strict in some cases.
>>
>> I've handled one cases where there were nested seqlock writers, and
>> there may be more edge cases, as while I've gotten it to run cleanly,
>> depending on config its reporting issues that I'm not sure if they are
>> flaws in the implementation or actual bugs. But I wanted to send this
>> out for some initial thoughts as until today I hadn't looked at much
>> of the lockdep infrastructure. So I'm sure there are improvements
>> that could be made.
>>
>> Comments and feedback would be appreciated!
>> --- a/arch/x86/vdso/vclock_gettime.c
>> +++ b/arch/x86/vdso/vclock_gettime.c
>> @@ -178,13 +178,15 @@ notrace static int __always_inline do_realtime(struct timespec *ts)
>>  
>>  	ts->tv_nsec = 0;
>>  	do {
>> -		seq = read_seqcount_begin(&gtod->seq);
>> +		seq = __read_seqcount_begin(&gtod->seq);
>> +		smp_rmb();
>>  		mode = gtod->clock.vclock_mode;
>>  		ts->tv_sec = gtod->wall_time_sec;
>>  		ns = gtod->wall_time_snsec;
>>  		ns += vgetsns(&mode);
>>  		ns >>= gtod->clock.shift;
>> -	} while (unlikely(read_seqcount_retry(&gtod->seq, seq)));
>> +		smp_rmb();
>> +	} while (unlikely(__read_seqcount_retry(&gtod->seq, seq)));
>>  
>>  	timespec_add_ns(ts, ns);
>>  	return mode;
>
> You didn't mention the VDSO 'fun' in you Changelog!

No, although its not any net change. I'll clean it up w/ a helper
function so that we're not doing the memory barriers in the logic here.
That should simplify the diff a bit.

thanks
-john

  reply	other threads:[~2013-09-10 16:29 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 [this message]
2013-09-10  8:55 ` Peter Zijlstra
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=522F48C9.3060606@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox