Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp4531623rwo; Tue, 25 Jul 2023 07:26:18 -0700 (PDT) X-Google-Smtp-Source: APBJJlHve8WFuGFuSNThX2PgMpXW7IYYIZcWnjdyCw5AEqunr33lJOINqZAz4qydxIuirgtE9/C4 X-Received: by 2002:a17:90a:638d:b0:262:d7db:2520 with SMTP id f13-20020a17090a638d00b00262d7db2520mr10035722pjj.26.1690295178019; Tue, 25 Jul 2023 07:26:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690295178; cv=none; d=google.com; s=arc-20160816; b=AUnSi1dV5ilcx1U1SCsBeokFlUW3rPI7bzCNzaozuP7lBW+a9jMXLhC8XTY9jd6nqY 9L+V4h2+rIGH7TMz4HZtQ+BHAY9UW53wEw08eCgpVSWPjx26/BDbf2Yw8RWxZ7EHcMb2 +wx4Aph6FLVXDPjGrzRJFri/BrGVTbSUFCqFvlJvEKu8HvRVcYccY2fcHy0iWCvrymel /3zamq2BdnESQ7AYRON/GzheV/MsmGtJ0UWEyO+5qBmrpTv051G22BKZm5etLvgRMELM WmpY0HsHiIsLoZawi/w2N6zT0ucH5eLxkQqA1YVRxUdpJnmILR7ea93knSzc7THJ0bTg FaJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=uGwtpv4sQ6tMlJnBprHpZy+A2shb5owm6FTDMaQEmXQ=; fh=eCNCeXLXc0CRa8qNIG2q813ybFYG+tN3snLdHM1260g=; b=W3t767LhAlYWox6U2V6qBG8edEjkKtQ8P2UtiKCjfvclcwarKAIdN8xqiBeqw7Cph3 WdDN6HX/dM2QcFwwcTZBW2adks0F7Yk2l/wuBObawiQy9gKcW3omrK5fy4ilSJydUe6/ nxTuliyYt1YqkehYHQORrWSvA9Qf7SfeFhiWi1xQqdhrCGk2C3tVW2STdy58ik+Iqp7M BrQMTeYyZ01g4Kteikbm0UbEg+UFZkpa2GG7KbmBZA81KSVAHAmJdmjqZ4Sn1aR1AQ7x SK2MmnYf//FXVkHY6tZbEfzknhDqCJgmT1VihAorDRhFp4TxIr6fei8t+CMJFd/7lxC3 2PEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LiZCBSiE; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id om15-20020a17090b3a8f00b00258ee17486bsi12580781pjb.160.2023.07.25.07.26.06; Tue, 25 Jul 2023 07:26:17 -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=@redhat.com header.s=mimecast20190719 header.b=LiZCBSiE; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232147AbjGYOEL (ORCPT + 99 others); Tue, 25 Jul 2023 10:04:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232141AbjGYOEJ (ORCPT ); Tue, 25 Jul 2023 10:04:09 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7303D1BD6 for ; Tue, 25 Jul 2023 07:03:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690293801; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=uGwtpv4sQ6tMlJnBprHpZy+A2shb5owm6FTDMaQEmXQ=; b=LiZCBSiEBxikXXMiiG3rHj52jTzKzSafrctXZWE85NhD0rFIdhfXysoL1nG4XaVX589PDF EUAS7B33vOn6L0tiaobPuLBUHI+esjTgs5pR3o5ng7eM0B6mxuAkEMypaJ+xjv/suQSXNY uLzHuSN5Ad7bgZipY6nYLLtAY/wILUU= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-536-WWrD-uHNPmCN3T2aJwvUTQ-1; Tue, 25 Jul 2023 10:03:20 -0400 X-MC-Unique: WWrD-uHNPmCN3T2aJwvUTQ-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-3fd2e59bc53so14941565e9.1 for ; Tue, 25 Jul 2023 07:03:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690293799; x=1690898599; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uGwtpv4sQ6tMlJnBprHpZy+A2shb5owm6FTDMaQEmXQ=; b=PYtrGHO8dZ9UF9PBZHiVqLWyhIb5AF3Qrsgff4pk28kY3EfyOeSvDkBsE5Rmglw2A5 TXk6G6W7VbCp2WlURvn0vztUE3pERlqWVQqE1GTDZ6ARikU84H4SN06/u0jF5Rtx8xH5 /9gepwPv+0aWugk5SOeEAaXEUP0jP5a0uSXAz/y0cLNXit2j2VIVGwNma7iYhfJYYJEB WKoksGklFMld/TfDxvTzpgbY/4kt1HwzcokQgrI0FGHZLZewEmMdmiHSiwQR/C2Z6xNw 2XEoAEQt+CkSjjUsoKOTzK+f0lR6y75YpkqdnPUTxcM7OFEhBVt8YlcvCfRefOIHcieZ BkNg== X-Gm-Message-State: ABy/qLYpiN8m6eGsxiWm+PgFsU1xow0pF3elpMN50hTppTpUMCZGPDI/ 7LzStG6Jy8Qx6f9sHtstAXZyc/pZY/2hGeQqEfiHSLdj9Wvf8Eh8a333JXK/VfxtcDpwImJhFLe zlXnyG/+xe2qSaMQXz/0YnqXl X-Received: by 2002:a05:600c:2981:b0:3fb:b890:128b with SMTP id r1-20020a05600c298100b003fbb890128bmr9613838wmd.27.1690293798857; Tue, 25 Jul 2023 07:03:18 -0700 (PDT) X-Received: by 2002:a05:600c:2981:b0:3fb:b890:128b with SMTP id r1-20020a05600c298100b003fbb890128bmr9613787wmd.27.1690293798543; Tue, 25 Jul 2023 07:03:18 -0700 (PDT) Received: from vschneid.remote.csb ([149.12.7.81]) by smtp.gmail.com with ESMTPSA id s15-20020a05600c044f00b003fbc89af035sm13424142wmb.17.2023.07.25.07.03.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 07:03:18 -0700 (PDT) From: Valentin Schneider To: Peter Zijlstra , Dave Hansen Cc: Nadav Amit , Linux Kernel Mailing List , "linux-trace-kernel@vger.kernel.org" , "linux-doc@vger.kernel.org" , "kvm@vger.kernel.org" , linux-mm , bpf , the arch/x86 maintainers , "rcu@vger.kernel.org" , "linux-kselftest@vger.kernel.org" , Steven Rostedt , Masami Hiramatsu , Jonathan Corbet , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Paolo Bonzini , Wanpeng Li , Vitaly Kuznetsov , Andy Lutomirski , Frederic Weisbecker , "Paul E. McKenney" , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Andrew Morton , Uladzislau Rezki , Christoph Hellwig , Lorenzo Stoakes , Josh Poimboeuf , Jason Baron , Kees Cook , Sami Tolvanen , Ard Biesheuvel , Nicholas Piggin , Juerg Haefliger , Nicolas Saenz Julienne , "Kirill A. Shutemov" , Dan Carpenter , Chuang Wang , Yang Jihong , Petr Mladek , "Jason A. Donenfeld" , Song Liu , Julian Pidancet , Tom Lendacky , Dionna Glaze , Thomas =?utf-8?Q?Wei=C3=9Fschuh?= , Juri Lelli , Daniel Bristot de Oliveira , Marcelo Tosatti , Yair Podemsky Subject: Re: [RFC PATCH v2 20/20] x86/mm, mm/vmalloc: Defer flush_tlb_kernel_range() targeting NOHZ_FULL CPUs In-Reply-To: <20230725132155.GJ3765278@hirez.programming.kicks-ass.net> References: <20230720163056.2564824-1-vschneid@redhat.com> <20230720163056.2564824-21-vschneid@redhat.com> <188AEA79-10E6-4DFF-86F4-FE624FD1880F@vmware.com> <2284d0db-f94a-e059-7bd0-bab4f112ed35@intel.com> <20230725132155.GJ3765278@hirez.programming.kicks-ass.net> Date: Tue, 25 Jul 2023 15:03:15 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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 Sorry, I missed out Dave's email, so now I'm taking my time to page (hah!) all of this. On 25/07/23 15:21, Peter Zijlstra wrote: > On Mon, Jul 24, 2023 at 10:40:04AM -0700, Dave Hansen wrote: > >> TLB flushes for freed page tables are another game entirely. The CPU is >> free to cache any part of the paging hierarchy it wants at any time. >> It's also free to set accessed and dirty bits at any time, even for >> instructions that may never execute architecturally. >> >> That basically means that if you have *ANY* freed page table page >> *ANYWHERE* in the page table hierarchy of any CPU at any time ... you're >> screwed. >> >> There's no reasoning about accesses or ordering. As soon as the CPU >> does *anything*, it's out to get you. >> OK, I feel like I need to go back do some more reading now, but I think I get the difference. Thanks for spelling it out. >> You're going to need to do something a lot more radical to deal with >> free page table pages. > > Ha! IIRC the only thing we can reasonably do there is to have strict > per-cpu page-tables such that NOHZ_FULL CPUs can be isolated. That is, > as long we the per-cpu tables do not contain -- and have never contained > -- a particular table page, we can avoid flushing it. Because if it > never was there, it also couldn't have speculatively loaded it. > > Now, x86 doesn't really do per-cpu page tables easily (otherwise we'd > have done them ages ago) and doing them is going to be *major* surgery > and pain. > > Other than that, we must take the TLBI-IPI when freeing > page-table-pages. > > > But yeah, I think Nadav is right, vmalloc.c never frees page-tables (or > at least, I couldn't find it in a hurry either), but if we're going to > be doing this, then that file must include a very prominent comment > explaining it must never actually do so either. > I also couldn't find any freeing of the page-table-pages, I'll do another pass and sharpen my quill for a big fat comment. > Not being able to free page-tables might be a 'problem' if we're going > to be doing more of HUGE_VMALLOC, because that means it becomes rather > hard to swizzle from small to large pages.