linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* Does shmem_getpage==>shmem_alloc_page==>alloc_page_vma hold mmap_sem?
@ 2005-11-06  5:21 Paul Jackson
  2005-11-06  5:56 ` Hugh Dickins
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Jackson @ 2005-11-06  5:21 UTC (permalink / raw)
  To: Andi Kleen; +Cc: akpm, linux-mm, linux-kernel

Andi,

The comment in mm/mempolicy.c for alloc_page_vma() states:

  Should be called with the mm_sem of the vma hold.

However it seems that the call chain (#ifdef CONFIG_NUMA):

  shmem_getpage ==> shmem_alloc_page ==> alloc_page_vma

where shmem_getpage() is called from many of the mm/shmem.c file
operations, is called without holding mmap_sem.  There is no
mention of mmap_sem in the entire mm/shmem.c file.

This doesn't seem right.

-- 
                  I won't rest till it's the best ...
                  Programmer, Linux Scalability
                  Paul Jackson <pj@sgi.com> 1.925.600.0401

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: Does shmem_getpage==>shmem_alloc_page==>alloc_page_vma hold mmap_sem?
  2005-11-06  5:21 Does shmem_getpage==>shmem_alloc_page==>alloc_page_vma hold mmap_sem? Paul Jackson
@ 2005-11-06  5:56 ` Hugh Dickins
  2005-11-06  6:17   ` Paul Jackson
  0 siblings, 1 reply; 3+ messages in thread
From: Hugh Dickins @ 2005-11-06  5:56 UTC (permalink / raw)
  To: Paul Jackson; +Cc: Andi Kleen, akpm, linux-mm, linux-kernel

On Sat, 5 Nov 2005, Paul Jackson wrote:
> 
> The comment in mm/mempolicy.c for alloc_page_vma() states:
> 
>   Should be called with the mm_sem of the vma hold.
> 
> However it seems that the call chain (#ifdef CONFIG_NUMA):
> 
>   shmem_getpage ==> shmem_alloc_page ==> alloc_page_vma
> 
> where shmem_getpage() is called from many of the mm/shmem.c file
> operations, is called without holding mmap_sem.  There is no
> mention of mmap_sem in the entire mm/shmem.c file.

It's safe but horrid.  Look closer and you'll find there isn't even
an mm to hold the mmap_sem of.  The struct vm_area_struct is on the
stack of shmem_alloc_page, and exists solely to apply mempolicy to
a shmem file via an interface designed for mempolicy on vmas.

So far as I know, it works fine; but that interface really ought
to be redesigned some time - it looks like a quick hack that stuck.

Hugh

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: Does shmem_getpage==>shmem_alloc_page==>alloc_page_vma hold mmap_sem?
  2005-11-06  5:56 ` Hugh Dickins
@ 2005-11-06  6:17   ` Paul Jackson
  0 siblings, 0 replies; 3+ messages in thread
From: Paul Jackson @ 2005-11-06  6:17 UTC (permalink / raw)
  To: Hugh Dickins; +Cc: ak, akpm, linux-mm, linux-kernel

Hugh wrote:
> It's safe but horrid.

Ok - thanks for the explanation.

Now I don't feel so bad about some of my cpuset locking hacks.

(Yes, Andrew, I'm still looking at my latest hack, 
the down_write_trylock() call in cpuset.c refresh_mems.)

-- 
                  I won't rest till it's the best ...
                  Programmer, Linux Scalability
                  Paul Jackson <pj@sgi.com> 1.925.600.0401

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2005-11-06  6:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-06  5:21 Does shmem_getpage==>shmem_alloc_page==>alloc_page_vma hold mmap_sem? Paul Jackson
2005-11-06  5:56 ` Hugh Dickins
2005-11-06  6:17   ` Paul Jackson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox