locking spinlocks during copy_to_user, copy_from_user
anish kumar
anish198519851985 at gmail.com
Fri Jan 25 11:18:25 EST 2013
On Fri, 2013-01-25 at 10:00 -0300, Pablo Pessolani wrote:
> Hi:
> It is well know that is not recomended to keep a spinlock locked
> during operations that can be preempted. Some of these operations are
> copy_to_user, copy_from_user.
> Below is the code of the write_lock() as a sample.
>
> 340 static inline void __write_lock(rwlock_t *lock)
> 341{
> 342 preempt_disable(); <<<<<< THE ISSUE IS HERE <<<<<<<<<<<<<<
> 343 rwlock_acquire(&lock->dep_map, 0, 0, _RET_IP_);
> 344 LOCK_CONTENDED(lock, _raw_write_trylock, _raw_write_lock);
> 345}
>
> On write_unlock() the preemtion is enable.
>
> My question is: Is there any know consequence if I enable preemption
> before copy_to_user/copy_from user (keeping the spinlock locked) and
why do you want to do this?
> then disable preemption again after the copy?????
> i.e.:
> write_lock(&lock);
> .......
> preempt_enable();
> copy_to_user(.......);
> preempt_disable();
> .......
> write_unlock(&lock);
>
> Thanks in advance.
> PAP
>
>
>
>
>
>
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
More information about the Kernelnewbies
mailing list