Re: locking spinlocks during copy_to_user, copy_from_user

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 25 Jan 2013 09:58:42 -0300, Pablo Pessolani said:
> My question is: Is there any know consequence if I enable preemption before
> copy_to_user/copy_from user (keeping the spinlock locked) and then disable
> preemption again after the copy?????

Well, at that point, you potentially have "a spinlock locked during operations
that can be preempted", which you noted is "not recommended".

The generic problem is that while you're spinning, you can get hit with
a preempt, which ends up rescheduling or other fun stuff, and the preempting
thread ends up calling into the same code - at which point you'll possibly
deadlock because the second thread is now blocked on the spinlock that the
first thread holds...

You're much better off either restructuring your code so you don't do
anything that can preempt, or fix your locking in other ways so the
problem can't arise.

Attachment: pgpZ6gfkfpQNe.pgp
Description: PGP signature

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux