From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E786DC0015E for ; Tue, 25 Jul 2023 14:05:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 54F138D0001; Tue, 25 Jul 2023 10:05:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4FC976B0074; Tue, 25 Jul 2023 10:05:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 375BF8D0001; Tue, 25 Jul 2023 10:05:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 247236B0071 for ; Tue, 25 Jul 2023 10:05:59 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id C08B71A0E7F for ; Tue, 25 Jul 2023 14:05:58 +0000 (UTC) X-FDA: 81050307996.02.B4D2F95 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf05.hostedemail.com (Postfix) with ESMTP id 542771003CF for ; Tue, 25 Jul 2023 14:03:22 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=YlX8CUDj; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf05.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690293803; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=uGwtpv4sQ6tMlJnBprHpZy+A2shb5owm6FTDMaQEmXQ=; b=BO3mt+eyv5ZTcIqyHkbwn8YanCSVKNXxKvM0rlSFV0XPjVn8kPnQpJPtpvI1TJMu9ZQDTR d81FlAwbyQN3WDoGrciW668Mlf6x7WdLaNrBvqSCpRQmVzrz3aAmIXCHEbtaIjChEUIRJ9 HBLi64jj05NCJmjYI4GDuy4228r90x8= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=YlX8CUDj; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf05.hostedemail.com: domain of vschneid@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=vschneid@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690293803; a=rsa-sha256; cv=none; b=QX0DkWk9uh+ZjbytKujaBQvzHRDDVLqy3InU5779BjoQHwBipf/rlHE+aUTQ/pwHfFlKQ4 ta3x1RJQL6e1aSgPc5wjjNvHe0Uvvxi0z40hAHVgwq1W5eXd2Cj3L4fSfP1Vbob5xvHaXS NPM0oj01McTERYmbnDG00j5ArVHIKlA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690293802; 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=YlX8CUDjpTTdrTFtCy30L4+QqzqB+ukrvQKXSFp5/fUimRBReXVUDCMoYKB3PJ6xE2ICDN 3/6iMyBy4cxQu19doGdbg0OpF9z4L3Rz2o72SL0+NHWpoh4vB+HvMH368Jpx8nkMUpHZ5K +wHVryv8H1zINsKho/SYUzTGrZCqAVg= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-534-UvqxPg7QOGKEcr9mWCKgIw-1; Tue, 25 Jul 2023 10:03:20 -0400 X-MC-Unique: UvqxPg7QOGKEcr9mWCKgIw-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-3f41a04a297so27530985e9.3 for ; Tue, 25 Jul 2023 07:03:19 -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=Vj0mfpTOUP9pRAJm78tk4QaTeVD3M1T5boPQa0pz9sFbIuCGuAYAieSDXksCzDShsI ZZZ6Y393wU90xAh0eNUxIDXpinEmWDPE6jUBjrvHypStHDQRBvhqZRWMWEFG8RhXrsso 0ouDuHJBBv53ndgDxXL/CU97JJ/2vYdbIF0RONjAVdOk0N8ic1O7nJi9PxaTMH34lqms GXGBHtha2BozBCtiZKIu0k8mEQjxHvh6KDscLgcPkVU0Qoz3biPLn1qzjdGj8suT61es sfj6gX9p7HDGpzWSJhqGVQTQ3uJhCnZoNAomcfnZpehasgoiAHSRHa0g/AcJQdX+ht6B stEQ== X-Gm-Message-State: ABy/qLbb3W41dKZ2tM4uaEOdFNThMgUOyxb8+mgTVRCmsPxbmSPCXXZv otF1VOl+IKD4OFv60GLtFJVdrudEbW1k8rRRxggll7OLiIYmtOJcH2ft2XgSXzfevvMkYLTmq7R VhyHxoPyUXKc= X-Received: by 2002:a05:600c:2981:b0:3fb:b890:128b with SMTP id r1-20020a05600c298100b003fbb890128bmr9613835wmd.27.1690293798856; Tue, 25 Jul 2023 07:03:18 -0700 (PDT) X-Google-Smtp-Source: APBJJlGWt7E0uSkTs/ryo2PFkVv/T+3yWUu9tffF3NSN1ZjOzS6i3uoLFxbI/VM6mSJfkjz65gbRPQ== 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 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Rspamd-Queue-Id: 542771003CF X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: czmf34pzb4e8618dfzn1ei58r5bx3p9p X-HE-Tag: 1690293802-862458 X-HE-Meta: U2FsdGVkX1+6Qit5M1opDvDse0hwAqsdG4KQKSN3PTicqLSgQ1VqbSBEXXZjL+xwdWY31JGSbh4whzqtK0vFerf2pxdGw1mL1/RNTH3ekwkamPROaJZrtXgeBqd5wx76N38uqbK7qdeq6dC9NXU7N24Zj0D6HHOvPPs4R2+6SJUlpH0qcT7pCroeNNs4R+Ji3BKL35Zy9kkUrBqNBreJOaDsKfpgTr1IGOgxOQYwEJJ1JhCDByiCQN+o+hyn5oTtihzKaF4lAYMFz1uJxpy16PAT+3rqvRXM/1xP1/Nb8hXi9KzMOTTdd553VaM5++GLyGw1suRcZVvqkNrJPOgU0l+bWAVFyqDHvZlI3nme86uVCRapLR6YZ19fiXx78OlA5d9rbAdSl+E9l2umH0DEUOFn6RPTKM6cWJonc2+vsoMGTctX9/icm5e0/DoAX7kxmENMgaYVMNyJaVzJV10zEbeoKswLIutZMKfQvChEdeA3hABNb/Ffc7lBTtM3fQliea6jp+OGbufEmWkiTt3i755gCu57XWQdb1Lwqdn2NtJi1JDg1lDSMawtW5Qf/1PJnb03Yspk1/WwapfL2KZheMar4BeNAZgS3T3IHvagt0Nv5C9HA1K/dtkhzBPLF1P7O1tNg+/W5u/oOF6OHAWNdxdqoepj8hUpczhsoPNfcTvH9VaD1j0M6rYiec406Qg63YBmLrWL7NZmMIpiw4S2FLML3To0wwUXHkFCLy3QkRJ8jobsx971dKRuhfNAx+hTIRirzk74IDP7dX5HtPn3hLEYBhYZHvfx8OkKIINQIZdh575gMZsw2qm9B791LZEbf8dE4gHrnRxq2p9zDDvTtGVpxe2YmrtVr5quHbW7go4WhbKJ0ryYdhxVHuvobS34MQpEGBP7gvolmU8WsEm+lmhnkLTuQcP7m2YeGaAflhr/7cmgWIX5lcAZxyZWpuY3tPArZFRPFi55b7P1eVi oLHquKcA snMfjFPPKC5RGHbBIjvgf1kUIybe1KtzOmI7XJUfrZjAYgZT1BMWKwCHhezx9+Yf4NQQQbidG0UvUysAoPstM2KcipWcohrLssmUViNcPs3cvH+u3yQeBZxjR8hc0Ok5K9kQetXWF3FdbdMAntwKJ06zeBkUsM8sFw4e0v/L23MvfPFpwOw1QaglKAKiMJhFiSkDpvTZXf3ij5YwBna9s0fMjU0Jm1XDPHURIDLKxGM1OVCtB75cye5He5KINcPApB6Q+VFUuw6qie1gcMmnQWH0pkzLkwGVdicI7TkoT87fxL8fqYDv198oZUIUfMMotXaApE1fzWXLiOn7XPG4AHNfOJ8dXgFIV9y2JxTEuOV6StP2RTGvtiXBbzbOtMFpjYucz0CZukrMvvhrftYQZzyNqVhzJP/ZKGInjzkgKkKOIDVrZakg3WsCygw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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.