Re: [PATCH] atomic: Only take lock when the counter drops to zero on UP as well

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Jan Blunck
Date: Thursday, April 23, 2009 - 6:32 am

On Fri, Apr 17, Andrew Morton wrote:


Sorry, you are right. spin_lock() isn't the problem here. _raw_spin_lock()
calls into __spin_lock_debug():

static void __spin_lock_debug(spinlock_t *lock)
{
        u64 i;
        u64 loops = loops_per_jiffy * HZ;
        int print_once = 1;

        for (;;) {
                for (i = 0; i < loops; i++) {
                        if (__raw_spin_trylock(&lock->raw_lock))
                                return;
                        __delay(1);
                }
                /* lockup suspected: */
                if (print_once) {
                        print_once = 0;
                        printk(KERN_EMERG "BUG: spinlock lockup on CPU#%d, "
                                        "%s/%d, %p\n",
                                raw_smp_processor_id(), current->comm,
                                task_pid_nr(current), lock);
                        dump_stack();
#ifdef CONFIG_SMP
                        trigger_all_cpu_backtrace();
#endif
                }
        }
}

This is an endless loop in this cases since the lock is already held and
therefore __raw_spin_trylock() never succeeds.


Sorry, I'll come up with a more verbose description of the root cause of how
this locks up.

Cheers,
Jan
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH] atomic: Only take lock when the counter drops ..., Paul E. McKenney, (Sat Apr 11, 10:49 am)
Re: [PATCH] atomic: Only take lock when the counter drops ..., Paul E. McKenney, (Sun Apr 12, 11:02 pm)
Re: [PATCH] atomic: Only take lock when the counter drops ..., Paul E. McKenney, (Tue Apr 14, 9:48 am)
Re: [PATCH] atomic: Only take lock when the counter drops ..., Paul E. McKenney, (Wed Apr 22, 7:08 am)
Re: [PATCH] atomic: Only take lock when the counter drops ..., Jan Blunck, (Thu Apr 23, 6:32 am)