Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp126997imm; Tue, 19 Jun 2018 17:30:04 -0700 (PDT) X-Google-Smtp-Source: ADUXVKISGeVFbftfozCdux1sZVKuunW9SDriKn9vQ/sJlTDuEZe57dNyWyVszIP22kuoyF78RzIF X-Received: by 2002:a62:e816:: with SMTP id c22-v6mr20137165pfi.124.1529454604752; Tue, 19 Jun 2018 17:30:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529454604; cv=none; d=google.com; s=arc-20160816; b=ll79yVOTPYnCHjLrKLmuUg6r60iDtU4Q8eYYSCKyJ1FLBcKzk3hkrmHE+6NRCIslyO vrdofFO/IRxm8U3Biui35Dvk4XPhQSqCGbo/Ne4bgar+JPpvRq3nVqQZ2VRNFNsY4N57 lwvtX+a0pEiIBiC+oGmMFxjuymvxHbUewaWFa5zusRW0eyljV4IU70QZfW/E/7qap0Rf SekKHdxmiXB8juqunNDD39oW31sgkZeFMhs5rDd6229H2DBhDqsP6ZYMk8TE17RA5Wh+ LUQ75r4pKo9B54+LMyEzR3Mrj7/60R8yIwDBUkYuPR5aw4LjS0oYrnHI4py9AsKRU5Si Yl2A== 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=X1uFH6dNWKz9CkT9Hs9KjR3uH6b4iW9+Yk5gYCYubsM=; b=XeB2USZXnm2A7uolaT8xusB2BnIoLdBG6Vm/r7Km0+ABtpz3vrV4fS/w/PGUhJGyJr aduXBg9Z0aum97ByIz1upBXjNk0MCgimQInrdsAlOXYqjf1VTvSFXkz6/VK/9oHZ13nh vRgvmCy+mkL6x3jsnknoEeFNJ63hu4trk4uRWWhwp9ILsHlFSQOd85S7bZtWK4a/XwZI GBKfI5XyC6q8yANcsZB7ZB6Z1nI8AVtkO0oDhtn0/QyJZLSG1Ezj4NRYJk6y6NsytIYS +1qKTXmihMJgCcZzoEWX2nG8dp7HgdiUCzO6XPBeHOukBBZEhD8OdeJffZG+36pb2XO3 b9Zg== 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 v127-v6si809079pgv.212.2018.06.19.17.29.50; Tue, 19 Jun 2018 17:30:04 -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 S1754166AbeFTA2F (ORCPT + 99 others); Tue, 19 Jun 2018 20:28:05 -0400 Received: from terminus.zytor.com ([198.137.202.136]:33295 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753073AbeFTA2D (ORCPT ); Tue, 19 Jun 2018 20:28:03 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w5K0Rwef3299819 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 19 Jun 2018 17:27:58 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w5K0Rueo3299816; Tue, 19 Jun 2018 17:27:56 -0700 Date: Tue, 19 Jun 2018 17:27:56 -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: tglx@linutronix.de, reinette.chatre@intel.com, mingo@kernel.org, hpa@zytor.com, linux-kernel@vger.kernel.org Reply-To: tglx@linutronix.de, reinette.chatre@intel.com, linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@kernel.org In-Reply-To: References: To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/cache] x86/intel_rdt: Discover supported platforms via prefetch disable bits Git-Commit-ID: 48d2a87ab29b2f2275aa5af9effe2fef5116dfc0 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, T_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: 48d2a87ab29b2f2275aa5af9effe2fef5116dfc0 Gitweb: https://git.kernel.org/tip/48d2a87ab29b2f2275aa5af9effe2fef5116dfc0 Author: Reinette Chatre AuthorDate: Tue, 29 May 2018 05:57:53 -0700 Committer: Thomas Gleixner CommitDate: Wed, 20 Jun 2018 00:56:37 +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/a87d0ae287964753841c6cc628715a05be6c0e7a.1527593971.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;