Re: Mutex and Spinlock locked together
Check this out: drivers/infiniband/core/cache.c function: ib_cache_gid_add Line: 338 mutex_lock(&table->lock); write_lock_irq(&table->rwlock); . . . . write_unlock_irq(&table->rwlock); mutex_unlock(&table->lock); On Thu, Feb 25, 2016 at 3:42 PM, priyaranjan wrote: > >On Thu, Feb 25, 2016 at 2:53 PM, Devesh Sharma > wrote: > >Hi > > >In running kernel there are many places you can look to get the usage. > But the bottom line is > > Can you tell me the specific use case? or give me the file name/driver > where this is used. > > >* You can take a spinlock under a mutex. e.g. > mutex_lock--->spinlock-critical section-spinunlock--->mutex_unlock. > > >* You can not take a mutex under a spinlock. e.g. spinlock--->mutex_lock > -critical section mutex_unlock>spinunlock is not allowed. > > > On Thu, Feb 25, 2016 at 11:37 AM, priyaranjan > wrote: > Hello All, > > Do you have any idea of a situation where we would need mutex and spinlock > to be locked together? I think there is an example for this in Linux > kernel. Can anyone help me? > > Regards, > Priyaranjan > > ___ > Kernelnewbies mailing list > Kernelnewbies@kernelnewbies.org > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies > > > > -- Please don't print this E- mail unless you really need to - this will preserve trees on planet earth. ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Mutex and Spinlock locked together
>On Thu, Feb 25, 2016 at 2:53 PM, Devesh Sharma wrote: >Hi >In running kernel there are many places you can look to get the usage. But the bottom line is Can you tell me the specific use case? or give me the file name/driver where this is used. >* You can take a spinlock under a mutex. e.g. mutex_lock--->spinlock-critical section-spinunlock--->mutex_unlock. >* You can not take a mutex under a spinlock. e.g. spinlock--->mutex_lock -critical section mutex_unlock>spinunlock is not allowed. On Thu, Feb 25, 2016 at 11:37 AM, priyaranjan wrote: Hello All, Do you have any idea of a situation where we would need mutex and spinlock to be locked together? I think there is an example for this in Linux kernel. Can anyone help me? Regards, Priyaranjan ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Mutex and Spinlock locked together
Hi In running kernel there are many places you can look to get the usage. But the bottom line is * You can take a spinlock under a mutex. e.g. mutex_lock--->spinlock-critical section-spinunlock--->mutex_unlock. * You can not take a mutex under a spinlock. e.g. spinlock--->mutex_lock -critical section mutex_unlock>spinunlock is not allowed. On Thu, Feb 25, 2016 at 11:37 AM, priyaranjan wrote: > Hello All, > > Do you have any idea of a situation where we would need mutex and spinlock > to be locked together? I think there is an example for this in Linux > kernel. Can anyone help me? > > Regards, > Priyaranjan > > ___ > Kernelnewbies mailing list > Kernelnewbies@kernelnewbies.org > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies > > -- Please don't print this E- mail unless you really need to - this will preserve trees on planet earth. ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies