Path: blob/master/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
26516 views
// SPDX-License-Identifier: GPL-2.0-only1/*2* Resource Director Technology(RDT)3* - Cache Allocation code.4*5* Copyright (C) 2016 Intel Corporation6*7* Authors:8* Fenghua Yu <[email protected]>9* Tony Luck <[email protected]>10*11* More information about RDT be found in the Intel (R) x86 Architecture12* Software Developer Manual June 2016, volume 3, section 17.17.13*/1415#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt1617#include <linux/cpu.h>1819#include "internal.h"2021int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_ctrl_domain *d,22u32 closid, enum resctrl_conf_type t, u32 cfg_val)23{24struct rdt_hw_ctrl_domain *hw_dom = resctrl_to_arch_ctrl_dom(d);25struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r);26u32 idx = resctrl_get_config_index(closid, t);27struct msr_param msr_param;2829if (!cpumask_test_cpu(smp_processor_id(), &d->hdr.cpu_mask))30return -EINVAL;3132hw_dom->ctrl_val[idx] = cfg_val;3334msr_param.res = r;35msr_param.dom = d;36msr_param.low = idx;37msr_param.high = idx + 1;38hw_res->msr_update(&msr_param);3940return 0;41}4243int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid)44{45struct resctrl_staged_config *cfg;46struct rdt_hw_ctrl_domain *hw_dom;47struct msr_param msr_param;48struct rdt_ctrl_domain *d;49enum resctrl_conf_type t;50u32 idx;5152/* Walking r->domains, ensure it can't race with cpuhp */53lockdep_assert_cpus_held();5455list_for_each_entry(d, &r->ctrl_domains, hdr.list) {56hw_dom = resctrl_to_arch_ctrl_dom(d);57msr_param.res = NULL;58for (t = 0; t < CDP_NUM_TYPES; t++) {59cfg = &hw_dom->d_resctrl.staged_config[t];60if (!cfg->have_new_ctrl)61continue;6263idx = resctrl_get_config_index(closid, t);64if (cfg->new_ctrl == hw_dom->ctrl_val[idx])65continue;66hw_dom->ctrl_val[idx] = cfg->new_ctrl;6768if (!msr_param.res) {69msr_param.low = idx;70msr_param.high = msr_param.low + 1;71msr_param.res = r;72msr_param.dom = d;73} else {74msr_param.low = min(msr_param.low, idx);75msr_param.high = max(msr_param.high, idx + 1);76}77}78if (msr_param.res)79smp_call_function_any(&d->hdr.cpu_mask, rdt_ctrl_update, &msr_param, 1);80}8182return 0;83}8485u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_ctrl_domain *d,86u32 closid, enum resctrl_conf_type type)87{88struct rdt_hw_ctrl_domain *hw_dom = resctrl_to_arch_ctrl_dom(d);89u32 idx = resctrl_get_config_index(closid, type);9091return hw_dom->ctrl_val[idx];92}939495