Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1907784imm; Sat, 23 Jun 2018 05:23:54 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI3+cGiXQ5oVpVED0Mu/HK6aFfFsK0pro1SwJYuylj9YpkvikdGgj8QNh+XM7RIAMUSoQgU X-Received: by 2002:a62:5991:: with SMTP id k17-v6mr5744658pfj.94.1529756634584; Sat, 23 Jun 2018 05:23:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529756634; cv=none; d=google.com; s=arc-20160816; b=inTV/L3DlvGaO7RlwPAAJ+2OJ6WKZeyX1xV1+xif2oYejpmp29FTqy8Zm5oZIg7sFT ARTwp0RggxaTzWSP9oYPPbFlCsaRhqhT9qnE/qffuXJoPhjOjdNzT1RNMAr1YgMzACDp dFrsQDKpf3OUpusuDkKDvpG2yw0p60ABFKzdyK1qmkV2EIf4G7dKb+m0BFNEsfzMPtZL 6I1Dcapsr8duj3nPDf4YDRtXVoETF87PZVFlR3ZNTEQnI7wqIr2z5h2bPWGFcJxod1D1 p6yPXtOhDCdtqH9wXXRmNZVWsS+ZzR0mu3woaieCeTaLeMqc25zvErlQdcvmnmVTUIRH Iyag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=Tu2q+Atz4SmKneUaoIdo5s5PcfxHkZEnR7THfdKtRUg=; b=A7qNmmbRC9KeDZmWFaGYH8ytTYOhP6tKleBSChE38bnuL7DvST1suSlauDBi8TqdfV LDZXppiN6HTiJ3USJNy6vK3RMA2H2suKRnGZ+Dig9OPbo9oCUNJhy+Kq0afJ2L4RQe1P xj+TANjZhN7dxKWz8WuopjTc5feJJzYx1tHzjxNs98I6oNtrrtMQ2zWqwweA7yyUZ5XZ fR2PbG5m/tescq2U5HfWQV6EBVTqm6n0HLhTr5FMQKoNS1XIsS4ccmMT0T9awCqVTcse uCpoAcws/BLtw7HZGFwwzh8MUyx4Ud2cpR8ok+NFZnO0xTssQqfpNyzc+W+LuT+0jDxO RxLQ== 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 cc1-v6si1665625plb.458.2018.06.23.05.23.40; Sat, 23 Jun 2018 05:23:54 -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 S1751959AbeFWMWQ (ORCPT + 99 others); Sat, 23 Jun 2018 08:22:16 -0400 Received: from terminus.zytor.com ([198.137.202.136]:49233 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751775AbeFWMWP (ORCPT ); Sat, 23 Jun 2018 08:22:15 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w5NCMBiq465387 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sat, 23 Jun 2018 05:22:11 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w5NCMAHV465384; Sat, 23 Jun 2018 05:22:10 -0700 Date: Sat, 23 Jun 2018 05:22:10 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Reinette Chatre Message-ID: Cc: mingo@kernel.org, hpa@zytor.com, reinette.chatre@intel.com, tglx@linutronix.de, linux-kernel@vger.kernel.org Reply-To: linux-kernel@vger.kernel.org, tglx@linutronix.de, reinette.chatre@intel.com, hpa@zytor.com, mingo@kernel.org In-Reply-To: <3eef559aa9fd693a104ff99ff909cfee450c1695.1529706536.git.reinette.chatre@intel.com> References: <3eef559aa9fd693a104ff99ff909cfee450c1695.1529706536.git.reinette.chatre@intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/cache] x86/intel_rdt: Discover supported platforms via prefetch disable bits Git-Commit-ID: f2a177292bd052ce12ac453d2ceeb083fe07718a X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: f2a177292bd052ce12ac453d2ceeb083fe07718a Gitweb: https://git.kernel.org/tip/f2a177292bd052ce12ac453d2ceeb083fe07718a Author: Reinette Chatre AuthorDate: Fri, 22 Jun 2018 15:42:20 -0700 Committer: Thomas Gleixner CommitDate: Sat, 23 Jun 2018 13:03:49 +0200 x86/intel_rdt: Discover supported platforms via prefetch disable bits Knowing the model specific prefetch disable bits is required to support cache pseudo-locking because the hardware prefetchers need to be disabled when the kernel memory is pseudo-locked to cache. We add these bits only for platforms known to support cache pseudo-locking. When the user requests locksetup mode to be entered it will fail if the prefetch disabling bits are not known for the platform. Signed-off-by: Reinette Chatre Signed-off-by: Thomas Gleixner Cc: fenghua.yu@intel.com Cc: tony.luck@intel.com Cc: vikas.shivappa@linux.intel.com Cc: gavin.hindman@intel.com Cc: jithu.joseph@intel.com Cc: dave.hansen@intel.com Cc: hpa@zytor.com Link: https://lkml.kernel.org/r/3eef559aa9fd693a104ff99ff909cfee450c1695.1529706536.git.reinette.chatre@intel.com --- arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c | 75 +++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c b/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c index b145a7386b10..cbba4bc17522 100644 --- a/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c +++ b/arch/x86/kernel/cpu/intel_rdt_pseudo_lock.c @@ -12,8 +12,73 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include +#include #include "intel_rdt.h" +/* + * MSR_MISC_FEATURE_CONTROL register enables the modification of hardware + * prefetcher state. Details about this register can be found in the MSR + * tables for specific platforms found in Intel's SDM. + */ +#define MSR_MISC_FEATURE_CONTROL 0x000001a4 + +/* + * The bits needed to disable hardware prefetching varies based on the + * platform. During initialization we will discover which bits to use. + */ +static u64 prefetch_disable_bits; + +/** + * get_prefetch_disable_bits - prefetch disable bits of supported platforms + * + * Capture the list of platforms that have been validated to support + * pseudo-locking. This includes testing to ensure pseudo-locked regions + * with low cache miss rates can be created under variety of load conditions + * as well as that these pseudo-locked regions can maintain their low cache + * miss rates under variety of load conditions for significant lengths of time. + * + * After a platform has been validated to support pseudo-locking its + * hardware prefetch disable bits are included here as they are documented + * in the SDM. + * + * Return: + * If platform is supported, the bits to disable hardware prefetchers, 0 + * if platform is not supported. + */ +static u64 get_prefetch_disable_bits(void) +{ + if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL || + boot_cpu_data.x86 != 6) + return 0; + + switch (boot_cpu_data.x86_model) { + case INTEL_FAM6_BROADWELL_X: + /* + * SDM defines bits of MSR_MISC_FEATURE_CONTROL register + * as: + * 0 L2 Hardware Prefetcher Disable (R/W) + * 1 L2 Adjacent Cache Line Prefetcher Disable (R/W) + * 2 DCU Hardware Prefetcher Disable (R/W) + * 3 DCU IP Prefetcher Disable (R/W) + * 63:4 Reserved + */ + return 0xF; + case INTEL_FAM6_ATOM_GOLDMONT: + case INTEL_FAM6_ATOM_GEMINI_LAKE: + /* + * SDM defines bits of MSR_MISC_FEATURE_CONTROL register + * as: + * 0 L2 Hardware Prefetcher Disable (R/W) + * 1 Reserved + * 2 DCU Hardware Prefetcher Disable (R/W) + * 63:3 Reserved + */ + return 0x5; + } + + return 0; +} + /** * pseudo_lock_init - Initialize a pseudo-lock region * @rdtgrp: resource group to which new pseudo-locked region will belong @@ -225,6 +290,16 @@ int rdtgroup_locksetup_enter(struct rdtgroup *rdtgrp) return -EINVAL; } + /* + * Not knowing the bits to disable prefetching implies that this + * platform does not support Cache Pseudo-Locking. + */ + prefetch_disable_bits = get_prefetch_disable_bits(); + if (prefetch_disable_bits == 0) { + rdt_last_cmd_puts("pseudo-locking not supported\n"); + return -EINVAL; + } + if (rdtgroup_monitor_in_progress(rdtgrp)) { rdt_last_cmd_puts("monitoring in progress\n"); return -EINVAL;