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 <pet...@redhat.com>
> 
> Good cleanup! Thanks.
> Reviewed-by: Miaohe Lin <linmia...@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

Reply via email to