Received: by 10.223.164.202 with SMTP id h10csp2618267wrb; Mon, 27 Nov 2017 21:23:38 -0800 (PST) X-Google-Smtp-Source: AGs4zMYY+oP528/xLMJYdwfrw97CLSiJJGMKeCmxuZ0G4bTgs9J6bpPn9VT7Cy8uXBOsFtfpEvvR X-Received: by 10.98.252.7 with SMTP id e7mr39362804pfh.12.1511846618548; Mon, 27 Nov 2017 21:23:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511846618; cv=none; d=google.com; s=arc-20160816; b=1CMqx5PYUz3rr3+iXfAtUz2KsUDG4zijtOMu3oZxiZH/vhoEbuzXfpMzY+x9kVz3/M 47cp5A4FYGdAYtJjzh4Yrm+J74FEW69Fx7X1Y9BeESaM3pOjQvxTw8atKQMT/9LnZiO+ DdQwaCqpfYGcY7i4ROoiJVPNkTp7ZnzODklsR3VGshpLz+mzYC3NgwM7VkZ/NRM0Qlho eF6+OzKrQWLZ5AIxtq8ncNK7v3lYAhl5H4YkvSLDWNaQplHFDwEmUYlJ9FukxzBa9MwK 6j5I7s1w3hhP/tc5jofn8B80nilgGqnkJMIS+6LLSPIMgZlaoqnyVYguMHihPBAQ0Mom xMdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=j/useFdgWC8Rn7NkgeRw6QqR4HfkEJnCU5dNW/MvfL4=; b=Z9Ejxb/eV3E70VjRkNjfISKeu12VJ/zZIvhNplc8HpC+wM1G4u4+I687uVhOVCFsT8 QgAKRTVEl6DJx1QviXk2zvQE0wkhVtERaTSWLvP26194zoKPpOwtpY1iiGu30fDScjr/ AvIOXJbTF6D9vq6Yg/cuuyQ/DqIBc3V/UzSOkUksXFRxHneaTlSy+0h1RwF+efd8R22d T2BVWneE1WfiSIdyonTv4yhqOio6sMDcDDMi3+/Mfwi1CeRRKVb2ZuswaXDeiSViZ6Xz VtzV5LNGYcx7W0ZJu7mV4oGaqeYZAYUQ2MCzJPn9djg+fFThc/CHAXVjwsYFIo2x+JmE LkEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=o6Xv0hjv; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q13si23769298pgp.238.2017.11.27.21.23.27; Mon, 27 Nov 2017 21:23:38 -0800 (PST) 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=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=o6Xv0hjv; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750987AbdK1FWu (ORCPT + 77 others); Tue, 28 Nov 2017 00:22:50 -0500 Received: from mail-io0-f193.google.com ([209.85.223.193]:40086 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750835AbdK1FWt (ORCPT ); Tue, 28 Nov 2017 00:22:49 -0500 Received: by mail-io0-f193.google.com with SMTP id d21so16778660ioe.7 for ; Mon, 27 Nov 2017 21:22:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=j/useFdgWC8Rn7NkgeRw6QqR4HfkEJnCU5dNW/MvfL4=; b=o6Xv0hjvlOvu1gZ1uh+J1YsjVVgjFWCM3wM+858vSl7sZE411KB11105oM0cIZ+49s mg/clwSWtzlnjEvB8lD2WEUk2RMrQfG1WmJSX/IIZ9IRIHAZFIlvfAl4fX8Jo3PtmCgq MLGwPRx9I/EXIeVJkK4GEyk9FHJJ92HaLQkSAfmUAYqCH8JKdn0PQstccAfgy2mLKe7a 5BCT7mBeUIToWBtzC9bKntYBUXTBEsJ20pSkZ4r4o4wEHDNKrQYejGGwS1/ib/mZKQZJ Y4VOSOKatt0WvMLUo9/Arz2nrX33wCsi1eZe7Lxm8uZtLosw+wryWPXARS9YUG8xxEyQ vGTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=j/useFdgWC8Rn7NkgeRw6QqR4HfkEJnCU5dNW/MvfL4=; b=Jdw7WzMhFDF0MaSOG9aTn4cV9GdWi8jLNyae4qqzuDXCfhLyKliOfNgKfIuV/XjBK1 6/7Oi/WtFmzinDMmxSslmyDmSLTvFdFflI4jF9FtRDmpebqazpFyWeIZ+by6gFiBjw4t i0fLyk6V8vqSKRi7o6q6Y3YvBJ73zH4ZyvOK/UeVqBstyKFPaL4NvUSgECL14Db4vRKA ZDmmpbK4+g5IDihysyCWmSu4O23krHw5KeGLlCeSZNhFkYhlXPI/UfKyKQMmtNSF51yU vRk5hLnK+vaStgT1gzT2fwJUOwuyjhXxmOv05PzWpX2vFZV6YCNRo1FhHCR0tsklWvaC afyw== X-Gm-Message-State: AJaThX7urQBIDBsBJ90Xi1YqVZKGfEZ9muNm6Gbi2Ok4LtawKtXxaOQ3 hWDHiHq2wksCFlxq28gsgc67yEMu/eO/ZugGTWXSTg== X-Received: by 10.107.6.169 with SMTP id f41mr45625709ioi.173.1511846568379; Mon, 27 Nov 2017 21:22:48 -0800 (PST) MIME-Version: 1.0 Received: by 10.2.133.35 with HTTP; Mon, 27 Nov 2017 21:22:27 -0800 (PST) In-Reply-To: <20171127104923.14378-17-mingo@kernel.org> References: <20171127104923.14378-1-mingo@kernel.org> <20171127104923.14378-17-mingo@kernel.org> From: Andy Lutomirski Date: Mon, 27 Nov 2017 21:22:27 -0800 Message-ID: Subject: Re: [PATCH 16/24] x86/mm/kaiser: Use PCID feature to make user and kernel switches faster To: Ingo Molnar Cc: "linux-kernel@vger.kernel.org" , Dave Hansen , Thomas Gleixner , "H . Peter Anvin" , Peter Zijlstra , Borislav Petkov , Linus Torvalds Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 27, 2017 at 2:49 AM, Ingo Molnar wrote: > From: Dave Hansen > > Short summary: Use x86 PCID feature to avoid flushing the TLB at all > interrupts and syscalls. Speed them up. Makes context switches > and TLB flushing slower. I suspect that, if we actually did it right (by doing a deferred usermode flush when we switch CR3), it wouldn't make context switches or TLB flushing slower. > + /* > + * On systems with PCIDs, but no INVPCID, the only > + * way to flush a PCID is a CR3 write. Note that > + * we use the kernel page tables with the *user* > + * ASID here. > + */ > + unsigned long user_asid_flush_cr3; > + user_asid_flush_cr3 = build_cr3(pgd, user_asid(kern_asid)); > + write_cr3(user_asid_flush_cr3); This is wrong. If we could atomically switch CR3 and switch it back without any speculative fills in the mean time, we might be okay, but that's not what's happening. We could be filling the TLB with usermode-tagged kernel entries, which is a big no-no. (And I'm ignoring the fact that this code seems to have forgotten the "switch back" part.) > + /* > + * We do not use PCIDs with KAISER unless we also > + * have INVPCID. Getting here is unexpected. > + */ > + WARN_ON_ONCE(1); Well that's a bummer. From 1585216414570762682@xxx Mon Nov 27 10:56:20 +0000 2017 X-GM-THRID: 1585216414570762682 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread