From: Johannes Weiner <hannes@cmpxchg.org>
To: kosaki.motohiro@gmail.com
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
Minchan Kim <minchan.kim@gmail.com>,
Caspar Zhang <caspar@casparzhang.com>
Subject: Re: [PATCH] mempolicy: refix mbind_range() vma issue
Date: Mon, 12 Dec 2011 12:20:00 +0100 [thread overview]
Message-ID: <20111212112000.GB18789@cmpxchg.org> (raw)
In-Reply-To: <1323449709-25923-1-git-send-email-kosaki.motohiro@gmail.com>
On Fri, Dec 09, 2011 at 11:55:09AM -0500, kosaki.motohiro@gmail.com wrote:
> From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
>
> commit 8aacc9f550 (mm/mempolicy.c: fix pgoff in mbind vma merge) is
> slightly incorrect fix. It doesn't handle vma merge case 4 (see
> mmap.c#vma_merge() source comment).
>
> This patch fixes it.
>
> testcase: mbind_vma_test.c
> =====================================================
> #include <numaif.h>
> #include <numa.h>
> #include <sys/mman.h>
> #include <stdio.h>
> #include <unistd.h>
> #include <stdlib.h>
> #include <string.h>
>
> static unsigned long pagesize;
> void* mmap_addr;
> struct bitmask *nmask;
> char buf[1024];
> FILE *file;
> char retbuf[10240] = "";
>
> char *rubysrc = "ruby -e '\
> pid = %d; \
> vstart = 0x%llx; \
> vend = 0x%llx; \
> s = `pmap -q #{pid}`; \
> rary = []; \
> s.each_line {|line|; \
> ary=line.split(\" \"); \
> addr = ary[0].to_i(16); \
> if(vstart <= addr && addr < vend) then \
> rary.push(ary[1].to_i()/4); \
> end; \
> }; \
> print rary.join(\",\"); \
> '";
;-)
But thanks for going through the test cases so meticulously!
That being said, would you mind including the output before and after
this patch in the changelog?
> Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
for the fix itself, but I think the changelog needs a bit more
information:
> @@ -636,6 +636,7 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
> struct vm_area_struct *prev;
> struct vm_area_struct *vma;
> int err = 0;
> + pgoff_t pgoff;
> unsigned long vmstart;
> unsigned long vmend;
>
> @@ -643,13 +644,17 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
> if (!vma || vma->vm_start > start)
> return -EFAULT;
>
> + if (start > vma->vm_start)
> + prev = vma;
> +
> for (; vma && vma->vm_start < end; prev = vma, vma = next) {
> next = vma->vm_next;
> vmstart = max(start, vma->vm_start);
> vmend = min(end, vma->vm_end);
>
> + pgoff = vma->vm_pgoff + ((vmstart - vma->vm_start) >> PAGE_SHIFT);
> prev = vma_merge(mm, prev, vmstart, vmend, vma->vm_flags,
> - vma->anon_vma, vma->vm_file, vma->vm_pgoff,
> + vma->anon_vma, vma->vm_file, pgoff,
> new_pol);
> if (prev) {
> vma = prev;
This is essentially a revert of the aforementioned commit.
What you added instead is the fixing of @prev: only when mbind is
vma-aligned can the new area be potentially merged into the preceding
one. Otherwise that original vma is the one we need to check for
compatibility with the mbind range and leave the original prev alone:
[prev ][vma ]
|start
[prev ][vma][mbind vma ]
This should NOT attempt to merge mbind vma with prev (and forget about
and leak vma, iirc), but check if vma and the mbind vma are compatible
or should be separate areas.
Could you please add something to that extent to the changelog?
--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2011-12-12 11:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-09 16:55 [PATCH] mempolicy: refix mbind_range() vma issue kosaki.motohiro
2011-12-12 11:20 ` Johannes Weiner [this message]
2011-12-20 18:17 ` [PATCH] [v2] " kosaki.motohiro
2011-12-20 19:28 ` Johannes Weiner
2011-12-20 23:37 ` Andrew Morton
2011-12-20 23:54 ` Johannes Weiner
2011-12-20 18:19 ` [PATCH] " KOSAKI Motohiro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20111212112000.GB18789@cmpxchg.org \
--to=hannes@cmpxchg.org \
--cc=caspar@casparzhang.com \
--cc=kosaki.motohiro@gmail.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=minchan.kim@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).