Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754313AbaGOVHW (ORCPT ); Tue, 15 Jul 2014 17:07:22 -0400 Received: from mail-ig0-f171.google.com ([209.85.213.171]:39946 "EHLO mail-ig0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751411AbaGOVHS (ORCPT ); Tue, 15 Jul 2014 17:07:18 -0400 MIME-Version: 1.0 In-Reply-To: <20140715134206.5d4964569fe0c64e39873416@linux-foundation.org> References: <20140715115832.18997.90349.stgit@buzz> <20140715134206.5d4964569fe0c64e39873416@linux-foundation.org> Date: Wed, 16 Jul 2014 01:07:18 +0400 Message-ID: Subject: Re: [PATCH] mm: do not call do_fault_around for non-linear fault From: Konstantin Khlebnikov To: Andrew Morton Cc: Konstantin Khlebnikov , "linux-mm@kvack.org" , Hugh Dickins , Linux Kernel Mailing List , Sasha Levin , Ingo Korb , "Kirill A. Shutemov" , Dave Jones , Ning Qu Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 16, 2014 at 12:42 AM, Andrew Morton wrote: > On Tue, 15 Jul 2014 15:58:32 +0400 Konstantin Khlebnikov wrote: > >> From: Konstantin Khlebnikov >> >> Faulting around non-linear page-fault has no sense and >> breaks logic in do_fault_around because pgoff is shifted. >> > > Please be a lot more careful with the changelogs? This one failed to > describe the effects of the bug, failed to adequately describe the bug > itself, failed to describe the offending commits and failed to identify > which kernel versions need the patch. Sorry for that. I thought I had already lost that bug-fixing race. > > Sigh. I went back and assembled the necessary information, below. > Please check it. > > > > From: Konstantin Khlebnikov > Subject: mm: do not call do_fault_around for non-linear fault > > Ingo Korb reported that "repeated mapping of the same file on tmpfs using > remap_file_pages sometimes triggers a BUG at mm/filemap.c:202 when the > process exits". He bisected the bug to d7c1755179b82d ("mm: implement > ->map_pages for shmem/tmpfs"), although the bug was actually added by > 8c6e50b0290c4 ("mm: introduce vm_ops->map_pages()"). > > Problem is caused by calling do_fault_around for _non-linear_ faiult. In > this case pgoff is shifted and might become negative during calculation. > > Faulting around non-linear page-fault has no sense and breaks logic in > do_fault_around because pgoff is shifted. > > Signed-off-by: Konstantin Khlebnikov > Reported-by: "Ingo Korb" > Tested-by: "Ingo Korb" > Cc: Hugh Dickins > Cc: Sasha Levin > Cc: Dave Jones > Cc: Ning Qu > Cc: "Kirill A. Shutemov" > Cc: [3.15.x] > Signed-off-by: Andrew Morton > --- > > mm/memory.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff -puN mm/memory.c~mm-do-not-call-do_fault_around-for-non-linear-fault mm/memory.c > --- a/mm/memory.c~mm-do-not-call-do_fault_around-for-non-linear-fault > +++ a/mm/memory.c > @@ -2882,7 +2882,8 @@ static int do_read_fault(struct mm_struc > * if page by the offset is not ready to be mapped (cold cache or > * something). > */ > - if (vma->vm_ops->map_pages && fault_around_pages() > 1) { > + if (vma->vm_ops->map_pages && !(flags & FAULT_FLAG_NONLINEAR) && > + fault_around_pages() > 1) { > pte = pte_offset_map_lock(mm, pmd, address, &ptl); > do_fault_around(vma, address, pte, pgoff, flags); > if (!pte_same(*pte, orig_pte)) > _ > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/