On Sun, 12 Jan 2003, Christoph Hellwig wrote:
>
> 2.5 does hold the BKL on ->open of charater- (and block-) devices.
Ahh, my bad.
> The real problem is that the big irqlock is gone and mingo just replaced
> it with local_irq_save & friends, which is not enough.
Ok, most of them should be fixable with a simple spinlock approach.
If the recursion is too nasty to handle, we could make some tty-specific
recursive spinlock as a stop-gap measure, and mark it as being destined
for the garbage-heap in 2.7.x:
/*
* This isn't even _trying_ to be fast!
*/
struct recursive_spinlock {
spinlock_t lock;
int lock_count;
struct task_struct *lock_owner;
};
static struct recursive_spinlock tty_lock = {
.lock = SPIN_LOCK_UNLOCKED,
.lock_count = 0,
.lock_owner = NULL
};
unsigned long tty_spin_lock(void)
{
unsigned long flags;
struct task_struct *tsk;
local_irq_save(flags);
preempt_disable();
tsk = current;
if (spin_trylock(&tty_lock.lock))
goto got_lock;
if (tsk == tty_lock.lock_owner) {
WARN_ON(!tty_lock.lock_count);
tty_lock.lock_count++;
return flags;
}
spin_lock(&tty_lock.lock);
got_lock:
WARN_ON(tty_lock.lock_owner);
WARN_ON(tty_lock.lock_count);
tty_lock.lock_owner = tsk;
tty_lock.lock_count = 1;
return flags;
}
void tty_spin_unlock(unsigned long flags)
{
WARN_ON(tty_lock.lock_owner != current);
WARN_ON(!tty_lock.lock_count);
if (!--tty_lock.lock_count) {
tty_lock.lock_owner = NULL;
spin_unlock(&tty_lock.lock);
}
preempt_enable();
local_irq_restore(flags);
}
and be done with it.
Anybody willing to test it and see if the above works?
Linus
-
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/
This archive was generated by hypermail 2b29 : Wed Jan 15 2003 - 22:00:41 EST