kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* why does the kernel use mutex to protect the address_space structure
@ 2011-10-31 19:57 Zheng Da
  2011-11-04  4:44 ` Jimmy Pan
  0 siblings, 1 reply; 3+ messages in thread
From: Zheng Da @ 2011-10-31 19:57 UTC (permalink / raw)
  To: kernelnewbies

Hello,

I try to understand why the kernel uses mutex to protect the
address_space structure. I checked the critical areas protected by
i_mmap_mutex, and didn't see these areas use IO. I don't see why we
can't use spin locks. Do I miss something? It seems most of critical
areas provided by i_mmap_mutex aren't very large.

Thanks,
Da

^ permalink raw reply	[flat|nested] 3+ messages in thread

* why does the kernel use mutex to protect the address_space structure
  2011-10-31 19:57 why does the kernel use mutex to protect the address_space structure Zheng Da
@ 2011-11-04  4:44 ` Jimmy Pan
  2011-11-13 20:08   ` Zheng Da
  0 siblings, 1 reply; 3+ messages in thread
From: Jimmy Pan @ 2011-11-04  4:44 UTC (permalink / raw)
  To: kernelnewbies

On Tue, Nov 1, 2011 at 3:57 AM, Zheng Da <zhengda1936@gmail.com> wrote:
> Hello,
>
> I try to understand why the kernel uses mutex to protect the
> address_space structure. I checked the critical areas protected by
> i_mmap_mutex, and didn't see these areas use IO. I don't see why we
> can't use spin locks. Do I miss something? It seems most of critical
> areas provided by i_mmap_mutex aren't very large.
>
> Thanks,
> Da
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>

In my knowledge, when you use mutex, you can go to sleep, if you use spin lock,
the thread has to busy wait, spin lock causes cpu waste, while mutex
cannot be used
under interrupt context.

Regards,
Jimmy

^ permalink raw reply	[flat|nested] 3+ messages in thread

* why does the kernel use mutex to protect the address_space structure
  2011-11-04  4:44 ` Jimmy Pan
@ 2011-11-13 20:08   ` Zheng Da
  0 siblings, 0 replies; 3+ messages in thread
From: Zheng Da @ 2011-11-13 20:08 UTC (permalink / raw)
  To: kernelnewbies

On Fri, Nov 4, 2011 at 12:44 AM, Jimmy Pan <dspjm1@gmail.com> wrote:
>> I try to understand why the kernel uses mutex to protect the
>> address_space structure. I checked the critical areas protected by
>> i_mmap_mutex, and didn't see these areas use IO. I don't see why we
>> can't use spin locks. Do I miss something? It seems most of critical
>> areas provided by i_mmap_mutex aren't very large.
>
> In my knowledge, when you use mutex, you can go to sleep, if you use spin lock,
> the thread has to busy wait, spin lock causes cpu waste, while mutex
> cannot be used
> under interrupt context.

Right. The problem is that the critical areas protected by the mutex
are pretty small. There is no reason to switch context, which just
causes more overhead, unless I miss something.

Thanks,
Da

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-11-13 20:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-31 19:57 why does the kernel use mutex to protect the address_space structure Zheng Da
2011-11-04  4:44 ` Jimmy Pan
2011-11-13 20:08   ` Zheng Da

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).