Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3807089imm; Tue, 29 May 2018 14:10:45 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIEZQAxJcevAbzE3UpAAd0QjamBWqi5mQlOZ7FNNVYvuzywTPF/HmzPKleIb1SKxw26GQSu X-Received: by 2002:a17:902:b7c4:: with SMTP id v4-v6mr60729plz.188.1527628245935; Tue, 29 May 2018 14:10:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527628245; cv=none; d=google.com; s=arc-20160816; b=Fx5ALJ+ypwykyGpevcP8k5aLDUwjm7Yq+3/ErayE6UtErsMKosg1rYqd1udDxkHwcg bxQoPqmF0zTI1BdaExirFg4rhhvmSSGzIWzKWRF2bjAo8JuqMTk8e213btH7Djh7sD4a WNthRYHOf+39jbRWtQafzTGT8e66VSrXenFFNtgTAR/yXChqWMn7bE/Y6LAMOLIsdrs1 2AbUmGDlujeQc0UOvcoec7pgJupRKnY2VykN35Bd/9HtPQHqsfZYZ6FoGRPiupkRPhvF 7KWR8fZeNkkOFh4vQSzy2QHWL03a44WK8+Rja2Q/MPsYCwW55jCoQFvzOiDzLhG31O4e WsPQ== 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:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=TRh1VEQ2oRBOp4WvjFgTO8JOzVP3oa8uJLpLiv/9Ih8=; b=Q8BYshAevS5bwu//+uGtL37siTxqyvWxVCgRMi4UNXwKE4eK1mlRDOXYSuajzSQcWb QMuAxxGvbB0bzJY6jHExiiWyfU3og9BctYAwf+h6s2fSpRYMY2bpppcTKuAB++xP8qW2 c91nwVTXDdHcYdigitsbz+Pud2oh2/iDiiOwSysOyhyuwI7hL4Sc38AIejD1b63Mttx7 UjCGSf0MwgdKvt64u3SdJch46Iy10KbWboMpNgvFb77fAoSdFRle6CN1wZ5iQjKA0IEQ +CbIUm1Pz5vE1oR42XYjQAZ5BTMlWz+TzZYsGBfONhLVyoPfp1C71ehylIaQzrKKcYm9 QQ7g== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a18-v6si26434648pgu.59.2018.05.29.14.10.31; Tue, 29 May 2018 14:10:45 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966989AbeE2VJp (ORCPT + 99 others); Tue, 29 May 2018 17:09:45 -0400 Received: from mga01.intel.com ([192.55.52.88]:53962 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S937051AbeE2VA4 (ORCPT ); Tue, 29 May 2018 17:00:56 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 May 2018 14:00:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,457,1520924400"; d="scan'208";a="60127678" Received: from rchatre-s.jf.intel.com ([10.54.70.76]) by orsmga001.jf.intel.com with ESMTP; 29 May 2018 14:00:54 -0700 From: Reinette Chatre To: tglx@linutronix.de, fenghua.yu@intel.com, tony.luck@intel.com, vikas.shivappa@linux.intel.com Cc: gavin.hindman@intel.com, jithu.joseph@intel.com, dave.hansen@intel.com, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, linux-kernel@vger.kernel.org, Reinette Chatre Subject: [PATCH V5 04/38] x86/intel_rdt: Introduce resource group's mode resctrl file Date: Tue, 29 May 2018 05:57:29 -0700 Message-Id: <902574465439924850a6e7c4cc06b8a79bd7d2b4.1527593970.git.reinette.chatre@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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) -- 2.13.6