Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2412883rwb; Mon, 7 Nov 2022 13:01:33 -0800 (PST) X-Google-Smtp-Source: AMsMyM7tjPoi8Yg5uDBu3W8lGycUBlboBXG7/regmamnZjpf7ZP9kuNbG4Kx7RWRgO4SB0fqnpqZ X-Received: by 2002:a63:5266:0:b0:439:920b:fc65 with SMTP id s38-20020a635266000000b00439920bfc65mr44306512pgl.417.1667854893494; Mon, 07 Nov 2022 13:01:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667854893; cv=none; d=google.com; s=arc-20160816; b=JjGBVHxixZOy7D5gDysTA8r7vA3CR3gse2r4g06keS2lYUEHj/dGumSnP9y5c0GrK9 4Hs5vTQGy+fvdz3gGRUc10nntKNv6Kn45YA2LEKJLYyJAQAj5CRuFkqC2uhKewaK3Oto MbGLwZYZPSe91vOeVzQgL/BRHkWfx4SuZDkws9vXCHYx6GSibPWbrqldbAT4T44u0csC epeHJF8z0QyP2eFz4RI+fjfKs8OaGmffgsp5zgyWNNtgu64hvEQUYOtxROTSbuQ25wVh M8u2nTMUBAzeTwrg0DO8FZons4mzREMP7nj/ZZ6lik28WQsa8ev5Mjaun68bCvjccK9g eB1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=rmekPIfsDhO/c1VKUUGZV/Wt7GFULF9qq4iGNhwtPaQ=; b=lOMn1XvZCgAz714zxnuFLL5i7inzvb6IcaNKLEmHLeZGt6cpi/kPUlJYXXyDIK7edu 3W0HtTaugzAm+Ny2ZmSsuM2nJGs5krs3LpTvdVPKITEqin16dOeY0lX5WQrcNLVdRZFB V9f5MgOnO70Kt7qD6UTEEYM2qwjhYAKDY2mt+SUWAbSjsfK3QmYnoyQ1PFHRMabRPnHb h0cinpunA5AOrJ0JPrUlbYJBATDQAmitGr12rEPiSWARoLVSgQoUJMjbRq9biUBSp0LX N8Vg1VpehXc1okMsrXpoB1tqVImsqpwxOm+MBrG7ZZsJ7ipxdzZr483/7VJ8GihLTO9e L6HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=WoUgENFw; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e66-20020a636945000000b0042af7555d10si6413099pgc.862.2022.11.07.13.01.17; Mon, 07 Nov 2022 13:01:33 -0800 (PST) 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=@linux-foundation.org header.s=google header.b=WoUgENFw; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232847AbiKGU3m (ORCPT + 93 others); Mon, 7 Nov 2022 15:29:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232501AbiKGU3h (ORCPT ); Mon, 7 Nov 2022 15:29:37 -0500 Received: from mail-qv1-xf32.google.com (mail-qv1-xf32.google.com [IPv6:2607:f8b0:4864:20::f32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2ACA4183B6 for ; Mon, 7 Nov 2022 12:29:36 -0800 (PST) Received: by mail-qv1-xf32.google.com with SMTP id j6so8903436qvn.12 for ; Mon, 07 Nov 2022 12:29:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=rmekPIfsDhO/c1VKUUGZV/Wt7GFULF9qq4iGNhwtPaQ=; b=WoUgENFw6x+yDkOL6DTJqhHSKthAbh8p3B4djaVfiu1Y1OuAAH5VN0vqEy2WlUru6T qBEWcImUuA95okNKVQS17+EvIUay4jWOzyHexqa6/e0Q/rmKyMAQKq5oz9xW/cpg+3BR IBAgXFUqMgzbuGwbQH9Ng0QPbzKb63u+5xeN8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=rmekPIfsDhO/c1VKUUGZV/Wt7GFULF9qq4iGNhwtPaQ=; b=AZzfz2EgY405mON0UmPcMKRqRYIZg8b7lJipbR+nX9QzdLdmCVOzwiQ9ePyDqHGsfz q2598WJiquUxFgdrLhUHyPbS0xkzW0f98i0i0vm9ypAUt1R/ux0NYhZlrwxjmQZgWLWr Hsz51jl3QRL3DdTaTiUDmBOcB7fi2QruUXSt4hM25WjfzzMOQyE6HYz6SC5glz7dJguw 3pkHtZlDO/hymvtgJHoOtGh2UgrP/ra7AiWZVQcvq0/b9/Wg2SJ3+R4OhsX6EYvZa6Mj X2jCaRP1M9CuJAF5axkXTBZVbsS1OUlt2wdmTUiaroqD3+QFtlD65+pUNrhIHlPLLpPr pypg== X-Gm-Message-State: ACrzQf1UlE2Pcl1XFHNu0zc4Nuc7DDLPBhCcAJRU24dwzN7azgLLBnFZ PZBNzXqszc10U4IZX9tyMmftZozdizBS8Q== X-Received: by 2002:a0c:a702:0:b0:4c1:2cc7:2d3d with SMTP id u2-20020a0ca702000000b004c12cc72d3dmr19035670qva.88.1667852975130; Mon, 07 Nov 2022 12:29:35 -0800 (PST) Received: from mail-yb1-f174.google.com (mail-yb1-f174.google.com. [209.85.219.174]) by smtp.gmail.com with ESMTPSA id c8-20020a05620a134800b006ecb9dfdd15sm7405414qkl.92.2022.11.07.12.29.28 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 07 Nov 2022 12:29:29 -0800 (PST) Received: by mail-yb1-f174.google.com with SMTP id o70so14998187yba.7 for ; Mon, 07 Nov 2022 12:29:28 -0800 (PST) X-Received: by 2002:a25:bd7:0:b0:6d7:7464:4859 with SMTP id 206-20020a250bd7000000b006d774644859mr5895133ybl.362.1667852967798; Mon, 07 Nov 2022 12:29:27 -0800 (PST) MIME-Version: 1.0 References: <8a1e97c9-bd5-7473-6da8-2aa75198fbe8@google.com> In-Reply-To: From: Linus Torvalds Date: Mon, 7 Nov 2022 12:29:11 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: mm: delay rmap removal until after TLB flush To: Johannes Weiner Cc: Hugh Dickins , Stephen Rothwell , Alexander Gordeev , Peter Zijlstra , Will Deacon , Aneesh Kumar , Nick Piggin , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , Nadav Amit , Jann Horn , John Hubbard , X86 ML , Matthew Wilcox , Andrew Morton , kernel list , Linux-MM , Andrea Arcangeli , "Kirill A . Shutemov" , Joerg Roedel , Uros Bizjak , Alistair Popple , linux-arch Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=no 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, Nov 7, 2022 at 12:07 PM Johannes Weiner wrote: > > - If we DO want to codify the pte lock requirement, we should just > remove the lock_page_memcg() altogether, as it's fully redundant. > > I'm leaning toward that second option. The thing is, that's very much the case we do *not* want. We need to delay the rmap removal until at least after the TLB flush. At least for dirty filemapped pages - because the page cleaning needs to see that they exists as mapped entities until all CPU's have *actually* dropped them. Now, we do the TLB flush still under the page table lock, so we could still then do the rmap removal before dropping the lock. But it would be much cleaner from the TLB flushing standpoint to delay it until the page freeing, which ends up being delayed until after the lock is dropped. That said, if always doing the rmap removal under the page table lock means that that memcg lock can just be deleted in that whole path, I will certainly bow to _that_ simplification instead, and just handle the dirty pages after the TLB flush but before the page table drop. Linus