* [PATCH} mm: Merging memory blocks resets mempolicy
@ 2013-03-18 6:13 Hampson, Steven T
2013-03-20 22:02 ` Andrew Morton
0 siblings, 1 reply; 2+ messages in thread
From: Hampson, Steven T @ 2013-03-18 6:13 UTC (permalink / raw)
To: linux-kernel@vger.kernel.org; +Cc: linux-mm@kvack.org
Using mbind to change the mempolicy to MPOL_BIND on several adjacent
mmapped blocks
may result in a reset of the mempolicy to MPOL_DEFAULT in vma_adjust.
Test code. Correct result is three lines containing "OK".
#include <stdio.h>
#include <unistd.h>
#include <sys/mman.h>
#include <numaif.h>
#include <errno.h>
/* gcc mbind_test.c -lnuma -o mbind_test -Wall */
#define MAXNODE 4096
void allocate()
{
int ret;
int len;
int policy = -1;
unsigned char *p;
unsigned long mask[MAXNODE] = { 0 };
unsigned long retmask[MAXNODE] = { 0 };
len = getpagesize() * 0x2fc00;
p = mmap(NULL, len, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
-1, 0);
if (p == MAP_FAILED)
printf("mbind err: %d\n", errno);
mask[0] = 1;
ret = mbind(p, len, MPOL_BIND, mask, MAXNODE, 0);
if (ret < 0)
printf("mbind err: %d %d\n", ret, errno);
ret = get_mempolicy(&policy, retmask, MAXNODE, p, MPOL_F_ADDR);
if (ret < 0)
printf("get_mempolicy err: %d %d\n", ret, errno);
if (policy == MPOL_BIND)
printf("OK\n");
else
printf("ERROR: policy is %d\n", policy);
}
int main()
{
allocate();
allocate();
allocate();
return 0;
}
Signed-off-by: Steven T Hampson <steven.t.hampson@intel.com>
---
diff --git a/mm/mmap.c b/mm/mmap.c
index 8832b87..5ba8b92 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -820,7 +820,7 @@ again: remove_next = 1 + (end > next->vm_end);
if (next->anon_vma)
anon_vma_merge(vma, next);
mm->map_count--;
- mpol_put(vma_policy(next));
+ vma_set_policy(vma, vma_policy(next));
kmem_cache_free(vm_area_cachep, next);
/*
* In mprotect's case 6 (see comments on vma_merge),
--
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 related [flat|nested] 2+ messages in thread
* Re: [PATCH} mm: Merging memory blocks resets mempolicy
2013-03-18 6:13 [PATCH} mm: Merging memory blocks resets mempolicy Hampson, Steven T
@ 2013-03-20 22:02 ` Andrew Morton
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2013-03-20 22:02 UTC (permalink / raw)
To: Hampson, Steven T; +Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org
On Mon, 18 Mar 2013 06:13:42 +0000 "Hampson, Steven T" <steven.t.hampson@intel.com> wrote:
> Using mbind to change the mempolicy to MPOL_BIND on several adjacent
> mmapped blocks
> may result in a reset of the mempolicy to MPOL_DEFAULT in vma_adjust.
>
> ...
>
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -820,7 +820,7 @@ again: remove_next = 1 + (end > next->vm_end);
> if (next->anon_vma)
> anon_vma_merge(vma, next);
> mm->map_count--;
> - mpol_put(vma_policy(next));
> + vma_set_policy(vma, vma_policy(next));
> kmem_cache_free(vm_area_cachep, next);
> /*
> * In mprotect's case 6 (see comments on vma_merge),
Is this missing an mpol_put(vma_policy(vma))?
--
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] 2+ messages in thread
end of thread, other threads:[~2013-03-20 22:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-18 6:13 [PATCH} mm: Merging memory blocks resets mempolicy Hampson, Steven T
2013-03-20 22:02 ` Andrew Morton
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).