lkml.org 
[lkml]   [2015]   [Dec]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/2] mm: bring in additional flag for fixup_user_fault to signal unlock
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


\
 
 \ /
  Last update: 2015-12-04 23:01    [W:0.054 / U:0.160 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site