> Well, I had that in one version of the patch, but people didn't think
> it would be useful. Maybe you'd like to check out Oliver's comments
> at http://marc.theaimsgroup.com/?l=linux-kernel&m=102644431806734&w=2
> and respond? If there's demand for MUST_NOT_HOLD, I'd be happy to add
> it since it should be easy. But if you're using it to enforce lock
> ordering as Oliver suggests, then there are probably more robust
> solutions.
Two other suggestions you could implement are CAN_SLEEP and
CANNOT_SLEEP. You can implement them via the preempt_count.
Even if CONFIG_PREEMPT is not set, you will get preempt_count values
representing whether or not you are in an interrupt or softirq (and thus
atomic and cannot sleep). If CONFIG_PREEMPT is set, you get a counter
that represents exactly the atomicity of the code including locks held.
E.g.,
#define CAN_SLEEP do { \
assert(unlikely(!preempt_count())); \
} while (0)
#define CANNOT_SLEEP do { \
assert(unlikely(preempt_count())); \
} while (0)
This works great because after the IRQ changes in 2.5.28, preempt_count
is a universal "are we atomic" count.
Robert Love
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/