Re: [PATCH] m32r: Revise __raw_read_trylock()

From: Matthew Wilcox
Date: Tue Sep 26 2006 - 18:30:20 EST

On Tue, Sep 26, 2006 at 02:33:44PM -0700, Andrew Morton wrote:
> We don't have a changelog for this patch. My usual technique when this
> happens is to mutter something unprintable then go on a hunt through the
> mailing list archives.
> But all I have is "Matthew Wilcox pointed out that
> generic__raw_read_trylock() is unfit for use.".
> What's wrong with it?

I pointed it out on linux-arch a couple of weeks ago. Ever look at the
generic__raw_read_trylock implementation?

$ git-diff linus spinlock.c
diff --git a/kernel/spinlock.c b/kernel/spinlock.c
index fb524b0..6fc4c92 100644
--- a/kernel/spinlock.c
+++ b/kernel/spinlock.c
@@ -16,17 +16,6 @@ #include <linux/interrupt.h>
#include <linux/debug_locks.h>
#include <linux/module.h>

- * Generic declaration of the raw read_trylock() function,
- * architectures are supposed to optimize this:
- */
-int __lockfunc generic__raw_read_trylock(raw_rwlock_t *lock)
- __raw_read_lock(lock);
- return 1;

If the cpu has the lock held for write, is interrupted, and the interrupt
handler calls read_trylock(), it's an instant deadlock.

Now, Dave Miller has subsequently pointed out that we don't have any
situations where this can occur. Nevertheless, we should delete
generic__raw_read_lock (and its associated EXPORT to make Arjan happy)
so that nobody thinks they can use it.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at