On Thu, 2006-07-06 at 12:13 +0530, Rajat Jain wrote: > On 7/5/06, Arjan van de Ven <arjan@xxxxxxxxxxxxx> wrote: > > On Wed, 2006-07-05 at 19:38 +0530, Ranjan Sinha wrote: > > > Hi, > > > > > > A very newbie question on locking. > > > > > > LDD3 talks about spin_lock_irqsave and spin_unlock_restore and > > > mentions that the two _must_ be called from the same function or the > > > code might break on some architecture. I searched for this on google > > > and found that one of the platform on which it can break is sparc. > > > > this is no longer the case; it used to be like that in older kernels, > > but that got fixed for 2.6 kernels. > > > > So now the functions spin_lock_irqsave() and spin_unlock_restore() can > be called from different functions (rather being called pairwise in a > single function)? they can. HOWEVER, this is generally a really bad practice to do so, since it means you can then no longer see that your locking code is balanced. So unless you have a really really really good reason, keep the spin_lock and the spin_unlock in the same function. It helps prevent a lot of bugs, and makes code review 10x easier as well. Greetings, Arjan van de Ven -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/