Re: [RFC] seqlock,lockdep: Add lock primitives to read_seqbegin().

From: Steven Rostedt
Date: Mon Mar 28 2011 - 13:12:39 EST


On Sat, Mar 26, 2011 at 01:12:17PM +0900, Tetsuo Handa wrote:
> I got a freeze between "seqlock_t rename_lock" and "DEFINE_BRLOCK(vfsmount_lock)"

Egad, that DEFINE_BRLOCK() is a scary macro. Turns into DEFINE_LGLOCK()
and creates a local and global lock.


>
> But there is still a problem. It seems to me that lockdep checks for this bug
> only when a new locking pattern (a locking pattern which was not already added
> to lockdep database) is added. This freeze can be triggered by running
>
> while :; do newns /sbin/pivot_root /proc/ /proc/sys/; done
>
> on one terminal and running
>
> while :; do /bin/ls -l /proc/*/exe; done
>
> on another terminal. (The "newns" is a program that unshares the mnt namespace
> before execve() using CLONE_NEWNS.) But even after applying the patch above,
> lockdep does not show the trace above.
>
> lockdep shows the trace above only after I run test programs for TOMOYO (which
> causes a locking pattern that was generated by neither
> "/sbin/pivot_root /proc/ /proc/sys/" nor "/bin/ls -l /proc/*/exe" to be added
> to lockdep database).
>
> I think that we want some method for rechecking already added locking pattern.
> Maybe it is run by (e.g.) every 60 seconds. Maybe it is run when stall checking
> mechanisms report the possibility of stall. (The sysrq key didn't work after
> the freeze occurred.)

This is where you confused me. Why would a pattern that was previously
checked, suddenly break? If we found A->B and then come across B->A,
lockdep should surely catch it. Maybe I don't understand exactly whay
you are trying to say.

>
> Also, what to do with __read_seqcount_begin() case? Since seqcount_t does not
> have a spinlock embedded into the struct, we can't use lock primitives...?
>

We could probably just add a lockdep key to the seqcount, and "acquire"
and "release" it when necessary. I can look into that as I'm playing
around with lockdep now anyway ;)

-- Steve

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/