From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756739AbbLDVvG (ORCPT ); Fri, 4 Dec 2015 16:51:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43585 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756603AbbLDVtf (ORCPT ); Fri, 4 Dec 2015 16:49:35 -0500 Date: Fri, 4 Dec 2015 22:49:33 +0100 From: Andrea Arcangeli To: Dominik Dingel Cc: "Kirill A. Shutemov" , Martin Schwidefsky , Christian Borntraeger , "Jason J. Herne" , linux-s390@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , David Rientjes , Eric B Munson , Naoya Horiguchi , Mel Gorman , Heiko Carstens , Paolo Bonzini , linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] mm: bring in additional flag for fixup_user_fault to signal unlock Message-ID: <20151204214933.GE29105@redhat.com> References: <1448558822-41358-1-git-send-email-dingel@linux.vnet.ibm.com> <1448558822-41358-2-git-send-email-dingel@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1448558822-41358-2-git-send-email-dingel@linux.vnet.ibm.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 26, 2015 at 06:27:01PM +0100, Dominik Dingel wrote: > @@ -599,6 +603,10 @@ int fixup_user_fault(struct task_struct *tsk, struct mm_struct *mm, > if (!(vm_flags & vma->vm_flags)) > return -EFAULT; > > + if (unlocked) > + fault_flags |= FAULT_FLAG_ALLOW_RETRY; > + > +retry: This should move up before find_extend_vma, otherwise the vma used below could be a dangling pointer after the "goto retry". > ret = handle_mm_fault(mm, vma, address, fault_flags); > if (ret & VM_FAULT_ERROR) { > if (ret & VM_FAULT_OOM) > @@ -609,12 +617,21 @@ int fixup_user_fault(struct task_struct *tsk, struct mm_struct *mm, > return -EFAULT; > BUG(); > } > - if (tsk) { > + if (tsk && !(fault_flags & FAULT_FLAG_TRIED)) { > if (ret & VM_FAULT_MAJOR) > tsk->maj_flt++; > else > tsk->min_flt++; > } It'd look cleaner if we'd move the tsk update after the retry check in case the FAULT_FLAG_TRIED second attempt actually fails, to avoid recording a fault for a non-really-faulting VM_FAULT_RETRY attempt. This is what the real page fault does at least so it sounds cleaner do the same here, but then in practice it makes very little difference. > + if (ret & VM_FAULT_RETRY) { > + down_read(&mm->mmap_sem); > + if (!(fault_flags & FAULT_FLAG_TRIED)) { > + *unlocked = true; > + fault_flags &= ~FAULT_FLAG_ALLOW_RETRY; > + fault_flags |= FAULT_FLAG_TRIED; > + goto retry; > + } > + } > return 0; > } Rest looks great. The futex.c should be patched to pass the unlocked pointer in a later patch but we can also postpone it to a different patchset. Thanks, Andrea