I have a query related to the usage of spin_lock_irqsave() and
spin_lock() function calls.
lets say I am in some critical section and I have two different locks,
these locks are nested inside other, I can acquire these nested locks
in two ways, I am not sure which one is more justified. The two
possible way are as follows, please tell me the correct way?
spin_lock_irqsave(&x_lock, x_lock_flags) ;
.
spin_lock_irqsave(&y_lock, y_lock_flags) ; <---- is this 'irqsave' justified?
.
.
.
spin_unlock_irqrestore(&y_lock, y_lock_flags) ;
spin_unlock_irqrestore(x_lock, x_lock_flags) ;
OR
spin_lock_irqsave(&x_lock, x_lock_flags) ;
.
spin_lock(&y_lock) ;
.
.
.
spin_unlock(&y_lock) ;
spin_unlock_irqrestore(x_lock, x_lock_flags) ;
Which one is more correct or there are some other implications?
Devesh.
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to eca...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ
>
> spin_lock_irqsave(&x_lock, x_lock_flags) ;
> .
> spin_lock_irqsave(&y_lock, y_lock_flags) ; <---- is this 'irqsave' justified?
It is redundant. The code is correct but it will make no difference if
you use spin_lock() instead of spin_lock_irqsave() for y_lock.
>
> Which one is more correct or there are some other implications?
>
The second one is preferable as it will save you a few instructions.
Thanks,
Rajat