Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1271544rwd; Wed, 31 May 2023 11:34:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6JMLP0AitWMmc/XrShGfZq+H2PD13si7zXfODBVa8EY+89AJwDk/OWCFBOK2sd7I4NOZnf X-Received: by 2002:a9d:7753:0:b0:6b0:e010:4b44 with SMTP id t19-20020a9d7753000000b006b0e0104b44mr3185958otl.33.1685558084909; Wed, 31 May 2023 11:34:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685558084; cv=none; d=google.com; s=arc-20160816; b=fTz6HoAhbwXHz/7bRrYkX4sGZVC2Dh3pwLawEJFDj4H2z9RDq1sUJXRYOTS6BEdc0B O6zD+g5iuXXGE30nZAaz5Nr9FrwFus+aFXmhISXUDbujL0RlGI+ULXvi0N8BrsSbu8t6 9x+TCbmydZ1Pr/7Kb+mA5Edl0VlYvjt2dD+QnZd9z7WKHnUymrPJ+UJBn8jfj11hdkjf C+ogcS9ButLyVB+4LlXG4ztTIqKzE49a3GWbaOOY6BXKRwCSWdZLoDUxLGXnvcQLoKJG slhdPvLHs1Ouw9EOtglfDKixdEs24s1FE68V/RPbuOpyMGeAPb/35D70gZw6kCQlSBok IbUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=gB39BX9t2bk69eR34cuPtTrtH3iMrtwgLqGN0anXQzs=; b=XjKdteQJ5waUw1G2vvfsaOnatmYbkhiwiFoYaMe1DVFGv7nV1Bb3oZbBbJCNzaQ/HR UmfYP4YT9jB9Ekgq3cS4nI1DjVhO0iF/SZJCp7emZk3r3pguDgkAdPW443GjTpGxAtaZ eE/3rIa5E0ugvOpEiUIgdbe9aqWFVENn3yu66VF/g3TADemNVF/2KMlBWJY2YNG0lQq4 WsBXeiS9U9qeo4JCpeNUSoRj20ev9PzJa4+1AIzUZFnwt6ScGPjVhfL5aMaSuEJt77sr x94uuvZndnpZ671jNfPWRdwLIxS1Jp7dV90D07KgRQdm3DpffN+CnDw40+xautHmwjSH gMVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=sNHcscEz; 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 x22-20020a656ab6000000b00535a71508f3si1448672pgu.77.2023.05.31.11.34.29; Wed, 31 May 2023 11:34:44 -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=sNHcscEz; 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 S229527AbjEaSAB (ORCPT + 99 others); Wed, 31 May 2023 14:00:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230179AbjEaR77 (ORCPT ); Wed, 31 May 2023 13:59:59 -0400 Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F696126 for ; Wed, 31 May 2023 10:59:57 -0700 (PDT) Received: by mail-il1-x135.google.com with SMTP id e9e14a558f8ab-33baee0235cso12995ab.1 for ; Wed, 31 May 2023 10:59:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685555997; x=1688147997; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=gB39BX9t2bk69eR34cuPtTrtH3iMrtwgLqGN0anXQzs=; b=sNHcscEzF5oIXlbzrKvF04KLUYw1WT7sMRVqG8QGy8XIgG11atPlAKnpx5jKGtpy6a a+jCVG2eG9BX6mHRsSpbaugSwkATgdYQoWfvZd+ALZ/Jy6Mauf49PzdPffe5WmNZPR4Z WAFrsIXSEXKtDxjryc6yB0Z+hcuRTBy1nOpSqzMGFFGOJoYlv2FFuEbQe/FRb7W1B+KV 0tTSBe6RpqLXei52V6g9ZxrdXeXwUXD4CalXMcTtAUE4wynrS414dVRH12lnDs0RZxQf mSOnJt6GA5r/CNqCC7dCE5XlEFmkMml+h5K7Z1ZJnauFHk0x4Zj6P4zxqfq+t5LPRE9b dxAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685555997; x=1688147997; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gB39BX9t2bk69eR34cuPtTrtH3iMrtwgLqGN0anXQzs=; b=RtqFK+7f5W75AWsTHtEl2/bsbMneZqATmkfeLvjhjSIh8mmSL/b4ExEHqsTuiQoHNL 3PPptbzFqraIHmcwviZ3YWnllC2sZzpM598xvDONpXx0Ae5zdQZZvc49tXCSWgRKkofD SNilW8Lr/U5YRs4amtvxRRV/7vZRp2tQvDMiKBpj/r5zqfAUK/RTT4362aIGTZ/SAfAw oa4IZHgO4zuK8jqn10pfyYzJ+e5fqK9TDGs0COc/b4HMaG8mi7hYVdJ0jhPxi/qLEZQe cjwt1xw3rr8bPLpP4FM6ixe3Z9kbXfP03HMoTdnHXVVA1ImQxUeN2V3PcSoRSm2XXzPL Q4ew== X-Gm-Message-State: AC+VfDwZjho0C6tJcqUmBKzsf4vgUVY19Ezdvd4ENPLu4Jg2sanq0ofS fiojcDVjZWHQClCcJ6E/r7n20VGmTrs4fJsL5a2Ipw== X-Received: by 2002:a05:6e02:b2e:b0:33b:5343:c1be with SMTP id e14-20020a056e020b2e00b0033b5343c1bemr174970ilu.29.1685555996652; Wed, 31 May 2023 10:59:56 -0700 (PDT) MIME-Version: 1.0 References: <35e983f5-7ed3-b310-d949-9ae8b130cdab@google.com> In-Reply-To: <35e983f5-7ed3-b310-d949-9ae8b130cdab@google.com> From: Jann Horn Date: Wed, 31 May 2023 19:59:20 +0200 Message-ID: Subject: Re: [PATCH 00/12] mm: free retracted page table by RCU To: Hugh Dickins Cc: 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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=ham 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 On Mon, May 29, 2023 at 8:11=E2=80=AFAM Hugh Dickins wro= te: > Here is the third series of patches to mm (and a few architectures), base= d > on v6.4-rc3 with the preceding two series applied: in which khugepaged > takes advantage of pte_offset_map[_lock]() allowing for pmd transitions. To clarify: Part of the design here is that when you look up a user page table with pte_offset_map_nolock() or pte_offset_map() without holding mmap_lock in write mode, and you later lock the page table yourself, you don't know whether you actually have the real page table or a detached table that is currently in its RCU grace period, right? And detached tables are supposed to consist of only zeroed entries, and we assume that no relevant codepath will do anything bad if one of these functions spuriously returns a pointer to a page table full of zeroed entries? 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? If that's the intent, it might be good to add some comments, because at least to me that's not very obvious.