lkml.org 
[lkml]   [2022]   [Dec]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v2 05/10] mm/hugetlb: Make userfaultfd_huge_must_wait() safe to pmd unshare
From
On 12/7/22 15:44, Peter Xu wrote:
> The part that matters in the comment is "need to be before setting current
> state".
>
> blocking_state = userfaultfd_get_blocking_state(vmf->flags);
> if (is_vm_hugetlb_page(vma))
> hugetlb_vma_lock_read(vma);
> set_current_state(blocking_state);
>
> down_read() can sleep and also modify the task state, we cannot take the
> lock after that point because otherwise the task state will be messed up.
>

OK, how about:

/*
* Take the vma lock now, in order to safely call
* userfaultfd_huge_must_wait() a little bit later. Because acquiring
* the (sleepable) vma lock potentially modifies the current task state,
* that must be before explicitly calling set_current_state().
*/

Other than that, the patch looks good, so:

Reviewed-by: John Hubbard <jhubbard@nvidia.com>

thanks,
--
John Hubbard
NVIDIA

\
 
 \ /
  Last update: 2022-12-08 00:55    [W:0.059 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site