Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6680787rwd; Mon, 5 Jun 2023 23:52:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5v1v/h3rSAKjn7zqK2d8drgQkIwas/+iOj0Aa8JG76Gt91Vquuq4AT9ADepELtTX0EoSs9 X-Received: by 2002:a05:6808:3c4:b0:398:4217:e8a4 with SMTP id o4-20020a05680803c400b003984217e8a4mr728052oie.9.1686034349189; Mon, 05 Jun 2023 23:52:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686034349; cv=none; d=google.com; s=arc-20160816; b=SJgG/kHPWf5iEJlFNpvkwxVH5F1xKRm8c2YIGptSAN0ceJ27CdTqmGysSZ9LMIzCWk YxVMNf7hXb5fVu7egOd36m4efP77GsQnnt6Wnw2wOOOOmY4tV1uJGL82bt0oHARNktFI Sr4M9ER95KIfGdELFIC7VRRs5Glbg2A9x2Z8vmbMtT+iJbrZPuskW9vDTsfbrQeAERUn mEsdYVj4/9QO6G4Au183T3J12A7PJN9UXavNbhBT1E2pwDXS9erDxWNpv9MueiecLZA3 2JTDLHLMP7jCtRc+A3KntN7Jz+KSBhflJwaMW/kO8vZGkrK9LD0Dj4dTF6OQv68nM/aB jkeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=lh4nTYVvP2xhbTqzCFThdJwLmWrtDo6cCYu0K1MEaUc=; b=orooVMFehz92ZOjj+mg1R4CDXhOSLXR+/jNfIz4kRaJ5iO2gbrfHezILHThIrGDgZp UtOiCz3FeJ2WyOlo2AOXJlHEgAj0pCQY9Aixjpkz7DpQcpE1bhdzGiwmAgvV0OQfRcVS /iy08EC4pZbY/HAo3be5O7sJpunuFf5Anz9AyWz2ag/HublTN+XYZI2USGpr9vRDyr/U S5iYYPP6ZbOBAAg/+o+QuuR/Zwk/YviET8dKjCsO/n7DQPOt3fFgwmCvUz2DVvXnU33S ohbgrjwHbmg5bgT1YcwwxnXcaRwTuRKxUmNvVvS59JMpDU2JlGQ6Lo0s/Ne0S/RnP7yq NOcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=ULW8wPRi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e69-20020a636948000000b0053fb32e621bsi6724766pgc.896.2023.06.05.23.52.16; Mon, 05 Jun 2023 23:52:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=ULW8wPRi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234679AbjFFG3Q (ORCPT + 99 others); Tue, 6 Jun 2023 02:29:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235090AbjFFG2l (ORCPT ); Tue, 6 Jun 2023 02:28:41 -0400 Received: from mail-yw1-x112a.google.com (mail-yw1-x112a.google.com [IPv6:2607:f8b0:4864:20::112a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED101E76 for ; Mon, 5 Jun 2023 23:28:33 -0700 (PDT) Received: by mail-yw1-x112a.google.com with SMTP id 00721157ae682-565e6beb7aaso72071917b3.2 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=Ef2VxiW53zpZHR01cVvLfJ2zOGQaWHRY+obYsRZmCspof+WM5iTR6RX68cU3CoaoSM l9nuO2e9d3kIa+jJ4c8vv8Iys2vjX+lKYLFomBPFw23m/WtiJ8uKO8Z3l9YsCzfMySnD j3FMV3AjDjCDnCuxHJpMQZLKXXs7hGgucJsHobsiDv0LE3FHzMp1kfLes5xL30P0u3tN erI7BWzj/PzvDyv4wikZ8LOD8jGJ3R8fCu5HGXve8a5+vTDnvgczh7dt77ruH04lDbkI cIjplpUUYyjJ4Lm3o9UNaUBueezNRrGtKrcU7jspNPFSsIuubPlHf7q7IcbKOzWjsYam TJNQ== X-Gm-Message-State: AC+VfDykz9SqVPhugjVq5Miyelu/7D+Y2SxhR9pV6o0qpVipwCuxLNDz GiRkcu+sdp/eM0sX7+lUb96CTg== 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-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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--