Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp118244imm; Tue, 19 Jun 2018 17:16:42 -0700 (PDT) X-Google-Smtp-Source: ADUXVKISNoSBKUdiDcImzusWmMYHrsGBxzMoWXJY251cLyV9HngLYWZF0GanrY2YMHsMaYffwwiP X-Received: by 2002:a62:1411:: with SMTP id 17-v6mr20330422pfu.3.1529453802484; Tue, 19 Jun 2018 17:16:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529453802; cv=none; d=google.com; s=arc-20160816; b=M8hds6KBTJEPoW9i5kSgeqs//qUVk3Q3tIsJdkl8gXkm7C0yUF/TjpMLIjESOvwyYk WcBsvqCZgGOwO68bZXObyyWm8nw50vtr70v9IxhIaLcRG06jkLRsA6E/ERHRB57eTqXf 2kqTuz09yMmlqAAXQHYzJKn9oGAyLdeUX7kTTpGnf3l6seYec0DlYApzECoOtCmzZN+D PqhAdf+cZAnzqXUc1YcSIlTzJgswMJR7c+lGi7/QvYiZGun2Km2p8uG15YEdrpCDP7pA 96JdRJ0Wx8rUKqCRh6QK3wzAw3dJboc5YkHZgwV5YhcoqQD4KUZPk6dZKNbR//WKlzS3 smEQ== 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=DAT1EBR2K6qcYhByfKKPvfpXyKrsUmg4WR3TXaGBSKQ=; b=piCGytvGn26Ar7aDF6vozW0l2wUIwk9VEbdvA69JixfGLNpLGYspqataTkeA/PUTNX ch/1meq+WL4dAp/osHTtGmNUnV/jlPPfFBaR1r/7rIJPB0iEkMhkX3SYBixx+RYEezmh cOurhCxV82P6o0MDeHWLm9dP3Lk04pIf/cmTPt5K/uy9wcowu9M7RM4EGd/13WLLs1vZ I9jUmVbXlnPNOEQuntBnzcLYcHVv62kazF656nYEjlQ5exn2hpf4ISe0R1Eo01HEDPw/ +DPSJdblLxcA5wq1M5lD/nEaslMpRLvElHaL3qIq4Sipb4FGNRppU8c+YJJNuO7D93+m keCg== 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 bd1-v6si957608plb.338.2018.06.19.17.16.28; Tue, 19 Jun 2018 17:16:42 -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 S1754077AbeFTAOr (ORCPT + 99 others); Tue, 19 Jun 2018 20:14:47 -0400 Received: from terminus.zytor.com ([198.137.202.136]:52371 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750949AbeFTAOp (ORCPT ); Tue, 19 Jun 2018 20:14:45 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w5K0EeXQ3296308 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 19 Jun 2018 17:14:40 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w5K0Eekk3296305; Tue, 19 Jun 2018 17:14:40 -0700 Date: Tue, 19 Jun 2018 17:14:40 -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, reinette.chatre@intel.com, mingo@kernel.org, hpa@zytor.com Reply-To: hpa@zytor.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, reinette.chatre@intel.com, mingo@kernel.org In-Reply-To: <902574465439924850a6e7c4cc06b8a79bd7d2b4.1527593970.git.reinette.chatre@intel.com> References: <902574465439924850a6e7c4cc06b8a79bd7d2b4.1527593970.git.reinette.chatre@intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/cache] x86/intel_rdt: Introduce resource group's mode resctrl file Git-Commit-ID: 417d29b4daa1a7c9f5fc4f0e8205ea7dbc967054 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: 417d29b4daa1a7c9f5fc4f0e8205ea7dbc967054 Gitweb: https://git.kernel.org/tip/417d29b4daa1a7c9f5fc4f0e8205ea7dbc967054 Author: Reinette Chatre AuthorDate: Tue, 29 May 2018 05:57:29 -0700 Committer: Thomas Gleixner CommitDate: Wed, 20 Jun 2018 00:56:28 +0200 x86/intel_rdt: Introduce resource group's mode resctrl file A new resctrl file "mode" associated with each resource group is introduced. This file will display the resource group's current mode and an administrator can also use it to modify the resource group's mode. Only shareable mode is currently supported. 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/902574465439924850a6e7c4cc06b8a79bd7d2b4.1527593970.git.reinette.chatre@intel.com --- arch/x86/kernel/cpu/intel_rdt_rdtgroup.c | 83 ++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c index 70d7846041fe..eac60602c87b 100644 --- a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c +++ b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c @@ -147,6 +147,24 @@ enum rdtgrp_mode rdtgroup_mode_by_closid(int closid) return RDT_NUM_MODES; } +static const char * const rdt_mode_str[] = { + [RDT_MODE_SHAREABLE] = "shareable", +}; + +/** + * rdtgroup_mode_str - Return the string representation of mode + * @mode: the resource group mode as &enum rdtgroup_mode + * + * Return: string representation of valid mode, "unknown" otherwise + */ +static const char *rdtgroup_mode_str(enum rdtgrp_mode mode) +{ + if (mode < RDT_MODE_SHAREABLE || mode >= RDT_NUM_MODES) + return "unknown"; + + return rdt_mode_str[mode]; +} + /* set uid and gid of rdtgroup dirs and files to that of the creator */ static int rdtgroup_kn_set_ugid(struct kernfs_node *kn) { @@ -761,6 +779,63 @@ static ssize_t max_threshold_occ_write(struct kernfs_open_file *of, return nbytes; } +/* + * rdtgroup_mode_show - Display mode of this resource group + */ +static int rdtgroup_mode_show(struct kernfs_open_file *of, + struct seq_file *s, void *v) +{ + struct rdtgroup *rdtgrp; + + rdtgrp = rdtgroup_kn_lock_live(of->kn); + if (!rdtgrp) { + rdtgroup_kn_unlock(of->kn); + return -ENOENT; + } + + seq_printf(s, "%s\n", rdtgroup_mode_str(rdtgrp->mode)); + + rdtgroup_kn_unlock(of->kn); + return 0; +} + +static ssize_t rdtgroup_mode_write(struct kernfs_open_file *of, + char *buf, size_t nbytes, loff_t off) +{ + struct rdtgroup *rdtgrp; + enum rdtgrp_mode mode; + int ret = 0; + + /* Valid input requires a trailing newline */ + if (nbytes == 0 || buf[nbytes - 1] != '\n') + return -EINVAL; + buf[nbytes - 1] = '\0'; + + rdtgrp = rdtgroup_kn_lock_live(of->kn); + if (!rdtgrp) { + rdtgroup_kn_unlock(of->kn); + return -ENOENT; + } + + rdt_last_cmd_clear(); + + mode = rdtgrp->mode; + + if ((!strcmp(buf, "shareable") && mode == RDT_MODE_SHAREABLE)) + goto out; + + if (!strcmp(buf, "shareable")) { + rdtgrp->mode = RDT_MODE_SHAREABLE; + } else { + rdt_last_cmd_printf("unknown/unsupported mode\n"); + ret = -EINVAL; + } + +out: + rdtgroup_kn_unlock(of->kn); + return ret ?: nbytes; +} + /* rdtgroup information files for one cache resource. */ static struct rftype res_common_files[] = { { @@ -874,6 +949,14 @@ static struct rftype res_common_files[] = { .seq_show = rdtgroup_schemata_show, .fflags = RF_CTRL_BASE, }, + { + .name = "mode", + .mode = 0644, + .kf_ops = &rdtgroup_kf_single_ops, + .write = rdtgroup_mode_write, + .seq_show = rdtgroup_mode_show, + .fflags = RF_CTRL_BASE, + }, }; static int rdtgroup_add_files(struct kernfs_node *kn, unsigned long fflags)