Received: by 10.213.65.68 with SMTP id h4csp1072029imn; Fri, 6 Apr 2018 14:06:11 -0700 (PDT) X-Google-Smtp-Source: AIpwx48qnRQBtvURUbvb8bEaovFz+bFzdZiA1hJTib/7nZA9Tm7MN1XGgdeR7YsAxEAdkBHPIp7f X-Received: by 10.99.117.79 with SMTP id f15mr2411170pgn.47.1523048771239; Fri, 06 Apr 2018 14:06:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523048771; cv=none; d=google.com; s=arc-20160816; b=Ii55cfNA0MzhDCNo4Xov+K1lsvjNiIhRBNtdnauiuFGDeQ+YHXghfOi9NE37bE6DxN nrMS/oXp2A/QOmeENqr55YqtKtRFL6oBUEyykzpPOFeAoAMbJrVcXSwGUzI4rmoowoBg ZUNDUDK6W3SOLinT2k4zwVgJCoNhjKqe/L44rJATBedi4mDTMueKuCmUvrRP4KQOEZ6T 588ueBpZkdi79NW18H/tiHLpdG778G8pACAt2RMze1EJp6z1EgbSGvrKiXhryKEQLhNg uVRxvIZ2C/UBmzQoYZZqHTm/WmzmTcCtaXqIvTkrsbAQvYZvywRQiAoUJHQB+iOwdnks FYoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:from:cc:to:subject :arc-authentication-results; bh=865Psczt7Bqthm5+9W1FyT3fMygoDqVXg7S+H8+3q9I=; b=BsyMcrpS83dvqcz86kKQ173gFHiCh8f+FuqObITH5BGaUav+G6tX6yfs6FNfAQ9ODO 12DFdTOfp0c3Kz4J51nkSR+6WuVoMtTWOJTHNIeRtDQ29r7Y1EonnYP9OxrzcVQd/Bf3 yild9cchvOhp0S8pYWmF11SKG8asGz61dRs7LK267jXLV6z89oTdq37SdlGV3ZxYuXzs gUs4+3jl1fmWsoNGmS87qjp1Pz3v/jLHcWuJeJB+ST9/3hoNs/Ivx8wpbwXkX1gpe8sJ H058vGNwWzgxF/oaPnEJSrnRnOPkmM1pHp/lbKE/kQ5fmYRxeSTLIkxtu7uNz92O7syj x5rg== ARC-Authentication-Results: i=1; mx.google.com; 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 f19-v6si9211799plj.617.2018.04.06.14.05.34; Fri, 06 Apr 2018 14:06:11 -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; 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 S1751679AbeDFU57 (ORCPT + 99 others); Fri, 6 Apr 2018 16:57:59 -0400 Received: from mga17.intel.com ([192.55.52.151]:19573 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751312AbeDFU56 (ORCPT ); Fri, 6 Apr 2018 16:57:58 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Apr 2018 13:57:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,416,1517904000"; d="scan'208";a="31340123" Received: from viggo.jf.intel.com (HELO localhost.localdomain) ([10.54.39.119]) by orsmga007.jf.intel.com with ESMTP; 06 Apr 2018 13:57:57 -0700 Subject: [PATCH 00/11] [v5] Use global pages with PTI To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Dave Hansen , aarcange@redhat.com, luto@kernel.org, torvalds@linux-foundation.org, keescook@google.com, hughd@google.com, jgross@suse.com, x86@kernel.org, namit@vmware.com From: Dave Hansen Date: Fri, 06 Apr 2018 13:55:01 -0700 Message-Id: <20180406205501.24A1A4E7@viggo.jf.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Changes from v4 * Fix compile error reported by Tom Lendacky * Avoid setting _PAGE_GLOBAL on non-present entries Changes from v3: * Fix whitespace issue noticed by willy * Clarify comments about X86_FEATURE_PGE checks * Clarify commit message around the necessity of _PAGE_GLOBAL filtering when CR4.PGE=0 or PGE is unsupported. Changes from v2: * Add performance numbers to changelogs * Fix compile error resulting from use of x86-specific __default_kernel_pte_mask in arch-generic mm/early_ioremap.c * Delay kernel text cloning until after we are done messing with it (patch 11). * Blacklist K8 explicitly from mapping all kernel text as global (this should never happen because K8 does not use pti when pti=auto, but we on the safe side). (patch 11) -- The later versions of the KAISER patches (pre-PTI) allowed the user/kernel shared areas to be GLOBAL. The thought was that this would reduce the TLB overhead of keeping two copies of these mappings. During the switch over to PTI, we seem to have lost our ability to have GLOBAL mappings. This adds them back. To measure the benefits of this, I took a modern Atom system without PCIDs and ran a microbenchmark[1] (higher is better): No Global Lines (baseline ): 6077741 lseeks/sec 88 Global Lines (kern entry): 7528609 lseeks/sec (+23.9%) 94 Global Lines (all ktext ): 8433111 lseeks/sec (+38.8%) On a modern Skylake desktop with PCIDs, the benefits are tangible, but not huge: No Global pages (baseline): 15783951 lseeks/sec 28 Global pages (this set): 16054688 lseeks/sec +270737 lseeks/sec (+1.71%) I also double-checked with a kernel compile on the Skylake system (lower is better): No Global pages (baseline): 186.951 seconds time elapsed ( +- 0.35% ) 28 Global pages (this set): 185.756 seconds time elapsed ( +- 0.09% ) -1.195 seconds (-0.64%) 1. https://github.com/antonblanchard/will-it-scale/blob/master/tests/lseek1.c Cc: Andrea Arcangeli Cc: Andy Lutomirski Cc: Linus Torvalds Cc: Kees Cook Cc: Hugh Dickins Cc: Juergen Gross Cc: x86@kernel.org Cc: Nadav Amit