Strange Badness with RT Spin Lock
From: Darcy Watkins <hidden>
Date: 2008-08-08 19:56:13
Hello,
I have a very unusual bug I have been trying to get to the bottom of.
First the background...
AMCC PPC405EP on embedded network device (simpler than a Taihu)
Kernel 2.6.25.8-rt7 with incremental patches up to 2.6.25.13
mPCI slot with a WiMax radio card
This is an RT-Preemption kernel.
In my system, in a real time radio (WiMax) driver, I have code that
makes use of a spinlock to control access to a tree structure...
spinlock_t tree_lock;
...
Then I added the following to check if my code is about to generate a
kernel oops that normally happens when a spinlock is locked twice by the
same task. I did this because I can't find any logical code path that
would cause it to be locked twice so now I look for strange badness.
Note that in an RT Preemption kernel, the spinlock is implemented using
rtmutex.
#define USE_MUTEX_CHECK_HACK 1
#ifdef USE_MUTEX_CHECK_HACK
// This is just a temporary debug hack lifted from rtmutex code in the kernel.
#define RT_MUTEX_OWNER_MASKALL 3UL
static inline struct task_struct *rt_mutex_owner(spinlock_t * lock)
{
struct rt_mutex * rtlock = (struct rt_mutex *)lock;
return (struct task_struct *)
((unsigned long)rtlock->owner & ~RT_MUTEX_OWNER_MASKALL);
}
#define MUTEX_CHECK_SAVE_LOCKED \
spinlock_t saved_locked = tree_lock;