Re: mm,console: circular dependency between console_sem and zone lock

From: Peter Zijlstra
Date: Tue Jun 03 2014 - 04:47:56 EST


On Mon, Jun 02, 2014 at 09:55:29PM -0400, Steven Rostedt wrote:
> Hmm, it failed on a try lock, but on the spinlock within the trylock. I
> wonder if we should add this.
>
> Peter?
>
> -- Steve
>
> diff --git a/kernel/locking/semaphore.c b/kernel/locking/semaphore.c
> index 6815171..6579f84 100644
> --- a/kernel/locking/semaphore.c
> +++ b/kernel/locking/semaphore.c
> @@ -132,7 +132,9 @@ int down_trylock(struct semaphore *sem)
> unsigned long flags;
> int count;
>
> - raw_spin_lock_irqsave(&sem->lock, flags);
> + if (!raw_spin_trylock_irqsave(&sem->lock, flags))
> + return 1;
> +
> count = sem->count - 1;
> if (likely(count >= 0))
> sem->count = count;

I prefer not to, there is no reason the down_trylock() will fail if that
spinlock is contended. We might have just hit the release in progress.

But let me stare at the original problem..

Attachment: pgp_Z88SsuglZ.pgp
Description: PGP signature