Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2902656ybt; Mon, 22 Jun 2020 09:48:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsthe4bVLnzscMhUJUArb53SsG6CxvNuJXE92Ja7Fkq8ynNFeiLBBPAT6V8geCfBay9bUs X-Received: by 2002:aa7:dc57:: with SMTP id g23mr17152906edu.352.1592844509709; Mon, 22 Jun 2020 09:48:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592844509; cv=none; d=google.com; s=arc-20160816; b=Cc/iOEGS8+t9/0gxCTX/sYoM4N5lcmLiu6jnX3YMBve6NkLMjledgwtP9xIum9Yl/1 TxJS5iBvh8+mEjhPLWlI0QXgdNdR/YKOfB8OO3yMLNDxlRztTRC4xUs/kH+LDBGbxWsL T8+OV6idwT3eWPDMr+TcNJzHA6YehhyCL4p3+L+GpwwH+fIE9qpzOuxWXAddzAfosaAD b2yo32+ULjrFmfjOhzHUTc4PfyBAVjgkYpkhomgtTj3sErw0SGhTg9LcRL4/27KnHawf pNcHQIrRmmHmP3ozWXg6n2M6wDZtLYlaosj2Ng05F24jmEXZFC4VruOnh8ApsMAlvC4C zLqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=7MWEk/DiWjzG0dMfOUj6HnZkiBMF3Y44zvKkniL9Id4=; b=F2TwsmcmyXk3+IrrE9xupfEjD5/Of+GlyDz8UmzHI59tYVxl8WURJmkpORePNhJDed a9oDmuDM/cTsNnQGcv1EdCqTaN+YtBoCII9HMDCSLVpqSPY5gK8JwRl7bw1ag80x/iCh zuMwlRbYKmvWvnQ0yFrANW7H20wFnbDqh7LKTscX1ZMvXlE0dnVm0ktp9bS39aQ02gsP Cb6CxoWP5AWaDeluLXQe86g+DwV8c+5ifA/8aHozvWtQ0GrT4w3GpwBZ+jkLx/kSbXzC 5lc5ZmNfoQmx+OkE0vhUVcApMHTS4WVfIw9USvmPhyiChLIfXNN2ZTJ/yOOhO8WjU9zR h+NQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n9si9720446ejz.644.2020.06.22.09.48.06; Mon, 22 Jun 2020 09:48:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729883AbgFVQoJ (ORCPT + 99 others); Mon, 22 Jun 2020 12:44:09 -0400 Received: from mga03.intel.com ([134.134.136.65]:18797 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729637AbgFVQoH (ORCPT ); Mon, 22 Jun 2020 12:44:07 -0400 IronPort-SDR: JOHL0IQ6VdiF8Ks3cOlO1dN5J1PCZFmCkHnyHngDZUgSciUa8uSGNFLOn8/WsfLxDhLjS0WGYt LXazEz6Y2dyA== X-IronPort-AV: E=McAfee;i="6000,8403,9660"; a="143772328" X-IronPort-AV: E=Sophos;i="5.75,267,1589266800"; d="scan'208";a="143772328" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2020 09:44:05 -0700 IronPort-SDR: DPTTckPgdmP9Z7Wk5omOzScbR7+5SkxnXl1kMP3OD6ujkZuHya8EP0Yqjc1zOvq62vFPwUR25K UmaIQpyPKMUQ== X-IronPort-AV: E=Sophos;i="5.75,267,1589266800"; d="scan'208";a="281020611" Received: from rchatre-mobl1.jf.intel.com ([10.54.70.7]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2020 09:44:05 -0700 From: Reinette Chatre To: tglx@linutronix.de, fenghua.yu@intel.com, bp@alien8.de, tony.luck@intel.com Cc: kuo-lang.tseng@intel.com, ravi.v.shankar@intel.com, mingo@redhat.com, babu.moger@amd.com, hpa@zytor.com, x86@kernel.org, linux-kernel@vger.kernel.org, Reinette Chatre Subject: [PATCH V7 3/4] x86/resctrl: Enable per-thread MBA Date: Mon, 22 Jun 2020 09:43:30 -0700 Message-Id: <7524dba387939bd388651d7385ac14d3d438fbb3.1592841671.git.reinette.chatre@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fenghua Yu Current Memory Bandwidth Allocation (MBA) hardware has a limitation: all threads on the same core must have the same delay value. If there are different delay values across threads on one core, the original MBA implementation allocates the max delay value to the core and an updated implementation allocates either min or max delay value specified by a configuration MSR across threads on the core. Newer systems support per-thread MBA such that each thread is allocated with its own delay value. If per-thread MBA is supported, report "per-thread" in resctrl file "info/MB/thread_throttle_mode" to let user applications know memory bandwidth is allocated per thread and help them fine tune MBA on thread level. Signed-off-by: Fenghua Yu [reinette: transition patch to use membw_throttle_mode enum] Signed-off-by: Reinette Chatre Reviewed-by: Babu Moger --- No changes since V6 Documentation/x86/resctrl_ui.rst | 3 +++ arch/x86/kernel/cpu/resctrl/core.c | 5 ++++- arch/x86/kernel/cpu/resctrl/internal.h | 2 ++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 11 +++++++++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Documentation/x86/resctrl_ui.rst b/Documentation/x86/resctrl_ui.rst index 861ee2816470..1b066d1aafad 100644 --- a/Documentation/x86/resctrl_ui.rst +++ b/Documentation/x86/resctrl_ui.rst @@ -150,6 +150,9 @@ with respect to allocation: "max": the smallest percentage is applied to all threads + "per-thread": + bandwidth percentages are directly applied to + the threads running on the core If RDT monitoring is available there will be an "L3_MON" directory with the following files: diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c index 687221cae5c3..716ad71edf80 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -304,7 +304,10 @@ static bool __get_mem_config_intel(struct rdt_resource *r) } r->data_width = 3; - if (mba_cfg_supports_min_max_intel()) { + if (boot_cpu_has(X86_FEATURE_PER_THREAD_MBA)) { + r->membw.arch_throttle_mode = THREAD_THROTTLE_PER_THREAD; + thread_throttle_mode_init_ro(); + } else if (mba_cfg_supports_min_max_intel()) { r->membw.arch_throttle_mode = THREAD_THROTTLE_MIN_MAX; thread_throttle_mode_init_rw(); } else { diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h index 6b9b21d67c9b..e198ea2a8468 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -391,11 +391,13 @@ struct rdt_cache { * @THREAD_THROTTLE_MAX_ONLY: Memory bandwidth is throttled at the core * always using smallest bandwidth percentage * assigned to threads, aka "max throttling" + * @THREAD_THROTTLE_PER_THREAD: Memory bandwidth is throttled at the thread */ enum membw_throttle_mode { THREAD_THROTTLE_UNDEFINED = 0, THREAD_THROTTLE_MIN_MAX, THREAD_THROTTLE_MAX_ONLY, + THREAD_THROTTLE_PER_THREAD, }; /** diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index 3f9d03f72005..25c7379ddb0b 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1038,6 +1038,11 @@ static int max_threshold_occ_show(struct kernfs_open_file *of, * with the maximum delay value that from the software interface will be * the minimum of the bandwidth percentages assigned to the hardware threads * sharing the core. + * + * Some systems (identified by X86_FEATURE_PER_THREAD_MBA enumerated via CPUID) + * support per-thread MBA. On these systems hardware doesn't apply the minimum + * or maximum delay value to all threads in a core. Instead, a thread is + * allocated with the delay value that is assigned to the thread. */ static int rdt_thread_throttle_mode_show(struct kernfs_open_file *of, struct seq_file *seq, void *v) @@ -1047,12 +1052,18 @@ static int rdt_thread_throttle_mode_show(struct kernfs_open_file *of, mutex_lock(&rdtgroup_mutex); + if (r->membw.arch_throttle_mode == THREAD_THROTTLE_PER_THREAD) { + seq_puts(seq, "per-thread\n"); + goto out; + } + if (r->membw.arch_throttle_mode == THREAD_THROTTLE_MIN_MAX) throttle_mode = mba_cfg_msr & MBA_THROTTLE_MODE_MASK; seq_puts(seq, throttle_mode == MBA_THROTTLE_MODE_MIN ? "min\n" : "max\n"); +out: mutex_unlock(&rdtgroup_mutex); return 0; } -- 2.26.2