From: Andi Kleen > Andi, how come policy_vma() calls ->set_policy under i_shared_sem? I think this can be actually dropped now. In an earlier version I did walk the vma shared list to change the policies of other mappings to the same shared memory region. This turned out too complicated with all the corner cases, so I eventually gave in and added ->get_policy to the fast path. Also there is still the mmap_sem which prevents races in the same MM. Patch to remove it attached. Also adds documentation and removes the bogus __alloc_page_vma() prototype noticed by hch. --- 25-akpm/Documentation/numastat.txt | 22 ++++++++++++++++++++++ 25-akpm/include/linux/gfp.h | 3 --- 25-akpm/mm/mempolicy.c | 4 ---- 3 files changed, 22 insertions(+), 7 deletions(-) diff -puN Documentation/numastat.txt~numa-api-docs-policy_vma-fix Documentation/numastat.txt --- 25/Documentation/numastat.txt~numa-api-docs-policy_vma-fix Wed Apr 21 14:10:22 2004 +++ 25-akpm/Documentation/numastat.txt Wed Apr 21 14:10:22 2004 @@ -0,0 +1,22 @@ + +Numa policy hit/miss statistics + +/sys/devices/system/node/node*/numastat + +All units are pages. Hugepages have separate counters. + +numa_hit A process wanted to allocate memory from this node, + and succeeded. +numa_miss A process wanted to allocate memory from this node, + but ended up with memory from another. +numa_foreign A process wanted to allocate on another node, + but ended up with memory from this one. +local_node A process ran on this node and got memory from it. +other_node A process ran on this node and got memory from another node. +interleave_hit Interleaving wanted to allocate from this node + and succeeded. + +For easier reading you can use the numastat utility from the numactl package +(ftp://ftp.suse.com/pub/people/ak/numa/numactl*). Note that it only works +well right now on machines with a small number of CPUs. + diff -puN include/linux/gfp.h~numa-api-docs-policy_vma-fix include/linux/gfp.h --- 25/include/linux/gfp.h~numa-api-docs-policy_vma-fix Wed Apr 21 14:10:22 2004 +++ 25-akpm/include/linux/gfp.h Wed Apr 21 14:10:22 2004 @@ -96,9 +96,6 @@ alloc_pages(unsigned int gfp_mask, unsig return alloc_pages_current(gfp_mask, order); } -extern struct page *__alloc_page_vma(unsigned gfp_mask, - struct vm_area_struct *vma, unsigned long off); - extern struct page *alloc_page_vma(unsigned gfp_mask, struct vm_area_struct *vma, unsigned long addr); #else diff -puN mm/mempolicy.c~numa-api-docs-policy_vma-fix mm/mempolicy.c --- 25/mm/mempolicy.c~numa-api-docs-policy_vma-fix Wed Apr 21 14:10:22 2004 +++ 25-akpm/mm/mempolicy.c Wed Apr 21 14:10:22 2004 @@ -295,8 +295,6 @@ static int policy_vma(struct vm_area_str vma->vm_ops, vma->vm_file, vma->vm_ops ? vma->vm_ops->set_policy : NULL); - if (vma->vm_file) - down(&vma->vm_file->f_mapping->i_shared_sem); if (vma->vm_ops && vma->vm_ops->set_policy) err = vma->vm_ops->set_policy(vma, new); if (!err) { @@ -304,8 +302,6 @@ static int policy_vma(struct vm_area_str vma->vm_policy = new; mpol_free(old); } - if (vma->vm_file) - up(&vma->vm_file->f_mapping->i_shared_sem); return err; } _