2016-10-29 05:04:47 +07:00
|
|
|
/*
|
|
|
|
* Resource Director Technology(RDT)
|
|
|
|
* - Cache Allocation code.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2016 Intel Corporation
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Fenghua Yu <fenghua.yu@intel.com>
|
|
|
|
* Tony Luck <tony.luck@intel.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* More information about RDT be found in the Intel (R) x86 Architecture
|
|
|
|
* Software Developer Manual June 2016, volume 3, section 17.17.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
|
|
|
|
#include <linux/kernfs.h>
|
|
|
|
#include <linux/seq_file.h>
|
|
|
|
#include <linux/slab.h>
|
2017-07-26 04:14:23 +07:00
|
|
|
#include "intel_rdt.h"
|
2016-10-29 05:04:47 +07:00
|
|
|
|
2017-04-08 07:33:57 +07:00
|
|
|
/*
|
|
|
|
* Check whether MBA bandwidth percentage value is correct. The value is
|
|
|
|
* checked against the minimum and max bandwidth values specified by the
|
|
|
|
* hardware. The allocated bandwidth percentage is rounded to the next
|
|
|
|
* control step available on the hardware.
|
|
|
|
*/
|
|
|
|
static bool bw_validate(char *buf, unsigned long *data, struct rdt_resource *r)
|
|
|
|
{
|
|
|
|
unsigned long bw;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Only linear delay values is supported for current Intel SKUs.
|
|
|
|
*/
|
2017-09-26 06:39:34 +07:00
|
|
|
if (!r->membw.delay_linear) {
|
|
|
|
rdt_last_cmd_puts("No support for non-linear MB domains\n");
|
2017-04-08 07:33:57 +07:00
|
|
|
return false;
|
2017-09-26 06:39:34 +07:00
|
|
|
}
|
2017-04-08 07:33:57 +07:00
|
|
|
|
|
|
|
ret = kstrtoul(buf, 10, &bw);
|
2017-09-26 06:39:34 +07:00
|
|
|
if (ret) {
|
|
|
|
rdt_last_cmd_printf("Non-decimal digit in MB value %s\n", buf);
|
2017-04-08 07:33:57 +07:00
|
|
|
return false;
|
2017-09-26 06:39:34 +07:00
|
|
|
}
|
2017-04-08 07:33:57 +07:00
|
|
|
|
2018-04-21 05:36:19 +07:00
|
|
|
if ((bw < r->membw.min_bw || bw > r->default_ctrl) &&
|
|
|
|
!is_mba_sc(r)) {
|
2017-09-26 06:39:34 +07:00
|
|
|
rdt_last_cmd_printf("MB value %ld out of range [%d,%d]\n", bw,
|
|
|
|
r->membw.min_bw, r->default_ctrl);
|
2017-04-08 07:33:57 +07:00
|
|
|
return false;
|
2017-09-26 06:39:34 +07:00
|
|
|
}
|
2017-04-08 07:33:57 +07:00
|
|
|
|
|
|
|
*data = roundup(bw, (unsigned long)r->membw.bw_gran);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-09-16 04:58:19 +07:00
|
|
|
int parse_bw(struct rdt_parse_data *data, struct rdt_resource *r,
|
|
|
|
struct rdt_domain *d)
|
2017-04-08 07:33:57 +07:00
|
|
|
{
|
2018-09-16 04:58:19 +07:00
|
|
|
unsigned long bw_val;
|
2017-04-08 07:33:57 +07:00
|
|
|
|
2017-09-26 06:39:34 +07:00
|
|
|
if (d->have_new_ctrl) {
|
|
|
|
rdt_last_cmd_printf("duplicate domain %d\n", d->id);
|
2017-04-08 07:33:57 +07:00
|
|
|
return -EINVAL;
|
2017-09-26 06:39:34 +07:00
|
|
|
}
|
2017-04-08 07:33:57 +07:00
|
|
|
|
2018-09-16 04:58:19 +07:00
|
|
|
if (!bw_validate(data->buf, &bw_val, r))
|
2017-04-08 07:33:57 +07:00
|
|
|
return -EINVAL;
|
2018-09-16 04:58:19 +07:00
|
|
|
d->new_ctrl = bw_val;
|
2017-04-08 07:33:57 +07:00
|
|
|
d->have_new_ctrl = true;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-10-29 05:04:47 +07:00
|
|
|
/*
|
|
|
|
* Check whether a cache bit mask is valid. The SDM says:
|
|
|
|
* Please note that all (and only) contiguous '1' combinations
|
|
|
|
* are allowed (e.g. FFFFH, 0FF0H, 003CH, etc.).
|
|
|
|
* Additionally Haswell requires at least two bits set.
|
|
|
|
*/
|
2018-06-23 05:42:02 +07:00
|
|
|
static bool cbm_validate(char *buf, u32 *data, struct rdt_resource *r)
|
2016-10-29 05:04:47 +07:00
|
|
|
{
|
2017-04-08 07:33:56 +07:00
|
|
|
unsigned long first_bit, zero_bit, val;
|
2017-04-14 18:00:36 +07:00
|
|
|
unsigned int cbm_len = r->cache.cbm_len;
|
2017-04-08 07:33:56 +07:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = kstrtoul(buf, 16, &val);
|
2017-09-26 06:39:34 +07:00
|
|
|
if (ret) {
|
|
|
|
rdt_last_cmd_printf("non-hex character in mask %s\n", buf);
|
2017-04-08 07:33:56 +07:00
|
|
|
return false;
|
2017-09-26 06:39:34 +07:00
|
|
|
}
|
2016-10-29 05:04:47 +07:00
|
|
|
|
2017-09-26 06:39:34 +07:00
|
|
|
if (val == 0 || val > r->default_ctrl) {
|
|
|
|
rdt_last_cmd_puts("mask out of range\n");
|
2016-10-29 05:04:47 +07:00
|
|
|
return false;
|
2017-09-26 06:39:34 +07:00
|
|
|
}
|
2016-10-29 05:04:47 +07:00
|
|
|
|
2017-04-08 07:33:56 +07:00
|
|
|
first_bit = find_first_bit(&val, cbm_len);
|
|
|
|
zero_bit = find_next_zero_bit(&val, cbm_len, first_bit);
|
2016-10-29 05:04:47 +07:00
|
|
|
|
2017-09-26 06:39:34 +07:00
|
|
|
if (find_next_bit(&val, cbm_len, zero_bit) < cbm_len) {
|
|
|
|
rdt_last_cmd_printf("mask %lx has non-consecutive 1-bits\n", val);
|
2016-10-29 05:04:47 +07:00
|
|
|
return false;
|
2017-09-26 06:39:34 +07:00
|
|
|
}
|
2016-10-29 05:04:47 +07:00
|
|
|
|
2017-09-26 06:39:34 +07:00
|
|
|
if ((zero_bit - first_bit) < r->cache.min_cbm_bits) {
|
|
|
|
rdt_last_cmd_printf("Need at least %d bits in mask\n",
|
|
|
|
r->cache.min_cbm_bits);
|
2016-10-29 05:04:47 +07:00
|
|
|
return false;
|
2017-09-26 06:39:34 +07:00
|
|
|
}
|
2017-04-08 07:33:56 +07:00
|
|
|
|
|
|
|
*data = val;
|
2016-10-29 05:04:47 +07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read one cache bit mask (hex). Check that it is valid for the current
|
|
|
|
* resource type.
|
|
|
|
*/
|
2018-09-16 04:58:19 +07:00
|
|
|
int parse_cbm(struct rdt_parse_data *data, struct rdt_resource *r,
|
|
|
|
struct rdt_domain *d)
|
2016-10-29 05:04:47 +07:00
|
|
|
{
|
2018-06-23 05:42:04 +07:00
|
|
|
struct rdtgroup *rdtgrp = data->rdtgrp;
|
2018-06-23 05:42:02 +07:00
|
|
|
u32 cbm_val;
|
2016-10-29 05:04:47 +07:00
|
|
|
|
2017-09-26 06:39:34 +07:00
|
|
|
if (d->have_new_ctrl) {
|
|
|
|
rdt_last_cmd_printf("duplicate domain %d\n", d->id);
|
2017-04-04 04:44:16 +07:00
|
|
|
return -EINVAL;
|
2017-09-26 06:39:34 +07:00
|
|
|
}
|
2017-04-04 04:44:16 +07:00
|
|
|
|
2018-06-23 05:42:22 +07:00
|
|
|
/*
|
|
|
|
* Cannot set up more than one pseudo-locked region in a cache
|
|
|
|
* hierarchy.
|
|
|
|
*/
|
|
|
|
if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP &&
|
|
|
|
rdtgroup_pseudo_locked_in_hierarchy(d)) {
|
|
|
|
rdt_last_cmd_printf("pseudo-locked region in hierarchy\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2018-06-23 05:42:04 +07:00
|
|
|
if (!cbm_validate(data->buf, &cbm_val, r))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2018-06-23 05:42:22 +07:00
|
|
|
if ((rdtgrp->mode == RDT_MODE_EXCLUSIVE ||
|
|
|
|
rdtgrp->mode == RDT_MODE_SHAREABLE) &&
|
|
|
|
rdtgroup_cbm_overlaps_pseudo_locked(d, cbm_val)) {
|
|
|
|
rdt_last_cmd_printf("CBM overlaps with pseudo-locked region\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2018-06-23 05:42:04 +07:00
|
|
|
/*
|
|
|
|
* The CBM may not overlap with the CBM of another closid if
|
|
|
|
* either is exclusive.
|
|
|
|
*/
|
|
|
|
if (rdtgroup_cbm_overlaps(r, d, cbm_val, rdtgrp->closid, true)) {
|
|
|
|
rdt_last_cmd_printf("overlaps with exclusive group\n");
|
2016-10-29 05:04:47 +07:00
|
|
|
return -EINVAL;
|
2018-06-23 05:42:04 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (rdtgroup_cbm_overlaps(r, d, cbm_val, rdtgrp->closid, false)) {
|
2018-06-23 05:42:17 +07:00
|
|
|
if (rdtgrp->mode == RDT_MODE_EXCLUSIVE ||
|
|
|
|
rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP) {
|
2018-06-23 05:42:04 +07:00
|
|
|
rdt_last_cmd_printf("overlaps with other group\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
2018-06-23 05:42:02 +07:00
|
|
|
|
|
|
|
d->new_ctrl = cbm_val;
|
2017-04-08 07:33:51 +07:00
|
|
|
d->have_new_ctrl = true;
|
2016-10-29 05:04:47 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For each domain in this resource we expect to find a series of:
|
|
|
|
* id=mask
|
2017-04-04 04:44:16 +07:00
|
|
|
* separated by ";". The "id" is in decimal, and must match one of
|
|
|
|
* the "id"s for this resource.
|
2016-10-29 05:04:47 +07:00
|
|
|
*/
|
2018-06-23 05:42:04 +07:00
|
|
|
static int parse_line(char *line, struct rdt_resource *r,
|
|
|
|
struct rdtgroup *rdtgrp)
|
2016-10-29 05:04:47 +07:00
|
|
|
{
|
2018-09-16 04:58:19 +07:00
|
|
|
struct rdt_parse_data data;
|
2016-10-29 05:04:47 +07:00
|
|
|
char *dom = NULL, *id;
|
|
|
|
struct rdt_domain *d;
|
|
|
|
unsigned long dom_id;
|
|
|
|
|
2017-04-04 04:44:16 +07:00
|
|
|
next:
|
|
|
|
if (!line || line[0] == '\0')
|
|
|
|
return 0;
|
|
|
|
dom = strsep(&line, ";");
|
|
|
|
id = strsep(&dom, "=");
|
2017-09-26 06:39:34 +07:00
|
|
|
if (!dom || kstrtoul(id, 10, &dom_id)) {
|
|
|
|
rdt_last_cmd_puts("Missing '=' or non-numeric domain\n");
|
2017-04-04 04:44:16 +07:00
|
|
|
return -EINVAL;
|
2017-09-26 06:39:34 +07:00
|
|
|
}
|
2017-04-20 06:50:03 +07:00
|
|
|
dom = strim(dom);
|
2016-10-29 05:04:47 +07:00
|
|
|
list_for_each_entry(d, &r->domains, list) {
|
2017-04-04 04:44:16 +07:00
|
|
|
if (d->id == dom_id) {
|
2018-06-23 05:42:04 +07:00
|
|
|
data.buf = dom;
|
|
|
|
data.rdtgrp = rdtgrp;
|
|
|
|
if (r->parse_ctrlval(&data, r, d))
|
2017-04-04 04:44:16 +07:00
|
|
|
return -EINVAL;
|
2018-06-23 05:42:22 +07:00
|
|
|
if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP) {
|
|
|
|
/*
|
|
|
|
* In pseudo-locking setup mode and just
|
|
|
|
* parsed a valid CBM that should be
|
|
|
|
* pseudo-locked. Only one locked region per
|
|
|
|
* resource group and domain so just do
|
|
|
|
* the required initialization for single
|
|
|
|
* region and return.
|
|
|
|
*/
|
|
|
|
rdtgrp->plr->r = r;
|
|
|
|
rdtgrp->plr->d = d;
|
|
|
|
rdtgrp->plr->cbm = d->new_ctrl;
|
|
|
|
d->plr = rdtgrp->plr;
|
|
|
|
return 0;
|
|
|
|
}
|
2017-04-04 04:44:16 +07:00
|
|
|
goto next;
|
|
|
|
}
|
2016-10-29 05:04:47 +07:00
|
|
|
}
|
2017-04-04 04:44:16 +07:00
|
|
|
return -EINVAL;
|
2016-10-29 05:04:47 +07:00
|
|
|
}
|
|
|
|
|
2018-06-23 05:41:58 +07:00
|
|
|
int update_domains(struct rdt_resource *r, int closid)
|
2016-10-29 05:04:47 +07:00
|
|
|
{
|
|
|
|
struct msr_param msr_param;
|
|
|
|
cpumask_var_t cpu_mask;
|
|
|
|
struct rdt_domain *d;
|
2018-04-21 05:36:19 +07:00
|
|
|
bool mba_sc;
|
|
|
|
u32 *dc;
|
2017-04-04 04:44:16 +07:00
|
|
|
int cpu;
|
2016-10-29 05:04:47 +07:00
|
|
|
|
|
|
|
if (!zalloc_cpumask_var(&cpu_mask, GFP_KERNEL))
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
msr_param.low = closid;
|
|
|
|
msr_param.high = msr_param.low + 1;
|
|
|
|
msr_param.res = r;
|
|
|
|
|
2018-04-21 05:36:19 +07:00
|
|
|
mba_sc = is_mba_sc(r);
|
2016-10-29 05:04:47 +07:00
|
|
|
list_for_each_entry(d, &r->domains, list) {
|
2018-04-21 05:36:19 +07:00
|
|
|
dc = !mba_sc ? d->ctrl_val : d->mbps_val;
|
|
|
|
if (d->have_new_ctrl && d->new_ctrl != dc[closid]) {
|
2017-04-04 04:44:16 +07:00
|
|
|
cpumask_set_cpu(cpumask_any(&d->cpu_mask), cpu_mask);
|
2018-04-21 05:36:19 +07:00
|
|
|
dc[closid] = d->new_ctrl;
|
2017-04-04 04:44:16 +07:00
|
|
|
}
|
2016-10-29 05:04:47 +07:00
|
|
|
}
|
2018-04-21 05:36:19 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Avoid writing the control msr with control values when
|
|
|
|
* MBA software controller is enabled
|
|
|
|
*/
|
|
|
|
if (cpumask_empty(cpu_mask) || mba_sc)
|
2017-04-04 04:44:16 +07:00
|
|
|
goto done;
|
2016-10-29 05:04:47 +07:00
|
|
|
cpu = get_cpu();
|
|
|
|
/* Update CBM on this cpu if it's in cpu_mask. */
|
|
|
|
if (cpumask_test_cpu(cpu, cpu_mask))
|
2017-04-08 07:33:51 +07:00
|
|
|
rdt_ctrl_update(&msr_param);
|
2016-10-29 05:04:47 +07:00
|
|
|
/* Update CBM on other cpus. */
|
2017-04-08 07:33:51 +07:00
|
|
|
smp_call_function_many(cpu_mask, rdt_ctrl_update, &msr_param, 1);
|
2016-10-29 05:04:47 +07:00
|
|
|
put_cpu();
|
|
|
|
|
2017-04-04 04:44:16 +07:00
|
|
|
done:
|
2016-10-29 05:04:47 +07:00
|
|
|
free_cpumask_var(cpu_mask);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-06-23 05:42:04 +07:00
|
|
|
static int rdtgroup_parse_resource(char *resname, char *tok,
|
|
|
|
struct rdtgroup *rdtgrp)
|
2017-04-20 06:50:04 +07:00
|
|
|
{
|
|
|
|
struct rdt_resource *r;
|
|
|
|
|
2017-07-26 04:14:25 +07:00
|
|
|
for_each_alloc_enabled_rdt_resource(r) {
|
2018-06-23 05:42:04 +07:00
|
|
|
if (!strcmp(resname, r->name) && rdtgrp->closid < r->num_closid)
|
|
|
|
return parse_line(tok, r, rdtgrp);
|
2017-04-20 06:50:04 +07:00
|
|
|
}
|
2017-09-26 06:39:34 +07:00
|
|
|
rdt_last_cmd_printf("unknown/unsupported resource name '%s'\n", resname);
|
2017-04-20 06:50:04 +07:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2016-10-29 05:04:47 +07:00
|
|
|
ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
|
|
|
|
char *buf, size_t nbytes, loff_t off)
|
|
|
|
{
|
|
|
|
struct rdtgroup *rdtgrp;
|
2017-04-04 04:44:16 +07:00
|
|
|
struct rdt_domain *dom;
|
2016-10-29 05:04:47 +07:00
|
|
|
struct rdt_resource *r;
|
|
|
|
char *tok, *resname;
|
2018-06-23 05:42:04 +07:00
|
|
|
int ret = 0;
|
2016-10-29 05:04:47 +07:00
|
|
|
|
|
|
|
/* Valid input requires a trailing newline */
|
2017-09-26 06:39:35 +07:00
|
|
|
if (nbytes == 0 || buf[nbytes - 1] != '\n')
|
2016-10-29 05:04:47 +07:00
|
|
|
return -EINVAL;
|
|
|
|
buf[nbytes - 1] = '\0';
|
|
|
|
|
|
|
|
rdtgrp = rdtgroup_kn_lock_live(of->kn);
|
|
|
|
if (!rdtgrp) {
|
|
|
|
rdtgroup_kn_unlock(of->kn);
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
2017-09-26 06:39:34 +07:00
|
|
|
rdt_last_cmd_clear();
|
2016-10-29 05:04:47 +07:00
|
|
|
|
2018-06-23 05:42:12 +07:00
|
|
|
/*
|
|
|
|
* No changes to pseudo-locked region allowed. It has to be removed
|
|
|
|
* and re-created instead.
|
|
|
|
*/
|
|
|
|
if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKED) {
|
|
|
|
ret = -EINVAL;
|
|
|
|
rdt_last_cmd_puts("resource group is pseudo-locked\n");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2017-07-26 04:14:25 +07:00
|
|
|
for_each_alloc_enabled_rdt_resource(r) {
|
2017-04-04 04:44:16 +07:00
|
|
|
list_for_each_entry(dom, &r->domains, list)
|
2017-04-08 07:33:51 +07:00
|
|
|
dom->have_new_ctrl = false;
|
2017-04-20 06:50:04 +07:00
|
|
|
}
|
2016-10-29 05:04:47 +07:00
|
|
|
|
|
|
|
while ((tok = strsep(&buf, "\n")) != NULL) {
|
2017-04-20 06:50:03 +07:00
|
|
|
resname = strim(strsep(&tok, ":"));
|
2016-10-29 05:04:47 +07:00
|
|
|
if (!tok) {
|
2017-09-26 06:39:34 +07:00
|
|
|
rdt_last_cmd_puts("Missing ':'\n");
|
2016-10-29 05:04:47 +07:00
|
|
|
ret = -EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
2017-11-11 02:16:24 +07:00
|
|
|
if (tok[0] == '\0') {
|
|
|
|
rdt_last_cmd_printf("Missing '%s' value\n", resname);
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
2018-06-23 05:42:04 +07:00
|
|
|
ret = rdtgroup_parse_resource(resname, tok, rdtgrp);
|
2017-04-20 06:50:04 +07:00
|
|
|
if (ret)
|
2016-10-29 05:04:47 +07:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2017-07-26 04:14:25 +07:00
|
|
|
for_each_alloc_enabled_rdt_resource(r) {
|
2018-06-23 05:42:04 +07:00
|
|
|
ret = update_domains(r, rdtgrp->closid);
|
2016-10-29 05:04:47 +07:00
|
|
|
if (ret)
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2018-06-23 05:42:22 +07:00
|
|
|
if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP) {
|
|
|
|
/*
|
|
|
|
* If pseudo-locking fails we keep the resource group in
|
|
|
|
* mode RDT_MODE_PSEUDO_LOCKSETUP with its class of service
|
|
|
|
* active and updated for just the domain the pseudo-locked
|
|
|
|
* region was requested for.
|
|
|
|
*/
|
|
|
|
ret = rdtgroup_pseudo_lock_create(rdtgrp);
|
|
|
|
}
|
|
|
|
|
2016-10-29 05:04:47 +07:00
|
|
|
out:
|
|
|
|
rdtgroup_kn_unlock(of->kn);
|
|
|
|
return ret ?: nbytes;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void show_doms(struct seq_file *s, struct rdt_resource *r, int closid)
|
|
|
|
{
|
|
|
|
struct rdt_domain *dom;
|
|
|
|
bool sep = false;
|
2018-04-21 05:36:19 +07:00
|
|
|
u32 ctrl_val;
|
2016-10-29 05:04:47 +07:00
|
|
|
|
2017-04-04 04:44:17 +07:00
|
|
|
seq_printf(s, "%*s:", max_name_width, r->name);
|
2016-10-29 05:04:47 +07:00
|
|
|
list_for_each_entry(dom, &r->domains, list) {
|
|
|
|
if (sep)
|
|
|
|
seq_puts(s, ";");
|
2018-04-21 05:36:19 +07:00
|
|
|
|
|
|
|
ctrl_val = (!is_mba_sc(r) ? dom->ctrl_val[closid] :
|
|
|
|
dom->mbps_val[closid]);
|
2017-04-08 07:33:56 +07:00
|
|
|
seq_printf(s, r->format_str, dom->id, max_data_width,
|
2018-04-21 05:36:19 +07:00
|
|
|
ctrl_val);
|
2016-10-29 05:04:47 +07:00
|
|
|
sep = true;
|
|
|
|
}
|
|
|
|
seq_puts(s, "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
int rdtgroup_schemata_show(struct kernfs_open_file *of,
|
|
|
|
struct seq_file *s, void *v)
|
|
|
|
{
|
|
|
|
struct rdtgroup *rdtgrp;
|
|
|
|
struct rdt_resource *r;
|
2017-07-26 04:14:38 +07:00
|
|
|
int ret = 0;
|
|
|
|
u32 closid;
|
2016-10-29 05:04:47 +07:00
|
|
|
|
|
|
|
rdtgrp = rdtgroup_kn_lock_live(of->kn);
|
|
|
|
if (rdtgrp) {
|
2018-06-23 05:42:17 +07:00
|
|
|
if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP) {
|
|
|
|
for_each_alloc_enabled_rdt_resource(r)
|
|
|
|
seq_printf(s, "%s:uninitialized\n", r->name);
|
2018-06-23 05:42:23 +07:00
|
|
|
} else if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKED) {
|
|
|
|
seq_printf(s, "%s:%d=%x\n", rdtgrp->plr->r->name,
|
|
|
|
rdtgrp->plr->d->id, rdtgrp->plr->cbm);
|
2018-06-23 05:42:17 +07:00
|
|
|
} else {
|
|
|
|
closid = rdtgrp->closid;
|
|
|
|
for_each_alloc_enabled_rdt_resource(r) {
|
|
|
|
if (closid < r->num_closid)
|
|
|
|
show_doms(s, r, closid);
|
|
|
|
}
|
2016-10-29 05:04:47 +07:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ret = -ENOENT;
|
|
|
|
}
|
|
|
|
rdtgroup_kn_unlock(of->kn);
|
|
|
|
return ret;
|
|
|
|
}
|
2017-07-26 04:14:38 +07:00
|
|
|
|
|
|
|
void mon_event_read(struct rmid_read *rr, struct rdt_domain *d,
|
2017-07-26 04:14:46 +07:00
|
|
|
struct rdtgroup *rdtgrp, int evtid, int first)
|
2017-07-26 04:14:38 +07:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* setup the parameters to send to the IPI to read the data.
|
|
|
|
*/
|
|
|
|
rr->rgrp = rdtgrp;
|
|
|
|
rr->evtid = evtid;
|
2017-07-26 04:14:45 +07:00
|
|
|
rr->d = d;
|
2017-07-26 04:14:38 +07:00
|
|
|
rr->val = 0;
|
2017-07-26 04:14:46 +07:00
|
|
|
rr->first = first;
|
2017-07-26 04:14:38 +07:00
|
|
|
|
|
|
|
smp_call_function_any(&d->cpu_mask, mon_event_count, rr, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
int rdtgroup_mondata_show(struct seq_file *m, void *arg)
|
|
|
|
{
|
|
|
|
struct kernfs_open_file *of = m->private;
|
|
|
|
u32 resid, evtid, domid;
|
|
|
|
struct rdtgroup *rdtgrp;
|
|
|
|
struct rdt_resource *r;
|
|
|
|
union mon_data_bits md;
|
|
|
|
struct rdt_domain *d;
|
|
|
|
struct rmid_read rr;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
rdtgrp = rdtgroup_kn_lock_live(of->kn);
|
|
|
|
|
|
|
|
md.priv = of->kn->priv;
|
|
|
|
resid = md.u.rid;
|
|
|
|
domid = md.u.domid;
|
|
|
|
evtid = md.u.evtid;
|
|
|
|
|
|
|
|
r = &rdt_resources_all[resid];
|
|
|
|
d = rdt_find_domain(r, domid, NULL);
|
|
|
|
if (!d) {
|
|
|
|
ret = -ENOENT;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2017-07-26 04:14:46 +07:00
|
|
|
mon_event_read(&rr, d, rdtgrp, evtid, false);
|
2017-07-26 04:14:38 +07:00
|
|
|
|
|
|
|
if (rr.val & RMID_VAL_ERROR)
|
|
|
|
seq_puts(m, "Error\n");
|
|
|
|
else if (rr.val & RMID_VAL_UNAVAIL)
|
|
|
|
seq_puts(m, "Unavailable\n");
|
|
|
|
else
|
|
|
|
seq_printf(m, "%llu\n", rr.val * r->mon_scale);
|
|
|
|
|
|
|
|
out:
|
|
|
|
rdtgroup_kn_unlock(of->kn);
|
|
|
|
return ret;
|
|
|
|
}
|