• KOSAKI Motohiro's avatar
    mm/mempolicy.c: refix mbind_range() vma issue · e26a5114
    KOSAKI Motohiro authored
    commit 8aacc9f5 ("mm/mempolicy.c: fix pgoff in mbind vma merge") is the
    slightly incorrect fix.
    
    Why? Think following case.
    
    1. map 4 pages of a file at offset 0
    
       [0123]
    
    2. map 2 pages just after the first mapping of the same file but with
       page offset 2
    
       [0123][23]
    
    3. mbind() 2 pages from the first mapping at offset 2.
       mbind_range() should treat new vma is,
    
       [0123][23]
         |23|
         mbind vma
    
       but it does
    
       [0123][23]
         |01|
         mbind vma
    
       Oops. then, it makes wrong vma merge and splitting ([01][0123] or similar).
    
    This patch fixes it.
    
    [testcase]
      test result - before the patch
    
    	case4: 126: test failed. expect '2,4', actual '2,2,2'
           	case5: passed
    	case6: passed
    	case7: passed
    	case8: passed
    	case_n: 246: test failed. expect '4,2', actual '1,4'
    
    	------------[ cut here ]------------
    	kernel BUG at mm/filemap.c:135!
    	invalid opcode: 0000 [#4] SMP DEBUG_PAGEALLOC
    
    	(snip long bug on messages)
    
      test result - after the pa...
    e26a5114
mempolicy.c 64.5 KB