From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DED0BC433DB for ; Tue, 23 Mar 2021 15:41:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6907F619B2 for ; Tue, 23 Mar 2021 15:41:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6907F619B2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E89CB6B0209; Tue, 23 Mar 2021 11:41:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E39856B020B; Tue, 23 Mar 2021 11:41:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CB3AC6B020D; Tue, 23 Mar 2021 11:41:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0228.hostedemail.com [216.40.44.228]) by kanga.kvack.org (Postfix) with ESMTP id B165C6B0209 for ; Tue, 23 Mar 2021 11:41:00 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 756658249980 for ; Tue, 23 Mar 2021 15:41:00 +0000 (UTC) X-FDA: 77951552280.05.2A9C785 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf12.hostedemail.com (Postfix) with ESMTP id 6799AF0 for ; Tue, 23 Mar 2021 15:40:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616514059; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0ffzPyphtdhkRIijwb41EPoN1LYXu9B8LbqgVvLt0lI=; b=YAgUTi0lL90DBvWA+8imFUHBBnZpqIw3/iRoO3k8JnZrDI758nlwNKTqyf5BMIdHDsfIch +0hVFF89bxftfoBqn55ngfGPHStQADbeYHz+j6SeU/m9T612UVK/jDY8OwrmZhFnxBCjc9 gaihw/z8llhN9GZW4OqBPsqRxYNw1Co= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-538-WXHbRYAvML6TPgtVJFgDww-1; Tue, 23 Mar 2021 11:40:56 -0400 X-MC-Unique: WXHbRYAvML6TPgtVJFgDww-1 Received: by mail-qk1-f198.google.com with SMTP id u5so2239995qkj.10 for ; Tue, 23 Mar 2021 08:40:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=0ffzPyphtdhkRIijwb41EPoN1LYXu9B8LbqgVvLt0lI=; b=Dt9pBaxm54SjLv6Z8i7Q5fKNjTZ9DsyteYBnMOVe2u1wf9s2o4boHYKY2cIwyCtrkb nEJJl3jMnEq0WiE4mYSiRy9328NZyUvJuds3u+svYOzL+ixpW4kayoafjYi7GJsb18qJ bO+KAMGBT696UoJWHvbS1RJOrHdryUkGGbrKMdGkFP2HOXPneZLlSKcOpiTLCnXIAAQ+ 0Z3xfGN0Rd2MUk75a5g7i52nNhmjbOhBxxszgL3FfKqjI/KsVGmeg6nUGqhrdgw1rSLc YIuThPx9Rs4xyKbArKOrs6M+s/IeO/OXGhjsRpJFU0gyhmQlLEhnNktuplDQJMfSv748 wpwA== X-Gm-Message-State: AOAM532BKYko83+8auUsGsrqXh52KKlTK6jwn/v77kfRuUBgC40oq5px EzmE307LKNVpNxutFrxdtIfsMA8EKNvhMmj9PvwaAFfIQBA8GLjFCrXF0qPIW7B439hwugSanfo aKMEcfPHhc9E= X-Received: by 2002:ac8:6606:: with SMTP id c6mr5092326qtp.76.1616514055654; Tue, 23 Mar 2021 08:40:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjndLoaGi+llXMkxdyWCe50dXelUQ5vwDuDl2tdSDWegEQ0bnTd2W+fvQiGSlv81JRBlACkQ== X-Received: by 2002:ac8:6606:: with SMTP id c6mr5092296qtp.76.1616514055380; Tue, 23 Mar 2021 08:40:55 -0700 (PDT) Received: from xz-x1 (bras-base-toroon474qw-grc-82-174-91-135-175.dsl.bell.ca. [174.91.135.175]) by smtp.gmail.com with ESMTPSA id b17sm11042850qtp.73.2021.03.23.08.40.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 08:40:54 -0700 (PDT) Date: Tue, 23 Mar 2021 11:40:53 -0400 From: Peter Xu To: Miaohe Lin Cc: "Kirill A . Shutemov" , Jerome Glisse , Mike Kravetz , Matthew Wilcox , Andrew Morton , Axel Rasmussen , Hugh Dickins , Nadav Amit , Andrea Arcangeli , Mike Rapoport , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 02/23] mm: Clear vmf->pte after pte_unmap_same() returns Message-ID: <20210323154053.GF6486@xz-x1> References: <20210323004912.35132-1-peterx@redhat.com> <20210323004912.35132-3-peterx@redhat.com> <28c1dfdc-b72b-88a7-411c-effc078f774a@huawei.com> MIME-Version: 1.0 In-Reply-To: <28c1dfdc-b72b-88a7-411c-effc078f774a@huawei.com> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Stat-Signature: f46zccmakt6uckt18fu9rcq8n68ach8i X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 6799AF0 Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf12; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=63.128.21.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1616514059-192388 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 > > Good cleanup! Thanks. > Reviewed-by: Miaohe Lin 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