Does shmem_getpage==>shmem_alloc_page==>alloc_page_vma hold mmap_sem?
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.
Signature · 9 lines
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <[email protected]> 1.925.600.0401
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>Quoted 5 lines · Paul Jackson
The comment in
mm/mempolicy.cforalloc_page_vma()states:Should be called with the
mm_semof the vma hold.
Quoted 7 lines
However it seems that the call chain (#ifdef
CONFIG_NUMA):
shmem_getpage==>shmem_alloc_page==>alloc_page_vmawhere
shmem_getpage()is called from many of themm/shmem.cfile operations, is called without holdingmmap_sem. There is no mention ofmmap_semin the entiremm/shmem.cfile.
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 [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 1 line · Hugh
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.)
Signature · 9 lines
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <[email protected]> 1.925.600.0401
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>