lkml.org 
[lkml]   [2021]   [Mar]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 02/23] mm: Clear vmf->pte after pte_unmap_same() returns
On Tue, Mar 23, 2021 at 10:34:45AM +0800, Miaohe Lin wrote:
> Hi:
> On 2021/3/23 8:48, Peter Xu wrote:
> > pte_unmap_same() will always unmap the pte pointer. After the unmap, vmf->pte
> > will not be valid any more. We should clear it.
> >
> > It was safe only because no one is accessing vmf->pte after pte_unmap_same()
> > returns, since the only caller of pte_unmap_same() (so far) is do_swap_page(),
> > where vmf->pte will in most cases be overwritten very soon.
> >
> > pte_unmap_same() will be used in other places in follow up patches, so that
> > vmf->pte will not always be re-written. This patch enables us to call
> > functions like finish_fault() because that'll conditionally unmap the pte by
> > checking vmf->pte first. Or, alloc_set_pte() will make sure to allocate a new
> > pte even after calling pte_unmap_same().
> >
> > Since we'll need to modify vmf->pte, directly pass in vmf into pte_unmap_same()
> > and then we can also avoid the long parameter list.
> >
> > Signed-off-by: Peter Xu <peterx@redhat.com>
>
> Good cleanup! Thanks.
> Reviewed-by: Miaohe Lin <linmiaohe@huawei.com>

Just a note that this is not a pure cleanup - the latter patches may start to
depend on the clearing of vmf->pte in their logic.

Thanks for the quick review!

--
Peter Xu

\
 
 \ /
  Last update: 2021-03-23 16:50    [W:0.134 / U:0.476 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site