On Thu, Dec 17, 2009 at 01:25:44PM +0100, Andrew Lunn wrote:
This reminds me of something i keep intending to do, but never get around to.
It would be nice to have a LOCKING.TXT document, with the following Table of Contents.
What locks we have and what they protect.
What different contexts different parts of the code run in.
These two sections provide the basis for the following sections.
- Which locking primitives, ie spin_lock() or spin_lock_irqsave()
should be used for each lock.
- A list of what order locks should be taken in, when taking multiple
locks, so as to avoid deadlocks.
Yes, would be nice to have something like that, but Simon will change some of the stuff with the next (maybe not deadlocking) patch to remove the big b.a.t.m.a.n. lock. And I heard that Simon also wanted to change the way the packets get send... which probably changes context of each lock.
When finding this bug, did you take any notes etc, which could contribute to such a document?
Sry, I have no notes. I was just sitting next to Marek while discussing what we can do to provide a better working situation for you. This patch was just used to test the changes to git-svn and the pre-commit hooks of svn. The patch was only produced using the help of much to less sleep and some developer tea.
The documentation about the context in which each lock/function is used isn't really there for the kernel. As there are some upcoming changes we should wait until they are submitted. They should be generated while checking for new deadlocks introduced by them.
Best regards, Sven