Received: by 10.192.165.148 with SMTP id m20csp774228imm; Fri, 20 Apr 2018 15:46:54 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+UM83W169lFt5pX9CKxeDmYwPBvS0X625f0toOc7nAzqfDE2RFEuIkua9eS35pZN31Pn52 X-Received: by 10.98.75.89 with SMTP id y86mr11337446pfa.140.1524264414083; Fri, 20 Apr 2018 15:46:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524264414; cv=none; d=google.com; s=arc-20160816; b=fiBwMOQp0Tpi8S3IMF8Xp4rM7/H3cOa5buVx/6vwfvbTsGSlotaM3eo7panDUl4/k2 hoIU89+EnM5So/SCsDZ8vkiVd3d1K1WAiTGL4JFKdKig076ZvSmOrJOBxUKfbpxsyWRm fW4PgxSKFyx45978zG7XUrZ5fHjcfrUEdnkyDJm8DBGPDzvzF+Zrp/sFKWxWNrAXV1hR c1WMY5V4SgtvMMvJad4m7I48D992g+2fVOzUJVb2InURJgy98UHWT2lB1n1denESLx1p 7oBfdLqNNkfaFgbBR4ujEjnid2QINBNc0C19aQy6UpHS+VJzB6Yz8Rj7bNg9f0l120dQ C+JQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=FdiCre1BmDeUauWffIt6Qz7hBR259le67u/C//QHKy8=; b=Pv4Tj9WAP90h5rXgLNe+u7Osib72g2aFifbjK8unAlIhXkaNt7pCtIx8tbvmdgE8cN Y1tZrtjcWeVYhF03FPvXOioF40mAOn6LDqfd8wuvgIYfMUeBaop0Yqa++M/P6koBvi+T Z19zIt0Ld94nRAP7x4x6DXjNipq0e/fsB8xxjJdwIvYhZyRdzjxWS4Yx20UrupSPch8i d4acIlYh0G1TxqUyN786QYwlokAXrRN7vDLEt0WL6LlKFzM64yF55bNefD9ScdR2m7Gd b3rb+yovacmQ1jSzP4f8s89umGTY0uK7bpmBs/hZ3rFhRbaXXVcqxcaTXh1yHie47YCS yMyQ== 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 m6-v6si6544812plt.54.2018.04.20.15.46.16; Fri, 20 Apr 2018 15:46: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 S1753280AbeDTWk0 (ORCPT + 99 others); Fri, 20 Apr 2018 18:40:26 -0400 Received: from mga01.intel.com ([192.55.52.88]:60382 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752881AbeDTWjJ (ORCPT ); Fri, 20 Apr 2018 18:39:09 -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 fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Apr 2018 15:39:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,303,1520924400"; d="scan'208";a="34982634" Received: from vshiva-udesk.sc.intel.com ([10.3.52.52]) by orsmga007.jf.intel.com with ESMTP; 20 Apr 2018 15:39:08 -0700 From: Vikas Shivappa To: vikas.shivappa@intel.com, tony.luck@intel.com, ravi.v.shankar@intel.com, fenghua.yu@intel.com, x86@kernel.org, tglx@linutronix.de, hpa@zytor.com Cc: linux-kernel@vger.kernel.org, ak@linux.intel.com, vikas.shivappa@linux.intel.com Subject: [PATCH 2/6] x86/intel_rdt/mba_sc: Enable/disable MBA software controller Date: Fri, 20 Apr 2018 15:36:17 -0700 Message-Id: <1524263781-14267-3-git-send-email-vikas.shivappa@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1524263781-14267-1-git-send-email-vikas.shivappa@linux.intel.com> References: <1524263781-14267-1-git-send-email-vikas.shivappa@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently user does memory bandwidth allocation(MBA) by specifying the bandwidth in percentage via the resctrl schemata file: "/sys/fs/resctrl/schemata" Add a new mount option "mba_MBps" to enable the user to specify MBA in MBps: $mount -t resctrl resctrl [-o cdp[,cdpl2][mba_MBps]] /sys/fs/resctrl Signed-off-by: Vikas Shivappa --- arch/x86/kernel/cpu/intel_rdt.c | 8 ++++++++ arch/x86/kernel/cpu/intel_rdt.h | 3 +++ arch/x86/kernel/cpu/intel_rdt_rdtgroup.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/arch/x86/kernel/cpu/intel_rdt.c b/arch/x86/kernel/cpu/intel_rdt.c index 2b65601..2a0931f 100644 --- a/arch/x86/kernel/cpu/intel_rdt.c +++ b/arch/x86/kernel/cpu/intel_rdt.c @@ -230,6 +230,14 @@ static inline void cache_alloc_hsw_probe(void) rdt_alloc_capable = true; } +bool is_mba_sc(struct rdt_resource *r) +{ + if (!r) + return rdt_resources_all[RDT_RESOURCE_MBA].membw.mba_sc; + + return r->membw.mba_sc; +} + /* * rdt_get_mb_table() - get a mapping of bandwidth(b/w) percentage values * exposed to user interface and the h/w understandable delay values. diff --git a/arch/x86/kernel/cpu/intel_rdt.h b/arch/x86/kernel/cpu/intel_rdt.h index 3fd7a70..74aee0f 100644 --- a/arch/x86/kernel/cpu/intel_rdt.h +++ b/arch/x86/kernel/cpu/intel_rdt.h @@ -259,6 +259,7 @@ struct rdt_cache { * @min_bw: Minimum memory bandwidth percentage user can request * @bw_gran: Granularity at which the memory bandwidth is allocated * @delay_linear: True if memory B/W delay is in linear scale + * @mba_sc: True if MBA software controller(mba_sc) is enabled * @mb_map: Mapping of memory B/W percentage to memory B/W delay */ struct rdt_membw { @@ -266,6 +267,7 @@ struct rdt_membw { u32 min_bw; u32 bw_gran; u32 delay_linear; + bool mba_sc; u32 *mb_map; }; @@ -445,6 +447,7 @@ void mon_event_read(struct rmid_read *rr, struct rdt_domain *d, void mbm_setup_overflow_handler(struct rdt_domain *dom, unsigned long delay_ms); void mbm_handle_overflow(struct work_struct *work); +bool is_mba_sc(struct rdt_resource *r); void cqm_setup_limbo_handler(struct rdt_domain *dom, unsigned long delay_ms); void cqm_handle_limbo(struct work_struct *work); bool has_busy_rmid(struct rdt_resource *r, struct rdt_domain *d); diff --git a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c index fca759d..b9ceb13 100644 --- a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c +++ b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c @@ -1005,6 +1005,11 @@ static void l2_qos_cfg_update(void *arg) wrmsrl(IA32_L2_QOS_CFG, *enable ? L2_QOS_CDP_ENABLE : 0ULL); } +static inline bool is_mba_linear(void) +{ + return rdt_resources_all[RDT_RESOURCE_MBA].membw.delay_linear; +} + static int set_cache_qos_cfg(int level, bool enable) { void (*update)(void *arg); @@ -1041,6 +1046,25 @@ static int set_cache_qos_cfg(int level, bool enable) return 0; } +/* + * Enable or disable the MBA software controller + * which helps user specify bandwidth in MBps. + * MBA software controller is supported only if + * MBM is supported and MBA is in linear scale. + */ +static int set_mba_sc(bool mba_sc) +{ + struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_MBA]; + + if (!is_mbm_enabled() || !is_mba_linear() || + mba_sc == is_mba_sc(r)) + return -1; + + r->membw.mba_sc = mba_sc; + + return 0; +} + static int cdp_enable(int level, int data_type, int code_type) { struct rdt_resource *r_ldata = &rdt_resources_all[data_type]; @@ -1123,6 +1147,10 @@ static int parse_rdtgroupfs_options(char *data) ret = cdpl2_enable(); if (ret) goto out; + } else if (!strcmp(token, "mba_MBps")) { + ret = set_mba_sc(true); + if (ret) + goto out; } else { ret = -EINVAL; goto out; @@ -1445,6 +1473,8 @@ static void rdt_kill_sb(struct super_block *sb) cpus_read_lock(); mutex_lock(&rdtgroup_mutex); + set_mba_sc(false); + /*Put everything back to default values. */ for_each_alloc_enabled_rdt_resource(r) reset_all_ctrls(r); -- 1.9.1