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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7658EC7EE24 for ; Tue, 6 Jun 2023 06:29:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:Message-ID:In-Reply-To:Subject:cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=vHUg369s+6OSllep/FMrCevRrBsmpoXXkjhmU+IyDEw=; b=Z9lRKrErVegen0lWnQ7ZWm5PD+ wWwk0D5RKa4HLE8n8gPjcLaxVaEIsTxVkqgvuBg4lYCEL4SlH6UJQg/EzGCSDe9r2VzM7LjJWUoCq Fn3Ce92v64a9+vnFxLnQ8/Rtb/RLS64vd1N4u+PosVpWPpIIb1UVfZXH1IPkGYLh6G8QPwPuBsZCP +33qn6OtkbNNpk4vGm1Vy468Uiw4p1YO68hdPcdnKP2NtZ6ecoJXhAD4jc3k0+YF5grLqkJZx3Dnn tkCBlZkwxT/a7hHeBFsj1rIz8xUhzkjtd34RlQY72KHat3KsxDCucriFoVrG9fVyHVZXqoqjjUrO2 RZNcRRaA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q6QBM-000N6c-0A; Tue, 06 Jun 2023 06:28:40 +0000 Received: from mail-yw1-x112a.google.com ([2607:f8b0:4864:20::112a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q6QBI-000N4X-28 for linux-arm-kernel@lists.infradead.org; Tue, 06 Jun 2023 06:28:38 +0000 Received: by mail-yw1-x112a.google.com with SMTP id 00721157ae682-568ba7abc11so72124687b3.3 for ; Mon, 05 Jun 2023 23:28:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686032913; x=1688624913; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=lh4nTYVvP2xhbTqzCFThdJwLmWrtDo6cCYu0K1MEaUc=; b=ULW8wPRikckM9LELAx9UpWle2Lb4WwZxPIXEDt1lR9wQIO5cxXakH/8jTLMBuZw8wx Uh47SeunW4Tp+pyb/wTLCC6nZMEC4nTofGf4XUgb3BlgvfEFnDLECsk+JtbDPIEYi26x 9vZZ874SZy4X8WigJ/C8mjXXdDbReJrV0R4WIGr0mh0A5ZnrYuJU6h/Cw9u/zsQYaDk7 mLxWS2XDJjEOTgncPyb98NRz5neLtObTpcxFngkG2w0fp+AzoZOrYLnFHTWNsS7we8ze 5+dQOLu1Iwg73UmL89hyYzq5nExeBAcTkTsnwBDNieMk9P3B3h923KXyo65p9UTdz89t Xo3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686032913; x=1688624913; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lh4nTYVvP2xhbTqzCFThdJwLmWrtDo6cCYu0K1MEaUc=; b=HJQBKQt27IaboQJcH0WU3QHd4YnqU+7G8v5Mic5Nu1y5JIMnd0X92hjc8c/BFokUne 6cfiSdrrr+9o4HSOmMYGusd4FpSxCvnLA6jmOeWt2hOpt4HA3iLDBuytbC5AAgaEC1qA 4oIPbDejsnw2rqzmRwcn6JLCIPP28XiBQIYK4Fk7CwAhLnPTjj4e0/6pKZW584ZGoAeu 7GxwuiIL9BicqGqgYF8XUnLN383Q4pCOisAXHMjH4Uor9lHOO1WZ8mXZBX7H6v2Z6+lt pewxng2dvhYKk4Sm5hT78eXLg4yNOEjlyUB82HwPCG4y6ZnG8iY4oCI20kg7LyA0HTZa 8TNQ== X-Gm-Message-State: AC+VfDzBc64tJsu19XlKS2/yzYxx+tVciBTYbJBxvJ6cmraOtGT2b5lS WfaBzKZF6hEY9RWvi0QZt7LB2w== X-Google-Smtp-Source: ACHHUZ7idIXR3XCuKUN9DZBZ124U2LyUkc47jWZoQiMKnSHKdPcQWeTsiAJumin9N7U+fFXlqtOy5g== X-Received: by 2002:a0d:dd0f:0:b0:565:a3e6:1b7b with SMTP id g15-20020a0ddd0f000000b00565a3e61b7bmr1184720ywe.18.1686032912712; Mon, 05 Jun 2023 23:28:32 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id u127-20020a818485000000b00569e0490babsm626769ywf.16.2023.06.05.23.28.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jun 2023 23:28:32 -0700 (PDT) Date: Mon, 5 Jun 2023 23:28:27 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Jann Horn cc: Hugh Dickins , Andrew Morton , Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Yang Shi , Mel Gorman , Peter Xu , Peter Zijlstra , Will Deacon , Yu Zhao , Alistair Popple , Ralph Campbell , Ira Weiny , Steven Price , SeongJae Park , Naoya Horiguchi , Christophe Leroy , Zack Rusin , Jason Gunthorpe , Axel Rasmussen , Anshuman Khandual , Pasha Tatashin , Miaohe Lin , Minchan Kim , Christoph Hellwig , Song Liu , Thomas Hellstrom , Russell King , "David S. Miller" , Michael Ellerman , "Aneesh Kumar K.V" , Heiko Carstens , Christian Borntraeger , Claudio Imbrenda , Alexander Gordeev , linux-arm-kernel@lists.infradead.org, sparclinux@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 00/12] mm: free retracted page table by RCU In-Reply-To: Message-ID: <99fadcf-3979-a493-2664-291c5fbce19e@google.com> References: <35e983f5-7ed3-b310-d949-9ae8b130cdab@google.com> <3a33b59f-47c1-9dea-209a-9f77eec3cb1@google.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="-1463760895-360064877-1686032912=:3708" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230605_232836_700311_D1A4FEC6 X-CRM114-Status: GOOD ( 30.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. ---1463760895-360064877-1686032912=:3708 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE On Fri, 2 Jun 2023, Jann Horn wrote: > On Fri, Jun 2, 2023 at 6:37=E2=80=AFAM Hugh Dickins wr= ote: >=20 > > The most obvious vital thing (in the split ptlock case) is that it > > remains a struct page with a usable ptl spinlock embedded in it. > > > > The question becomes more urgent when/if extending to replacing the > > pagetable pmd by huge pmd in one go, without any mmap_lock: powerpc > > wants to deposit the page table for later use even in the shmem/file > > case (and all arches in the anon case): I did work out the details once > > before, but I'm not sure whether I would still agree with myself; and w= as > > glad to leave replacement out of this series, to revisit some time late= r. > > > > > > > > So in particular, in handle_pte_fault() we can reach the "if > > > (unlikely(!pte_same(*vmf->pte, entry)))" with vmf->pte pointing to a > > > detached zeroed page table, but we're okay with that because in that > > > case we know that !pte_none(vmf->orig_pte)&&pte_none(*vmf->pte) , > > > which implies !pte_same(*vmf->pte, entry) , which means we'll bail > > > out? > > > > There is no current (even at end of series) circumstance in which we > > could be pointing to a detached page table there; but yes, I want to > > allow for that, and yes I agree with your analysis. >=20 > Hmm, what am I missing here? I spent quite a while trying to reconstruct what I had been thinking, what meaning of "detached" or "there" I had in mind when I asserted so confidently "There is no current (even at end of series) circumstance in which we could be pointing to a detached page table there". But had to give up and get on with more useful work. Of course you are right, and that is what this series is about. Hugh >=20 > static vm_fault_t handle_pte_fault(struct vm_fault *vmf) > { > pte_t entry; >=20 > if (unlikely(pmd_none(*vmf->pmd))) { > [not executed] > } else { > /* > * A regular pmd is established and it can't morph into a huge > * pmd by anon khugepaged, since that takes mmap_lock in write > * mode; but shmem or file collapse to THP could still morph > * it into a huge pmd: just retry later if so. > */ > vmf->pte =3D pte_offset_map_nolock(vmf->vma->vm_mm, vmf->pmd, > vmf->address, &vmf->ptl); > if (unlikely(!vmf->pte)) > [not executed] > // this reads a present readonly PTE > vmf->orig_pte =3D ptep_get_lockless(vmf->pte); > vmf->flags |=3D FAULT_FLAG_ORIG_PTE_VALID; >=20 > if (pte_none(vmf->orig_pte)) { > [not executed] > } > } >=20 > [at this point, a concurrent THP collapse operation detaches the page t= able] > // vmf->pte now points into a detached page table >=20 > if (!vmf->pte) > [not executed] >=20 > if (!pte_present(vmf->orig_pte)) > [not executed] >=20 > if (pte_protnone(vmf->orig_pte) && vma_is_accessible(vmf->vma)) > [not executed] >=20 > spin_lock(vmf->ptl); > entry =3D vmf->orig_pte; > // vmf->pte still points into a detached page table > if (unlikely(!pte_same(*vmf->pte, entry))) { > update_mmu_tlb(vmf->vma, vmf->address, vmf->pte); > goto unlock; > } > [...] > } ---1463760895-360064877-1686032912=:3708 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ---1463760895-360064877-1686032912=:3708--