Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp121906imm; Tue, 19 Jun 2018 17:21:50 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKfx19+MHdVJ/lbF7iIwAhzg8xgUKbOwEUIntf+jtFEM+9M7r82UbkTMB6YObgdZOdB6FKT X-Received: by 2002:a65:60d2:: with SMTP id r18-v6mr16876563pgv.306.1529454110162; Tue, 19 Jun 2018 17:21:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529454110; cv=none; d=google.com; s=arc-20160816; b=OgwrRC0k8CfSVnVYAH4LhZ1Szs7g2ubYiTgUnmh62MgzfL9hx2ANHnTGkEX6JchLhd d93GGvyk+1akl7VHCg1WFI8iUh40233gww4BjmYLZ1s9XI2Xql9oG6ZGvh2Bk+8Niikl vCDQRkz/U3rBC+st/SfOycQKpaYAIOODa7ItR6xGOywFFFQZH263uyXdXVLkqqXKhCQy PrWvW/s+nsI0eyS4GxWy9bVCAWg3d1S8PaC00enS/PdbWalkIixkw79oqoRcTDQi7OCN n3ckDN12HlchWRz/ngZfXaRtcVwz0TquxGvrrYXUY7QLC8ZKpfTlvA9F4EktyJUclVDl NB8A== 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=1tCWZWwyBHq7+NLrg4sfLOfqez+/32jaghjbIjqRius=; b=fT+Cic63EPsPpuiz03W8qT882Mf0ha0cE10MaZYCNxRaYCfC8OnXhS/R8P61pwdgIB kvSUlpWxqnTbbR34XlfwTyXjKESkDbrj+6Uzqwb3IuD2f1LNNv2sBRq3/QsqB44nAQor q12M+d98jW9AjlR4NtSDGqUEUaNc1xSv2u78QPqEK1VoE9rT7ElWGka2xRUxJ8Jn/xa6 1OAJvArnt6Yax/ZeLvwIKdMqjIWBtVvNU1HXbsNIRVczp7mx0KbYWtaIgh24Tx+pFhOW brm+3FtXf/ZOUwsIg9Al5J/J236QnGB+k/VaD692/e3Zv30qaDMmkxkeoPI7xdHIz1Zn rJ3w== 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 i1-v6si924343plt.183.2018.06.19.17.21.36; Tue, 19 Jun 2018 17:21:50 -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 S1754198AbeFTATi (ORCPT + 99 others); Tue, 19 Jun 2018 20:19:38 -0400 Received: from terminus.zytor.com ([198.137.202.136]:32927 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751955AbeFTATe (ORCPT ); Tue, 19 Jun 2018 20:19:34 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w5K0JTqi3297109 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 19 Jun 2018 17:19:29 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w5K0JTAl3297106; Tue, 19 Jun 2018 17:19:29 -0700 Date: Tue, 19 Jun 2018 17:19:29 -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: linux-kernel@vger.kernel.org, tglx@linutronix.de, mingo@kernel.org, reinette.chatre@intel.com, hpa@zytor.com Reply-To: reinette.chatre@intel.com, mingo@kernel.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, hpa@zytor.com In-Reply-To: <0108de9c39225ff2e8359115f9283c4e410510de.1527593970.git.reinette.chatre@intel.com> References: <0108de9c39225ff2e8359115f9283c4e410510de.1527593970.git.reinette.chatre@intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/cache] x86/intel_rdt: Introduce "bit_usage" to display cache allocations details Git-Commit-ID: 0a1ad189dfd4680e7c05273f43d39623b6bc4c66 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: 0a1ad189dfd4680e7c05273f43d39623b6bc4c66 Gitweb: https://git.kernel.org/tip/0a1ad189dfd4680e7c05273f43d39623b6bc4c66 Author: Reinette Chatre AuthorDate: Tue, 29 May 2018 05:57:38 -0700 Committer: Thomas Gleixner CommitDate: Wed, 20 Jun 2018 00:56:31 +0200 x86/intel_rdt: Introduce "bit_usage" to display cache allocations details With cache regions now explicitly marked as "shareable" or "exclusive" we would like to communicate to the user how portions of the cache are used. Introduce "bit_usage" that indicates for each resource how portions of the cache are configured to be used. To assist the user to distinguish whether the sharing is from software or hardware we add the following annotation: 0 - currently unused X - currently available for sharing and used by software and hardware H - currently used by hardware only but available for software use S - currently used and shareable by software only E - currently used exclusively by one resource group 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/0108de9c39225ff2e8359115f9283c4e410510de.1527593970.git.reinette.chatre@intel.com --- arch/x86/kernel/cpu/intel_rdt_rdtgroup.c | 79 ++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c index 4574bb1cbd94..833bfce9146c 100644 --- a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c +++ b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c @@ -714,6 +714,78 @@ static int rdt_shareable_bits_show(struct kernfs_open_file *of, return 0; } +/** + * rdt_bit_usage_show - Display current usage of resources + * + * A domain is a shared resource that can now be allocated differently. Here + * we display the current regions of the domain as an annotated bitmask. + * For each domain of this resource its allocation bitmask + * is annotated as below to indicate the current usage of the corresponding bit: + * 0 - currently unused + * X - currently available for sharing and used by software and hardware + * H - currently used by hardware only but available for software use + * S - currently used and shareable by software only + * E - currently used exclusively by one resource group + */ +static int rdt_bit_usage_show(struct kernfs_open_file *of, + struct seq_file *seq, void *v) +{ + struct rdt_resource *r = of->kn->parent->priv; + u32 sw_shareable, hw_shareable, exclusive; + struct rdt_domain *dom; + int i, hwb, swb, excl; + enum rdtgrp_mode mode; + bool sep = false; + u32 *ctrl; + + mutex_lock(&rdtgroup_mutex); + hw_shareable = r->cache.shareable_bits; + list_for_each_entry(dom, &r->domains, list) { + if (sep) + seq_putc(seq, ';'); + ctrl = dom->ctrl_val; + sw_shareable = 0; + exclusive = 0; + seq_printf(seq, "%d=", dom->id); + for (i = 0; i < r->num_closid; i++, ctrl++) { + if (!closid_allocated(i)) + continue; + mode = rdtgroup_mode_by_closid(i); + switch (mode) { + case RDT_MODE_SHAREABLE: + sw_shareable |= *ctrl; + break; + case RDT_MODE_EXCLUSIVE: + exclusive |= *ctrl; + break; + case RDT_NUM_MODES: + WARN(1, + "invalid mode for closid %d\n", i); + break; + } + } + for (i = r->cache.cbm_len - 1; i >= 0; i--) { + hwb = test_bit(i, (unsigned long *)&hw_shareable); + swb = test_bit(i, (unsigned long *)&sw_shareable); + excl = test_bit(i, (unsigned long *)&exclusive); + if (hwb && swb) + seq_putc(seq, 'X'); + else if (hwb && !swb) + seq_putc(seq, 'H'); + else if (!hwb && swb) + seq_putc(seq, 'S'); + else if (excl) + seq_putc(seq, 'E'); + else /* Unused bits remain */ + seq_putc(seq, '0'); + } + sep = true; + } + seq_putc(seq, '\n'); + mutex_unlock(&rdtgroup_mutex); + return 0; +} + static int rdt_min_bw_show(struct kernfs_open_file *of, struct seq_file *seq, void *v) { @@ -995,6 +1067,13 @@ static struct rftype res_common_files[] = { .seq_show = rdt_shareable_bits_show, .fflags = RF_CTRL_INFO | RFTYPE_RES_CACHE, }, + { + .name = "bit_usage", + .mode = 0444, + .kf_ops = &rdtgroup_kf_single_ops, + .seq_show = rdt_bit_usage_show, + .fflags = RF_CTRL_INFO | RFTYPE_RES_CACHE, + }, { .name = "min_bandwidth", .mode = 0444,