Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp971581rwb; Wed, 16 Nov 2022 10:04:25 -0800 (PST) X-Google-Smtp-Source: AA0mqf47qMB6pLGNbbzfmMwGdhVIo8P6ni9UMSzcrDOamwj3FUXaCquwQ77i1e5Nw/FGA/a7C1Lz X-Received: by 2002:a17:907:cc9d:b0:7ac:ef6b:1ef4 with SMTP id up29-20020a170907cc9d00b007acef6b1ef4mr19668383ejc.104.1668621864994; Wed, 16 Nov 2022 10:04:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668621864; cv=none; d=google.com; s=arc-20160816; b=UMewgajcjVLmIwIW5QwAt8wGR4+GuO6yIb03z0RtYyinf7Od2xsg7DhU9l8XeZvekg 1/BFvAB67wugQijL+XC64yh5WwVKBTGFBtv+atBQO7996zFyVx/NE1tkBotPl3Cr0uO9 p7ythgId4brZ0aq7wyhr6yjtbdZFRRiFCklYHBFrbw5+oeinZDeBtA0OlogqaPOKmIRi p2bZg2do9wZKajC5ZmHSEsN7o4fctnKWIZcS9pMRisjAvvSU1KELyGQZKZ410tDw1Vs2 Wg8EGhDGBz8pSCSDvHzBW5LXnBZEf4Qff2L24a7QUUhxe8c1voqPWcthv0siFwgVFLWG Bnsw== 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=eyCPyeJMcrVYxUOOMaoDJ2LNfvpxquoWrFx7efPrDZ8=; b=cbls6Wa2MMWxEf99cqhF3+HzwPPpktAr9n17N3WtxuEoy/S8LW+93WqSI3r96WSMnP 5HW1rZNJsqyJnBnCd+IsOvJzt+wsL/y575FtTOsPD4xbTBrjf8vCQiOCef67InrSRgtA mdrOfwTuWJzaF2G1+r8fLUlvxeOetqMO/y/9EbnUgjrheUSOfBOt7FC8DR8YjNFqAhjA 5wK3sI3ppnKLihWZjM91WvZtaA7zzervXweDD4zZBegpdkKXolPawmMSA5lHKZ+yn+Ia OEZQToQ4hAmGH2t6WJxoKmOMvrPoc0X4iyHBi5JEvFnUninMayahdGas240RnrHxLJkS zwuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=N7b62XhQ; 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 t20-20020a056402525400b004637e16cf97si16987600edd.597.2022.11.16.10.04.03; Wed, 16 Nov 2022 10:04:24 -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=N7b62XhQ; 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 S233761AbiKPRk2 (ORCPT + 91 others); Wed, 16 Nov 2022 12:40:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233418AbiKPRkJ (ORCPT ); Wed, 16 Nov 2022 12:40:09 -0500 Received: from mail-qk1-x72d.google.com (mail-qk1-x72d.google.com [IPv6:2607:f8b0:4864:20::72d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01EAE59866 for ; Wed, 16 Nov 2022 09:40:09 -0800 (PST) Received: by mail-qk1-x72d.google.com with SMTP id v8so12112458qkg.12 for ; Wed, 16 Nov 2022 09:40:08 -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=eyCPyeJMcrVYxUOOMaoDJ2LNfvpxquoWrFx7efPrDZ8=; b=N7b62XhQzExJQ19iSSJdV9S1Sl+OMEc7fdQOBKMVt/0KOmv6HJZXkiOqukaKHgr+US EL6H/4lI7B/ZV3U+OkaunNG7bK/1YX2WVP1ep35JambbT2mPJC+54u5N6F5V7inevpSI /jtHd/t83esoNYpfH/yuF1F8IkFliNzivdUWc= 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=eyCPyeJMcrVYxUOOMaoDJ2LNfvpxquoWrFx7efPrDZ8=; b=rl5R5djwZrScXrA9HEXz1SBbPBfFJFh72sKmrE9Aipg9dovkK1/4cg4MY0vMcRbOkZ y1V0uE/XOzIfuxlGIOfCO3hxBh2PzepOw0MMlQKiu+sB/hYXScOcWU0YwZImajoQLqOZ QO1LD2Y42O8LNG/irm0kggUYR72XDc3m2kPBxydjGtP/cacnHqxVQD8nrMMahPZ3vrlc j6BobRE6nOij1qb3XBEfUB1ZvMbXNzBvJ+8Dr0CDstV2Tk+3zd0EGFM4Misw70p6l+oN u5fmzbzglb9iUsXCmcyzIdyyOXHKWq3Aw99qHo1sFXqve/lXxziWJK6454xzQMcHUaLT m3Tw== X-Gm-Message-State: ANoB5pmQA1Su1CAKKkEPSwUAr9RQEk4P7GT0KlswefCCFAqeeVFDh6+N UKzb+ikwlC5DXUlBb9ZTa0Xvo+XPHjlDzQ== X-Received: by 2002:a05:620a:e0c:b0:6ee:6845:ced with SMTP id y12-20020a05620a0e0c00b006ee68450cedmr19976653qkm.530.1668620407442; Wed, 16 Nov 2022 09:40:07 -0800 (PST) Received: from mail-qv1-f45.google.com (mail-qv1-f45.google.com. [209.85.219.45]) by smtp.gmail.com with ESMTPSA id q45-20020a05620a2a6d00b006ee7923c187sm10642282qkp.42.2022.11.16.09.40.06 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 16 Nov 2022 09:40:06 -0800 (PST) Received: by mail-qv1-f45.google.com with SMTP id j6so12351563qvn.12 for ; Wed, 16 Nov 2022 09:40:06 -0800 (PST) X-Received: by 2002:ad4:4347:0:b0:4bb:a80f:3f43 with SMTP id q7-20020ad44347000000b004bba80f3f43mr21868972qvs.43.1668620405914; Wed, 16 Nov 2022 09:40:05 -0800 (PST) MIME-Version: 1.0 References: <20221109203051.1835763-1-torvalds@linux-foundation.org> <20221109203051.1835763-4-torvalds@linux-foundation.org> In-Reply-To: From: Linus Torvalds Date: Wed, 16 Nov 2022 09:39:49 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 4/4] mm: delay page_remove_rmap() until after the TLB has been flushed To: Alexander Gordeev Cc: Hugh Dickins , Johannes Weiner , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Nadav Amit , Will Deacon , Aneesh Kumar , Nick Piggin , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , Sven Schnelle , Peter Zijlstra , Gerald Schaefer 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 Tue, Nov 15, 2022 at 11:48 PM Alexander Gordeev wrote: > > Which actually brings a question whether CONFIG_MMU_GATHER_NO_GATHER > mode could be beneficial for UP? No, the NO_GATHER case wouldn't work for UP in general, because once we drop the page table lock, even on UP we end up possibly re-scheduling due to preemption (and even without actual kernel preemption, we have that explicit "cond_resched()" there). And if we schedule to another thread that shares the same VM, that other thread will continue to use the existing TLB entries. And if those TLB entries then point to pages that were already free'd... So the NO_GATHER case requires that you flush the TLB early even on UP, although the requirements are a _bit_ less strict than on SMP. And TLB flushes are not necessarily cheap, even on UP. Now, we could possibly optimize this to the point where it *would* be quite possible - instead of actually flushing the TLB, just set the bit to "flush on next thread switch". So I think the UP case *could* be made to be non-gathering. But I don't think anybody cares about - or tests - UP enough for it to make sense to worry about it. Linus