Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3159121imm; Fri, 24 Aug 2018 11:37:48 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda+EAyD3FYLCECUcxSkgaC9ZhWKAm3UX3mtuHZqsmZlhHLsGphqAla6tEYJh5e0oJOEgrbH X-Received: by 2002:a65:420c:: with SMTP id c12-v6mr2765822pgq.405.1535135868733; Fri, 24 Aug 2018 11:37:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535135868; cv=none; d=google.com; s=arc-20160816; b=0ie0ZReFIjEiN7jtjH2fio09JyTbuNfh53wprScQttzdye7pFGoOeZLMjQLL6YrohG i8jodnyAUhsGT7MmYM/fxGVTjaycOSGHlR0PyuMHIJ07HWnnpuFXIcsUCsbEtc7Eo4oU ph8Qjfj1af/kKVrGN/y6c3FC/gn3SbtRJlP/B9j2jFYWG4CHZuYKFIc1nD90uF2KiOrg 1aVYZffWuYG0QjdDSevj1D+FWt/LeKvO70S6I86O97TT2nBVl+xvnpB7A8IF54Gh4oh3 KODEJI69fOeJRK/WA0xggGffVuogXxP0tHkc6ntizi3WwqBenX70Ogt8hkmPHTfhBC52 OvZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature:arc-authentication-results; bh=eKVewptwrD9lnrLnfnl+foCk/VIkfCVtBX6m8FuKBjs=; b=JTIn57YbrGeJkZFYQO4YFrw0KMtLKdRjLHIz/Q7nTSi/6Zt2wuAWOMCofMkZtqNZAx i0tYxsxrHt+LYA+z++ig0AhrYX+p5VUeAApqCVX/LUgJwYWI3KdWWMDPI54S5G9TM2u2 e3vTxOn1rN6G8AskjVa2Fgubho0wfvn3k10M1j4aOMx7RDRgLZQxL/0a5BtqFMVvmkHp 59LhfeNV8Y5on+FFvXOwF99gEnZtvr+3R4zzKekuWrdFGxpv4ZuhXFhuUNlF3gW+OL83 IEGLDcYxTzOvCbbM6WBsq6Pqh1qy1baQBF1OH0+9wb0fyhVBkSn88oieC1CCm/23cqCt vbLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=IvlJOOy9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b11-v6si3075149pgj.228.2018.08.24.11.37.32; Fri, 24 Aug 2018 11:37:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=IvlJOOy9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726911AbeHXWLs (ORCPT + 99 others); Fri, 24 Aug 2018 18:11:48 -0400 Received: from mail-pl1-f170.google.com ([209.85.214.170]:41109 "EHLO mail-pl1-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726535AbeHXWLr (ORCPT ); Fri, 24 Aug 2018 18:11:47 -0400 Received: by mail-pl1-f170.google.com with SMTP id p4-v6so1442065pll.8 for ; Fri, 24 Aug 2018 11:36:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=eKVewptwrD9lnrLnfnl+foCk/VIkfCVtBX6m8FuKBjs=; b=IvlJOOy9vqWiVDL1ZmMMHIk3izjfZoaZdpISEu+ZnIPH5qvXEJ22KilEgNMgD35UTB s+b4uYnyiUXChKrA3XmzjgWhf1n8UXpEBXiSJ0JaaXUQFUvFT4elZJI9OYt7JAEubOkj BZjHn6cphOsgQjIAYZYCRWLUFixojYMI+LdNbSEqqWiGVPY59qBWXhsNDkOUx3+k1gVp otM4sT32gGYjafoN+lNwYWBlb4Vu0Cxz0fkaZx5kcbNY1G+n2IQjOlUSr8z/Vidy/l4a FeUX2r5VY6MQj/brhPNBxcmH36TPXFV9DPiJv/TjBNn+gM1Fl8F/vRnyY6EXTsNDeTr7 VoTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=eKVewptwrD9lnrLnfnl+foCk/VIkfCVtBX6m8FuKBjs=; b=FfIq/I7srbrns6R86dET1Kol0JkipEpbHGWL6cWcJ0YAsqjWz8hSYwfixoqj1E3M8R DcxAos4TZfWeOWVrzjUCjmFZH/lxIb0uwREr/QO2LMy0Htcdu15kDbcNImW1qrOzvWy1 BkJZIWDmh2eviTv/0e6vmZQz9YdHpIpkI7SLYIdcEw0GgrCz7RgTeUrvI2ObZcqF93ov OlZoNF5IbJBYBhN4CAzIZ/gDYbirtb/pz660/4sc6JuDBlR3CO05Jh3tyBk57SMwIep8 1KSNs64DrfnEv6JdCcSDTohJxo1QTAPpH90IIRwZnRapbaQ1HjpMcCcytW/sBQcVHG/3 5WEQ== X-Gm-Message-State: APzg51CX1miDX0wcE6sjvz5q1lA3y4xvWPp5/D4aJs9xXKyiLk49x/hL P3EGUC+/UlmnF6HqTJUFYJM= X-Received: by 2002:a17:902:4a0c:: with SMTP id w12-v6mr2705047pld.289.1535135759908; Fri, 24 Aug 2018 11:35:59 -0700 (PDT) Received: from [10.33.114.204] ([66.170.99.1]) by smtp.gmail.com with ESMTPSA id c85-v6sm20859478pfd.110.2018.08.24.11.35.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Aug 2018 11:35:59 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\)) Subject: TLB flushes on fixmap changes From: Nadav Amit In-Reply-To: <20180824180438.GS24124@hirez.programming.kicks-ass.net> Date: Fri, 24 Aug 2018 11:35:57 -0700 Cc: Will Deacon , Linus Torvalds , Benjamin Herrenschmidt , Nick Piggin , Andrew Lutomirski , the arch/x86 maintainers , Borislav Petkov , Rik van Riel , Jann Horn , Adin Scannell , Dave Hansen , Linux Kernel Mailing List , linux-mm , David Miller , Martin Schwidefsky , Michael Ellerman Content-Transfer-Encoding: quoted-printable Message-Id: <56A9902F-44BE-4520-A17C-26650FCC3A11@gmail.com> References: <20180822153012.173508681@infradead.org> <20180822154046.823850812@infradead.org> <20180822155527.GF24124@hirez.programming.kicks-ass.net> <20180823134525.5f12b0d3@roar.ozlabs.ibm.com> <776104d4c8e4fc680004d69e3a4c2594b638b6d1.camel@au1.ibm.com> <20180823133958.GA1496@brain-police> <20180824084717.GK24124@hirez.programming.kicks-ass.net> <20180824180438.GS24124@hirez.programming.kicks-ass.net> To: Peter Zijlstra X-Mailer: Apple Mail (2.3445.9.1) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org at 11:04 AM, Peter Zijlstra wrote: > On Fri, Aug 24, 2018 at 10:26:50AM -0700, Nadav Amit wrote: >> at 1:47 AM, Peter Zijlstra wrote: >>=20 >>> On Thu, Aug 23, 2018 at 02:39:59PM +0100, Will Deacon wrote: >>>> The only problem with this approach is that we've lost track of the = granule >>>> size by the point we get to the tlb_flush(), so we can't adjust the = stride of >>>> the TLB invalidations for huge mappings, which actually works = nicely in the >>>> synchronous case (e.g. we perform a single invalidation for a 2MB = mapping, >>>> rather than iterating over it at a 4k granule). >>>>=20 >>>> One thing we could do is switch to synchronous mode if we detect a = change in >>>> granule (i.e. treat it like a batch failure). >>>=20 >>> We could use tlb_start_vma() to track that, I think. Shouldn't be = too >>> hard. >>=20 >> Somewhat unrelated, but I use this opportunity that TLB got your = attention >> for something that bothers me for some time. clear_fixmap(), which is = used >> in various places (e.g., text_poke()), ends up in doing only a local = TLB >> flush (in __set_pte_vaddr()). >>=20 >> Is that sufficient? >=20 > Urgh.. weren't the fixmaps per cpu? Bah, I remember looking at this > during PTI, but I seem to have forgotten everything again. [ Changed the title. Sorry for hijacking the thread. ] Since: native_set_fixmap()->set_pte_vaddr()->pgd_offset_k() And pgd_offset_k() uses init_mm, they do not seem to be per-CPU. In addition, the __flush_tlb_one_kernel() in text_poke() seems redundant (since set_fixmap() should do it as well). If you also think the current behavior is inappropriate, I can take a = stab at fixing it by adding a shootdown. But, if text_poke() is called when interrupts are disabled, the fix would be annoying.