- Push down into arch code the rounding of bandwidth control user values due

to the different ways ARM and x86 report MBA
 
 - Fix task reporting for the default group for systems which support only
   bandwidth monitoring, aka Haswell vintage computing
 
 - The usual fixlets and improvements
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEzv7L6UO9uDPlPSfHEsHwGGHeVUoFAmrWwDkACgkQEsHwGGHe
 VUoLXxAAkPL5Hg2ZHbGK4p8XQcj+/rBQkpLYhR+QXqC0fIu4Xa3La6G3er941cO8
 Jih6DMUBPuDBgg+147DHu4KXpE9eZY0ZEb9cZ53imtmLTM6+lFZqi9oe0h5XDrIl
 fiPHI6dwLTkGAIGxpEf2CUamR6dUSMvuOu2ADxdB0z44wlmyY77QyjFLNyM9w/wK
 I3+I8U+m16RdQjbU+WmHC8dzmUNpAdK5Ya9EoVVO4nM3lYCaJjBkDzQhxkLeVDUI
 /JmF9iQDB2UP/MrEidm7uIi/m7w7GCiR82lI6V/IeOjZlVJ/8u6s7Vwk20LWU5qv
 78Q7ZTfhVHvqGSdM+i4pQe6ethrFt8/kkDqH/Yz+QZoAfGpKEML3XKJCQHPaOY09
 DN7MXrtsNxqby7ejZCALIWCGPTxjUcUzjOkMwinKBvw2xY+02QzPAunS+GEU8smR
 75d5/SWKvHTI9pFqkvGT4XzT/eVP3ZfnvZLoh1dI7wIhIbs3Z6UX1ZKnL2vi6JnE
 FpRpahd+SHx8NSx/Z+ZzlotBAqd82sV+FjxeBNaxkGAQRgD2etyufu7Dwy9kFNt/
 wajJxcnJMENh21Xn5Q31YoF/WoL6+xGvETsjr5U3AG276NLXdcB8URkcRExeo4j0
 10b3kiHra2aT4w4qjU1O5IKizUk4cFP44IPNuRnXQA7nC5jKCt4=
 =c84l
 -----END PGP SIGNATURE-----

Merge tag 'x86_cache_for_v7.4_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 resource control updates from Borislav Petkov:

 - Push down into arch code the rounding of bandwidth control user
   values due to the different ways ARM and x86 report MBA

 - Fix task reporting for the default group for systems which support
   only bandwidth monitoring, aka Haswell vintage computing

 - The usual fixlets and improvements

* tag 'x86_cache_for_v7.4_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  fs/resctrl: Ensure default group reports tasks on monitor-only systems
  x86,fs/resctrl: Add event group descriptions for Intel Diamond Rapids
  x86/resctrl: Update documented unit for the "activity" event
  fs/resctrl: Simplify pseudo_lock_measure_trigger()
  fs/resctrl: Avoid extra call to strlen() in schemata_list_add()
  fs/resctrl: Factor MBA parse-time conversion to be per-arch
  arm_mpam: resctrl: Add pass-through resctrl_arch_preconvert_bw()
  x86,fs/resctrl: Add resctrl_arch_preconvert_bw()
This commit is contained in:
Linus Torvalds 2026-10-20 10:11:04 -10:00
commit f3b035ba59
10 changed files with 86 additions and 26 deletions

View File

@ -236,12 +236,11 @@ with respect to allocation:
user can request.
"bandwidth_gran":
The granularity in which the memory bandwidth
percentage is allocated. The allocated
b/w percentage is rounded off to the next
control step available on the hardware. The
available bandwidth control steps are:
min_bandwidth + N * bandwidth_gran.
The approximate granularity in which the memory bandwidth
percentage is allocated. The allocated bandwidth percentage is
rounded up or down to the closest control step available on the
hardware. The available hardware steps are no larger than this
value.
"delay_linear":
Indicates if the delay scale is linear or
@ -643,7 +642,7 @@ When monitoring is enabled all MON groups will also contain:
during execution of instructions summed across all logical CPUs on a
package for the current monitoring group.
"activity" also reports a floating point value (in Farads). This provides
"activity" also reports a floating point value (in nanofarads). This provides
an estimate of work done independent of the frequency that the CPUs used
for execution.
@ -881,8 +880,10 @@ The minimum bandwidth percentage value for each cpu model is predefined
and can be looked up through "info/MB/min_bandwidth". The bandwidth
granularity that is allocated is also dependent on the cpu model and can
be looked up at "info/MB/bandwidth_gran". The available bandwidth
control steps are: min_bw + N * bw_gran. Intermediate values are rounded
to the next control step available on the hardware.
control steps are, approximately, min_bw + N * bw_gran. The steps may
appear irregular due to rounding to an exact percentage: bw_gran is the
maximum interval between the percentage values corresponding to any two
adjacent steps in the hardware.
The bandwidth throttling is a core specific mechanism on some of Intel
SKUs. Using a high bandwidth and a low bandwidth setting on two threads

View File

@ -16,9 +16,15 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/cpu.h>
#include <linux/math.h>
#include "internal.h"
u32 resctrl_arch_preconvert_bw(const struct rdt_resource *r, u32 val)
{
return roundup(val, (unsigned long)r->membw.bw_gran);
}
int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_ctrl_domain *d,
u32 closid, enum resctrl_conf_type t, u32 cfg_val)
{

View File

@ -125,9 +125,43 @@ static struct event_group perf_0x26557651 = {
}
};
/*
* Link: https://github.com/intel/Intel-PMT/blob/main/xml/DMR/OOBMSM/RMID-ENERGY/dmr_aggregator.xml
*/
static struct event_group energy_0x47903099 = {
.pfname = "energy",
.guid = 0x47903099,
.num_rmid = 256,
.mmio_size = XML_MMIO_SIZE(256, 2, 3),
.num_events = 2,
.evts = {
EVT(PMT_EVENT_ENERGY, 0, 18),
EVT(PMT_EVENT_ACTIVITY, 1, 18),
}
};
/*
* Link: https://github.com/intel/Intel-PMT/blob/main/xml/DMR/OOBMSM/RMID-PERF/dmr_aggregator.xml
*/
static struct event_group perf_0x1415910a = {
.pfname = "perf",
.guid = 0x1415910a,
.num_rmid = 256,
.mmio_size = XML_MMIO_SIZE(256, 4, 3),
.num_events = 4,
.evts = {
EVT(PMT_EVENT_UNHALTED_REF_CYCLES, 0, 0),
EVT(PMT_EVENT_UNHALTED_CORE_CYCLES, 1, 0),
EVT(PMT_EVENT_INST_RETIRED, 2, 0),
EVT(PMT_EVENT_PCNT, 3, 0),
}
};
static struct event_group *known_event_groups[] = {
&energy_0x26696143,
&energy_0x47903099,
&perf_0x26557651,
&perf_0x1415910a,
};
#define for_each_event_group(_peg) \

View File

@ -148,6 +148,11 @@ bool resctrl_arch_get_cdp_enabled(enum resctrl_res_level rid)
return mpam_resctrl_controls[rid].cdp_enabled;
}
u32 resctrl_arch_preconvert_bw(const struct rdt_resource *r, u32 val)
{
return val;
}
/**
* resctrl_reset_task_closids() - Reset the PARTID/PMG values for all tasks.
*

View File

@ -37,8 +37,8 @@ typedef int (ctrlval_parser_t)(struct rdt_parse_data *data,
/*
* 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.
* hardware. The allocated bandwidth percentage is converted as appropriate
* for consumption by the specific hardware driver.
*/
static bool bw_validate(char *buf, u32 *data, struct rdt_resource *r)
{
@ -71,7 +71,7 @@ static bool bw_validate(char *buf, u32 *data, struct rdt_resource *r)
return false;
}
*data = roundup(bw, (unsigned long)r->membw.bw_gran);
*data = resctrl_arch_preconvert_bw(r, bw);
return true;
}

View File

@ -1041,6 +1041,8 @@ struct mon_evt mon_event_all[QOS_NUM_EVENTS] = {
MON_EVENT(PMT_EVENT_AUTO_C6_RES, "c6_res", RDT_RESOURCE_PERF_PKG, false),
MON_EVENT(PMT_EVENT_UNHALTED_REF_CYCLES, "unhalted_ref_cycles", RDT_RESOURCE_PERF_PKG, false),
MON_EVENT(PMT_EVENT_UOPS_RETIRED, "uops_retired", RDT_RESOURCE_PERF_PKG, false),
MON_EVENT(PMT_EVENT_INST_RETIRED, "inst_retired", RDT_RESOURCE_PERF_PKG, false),
MON_EVENT(PMT_EVENT_PCNT, "pcnt", RDT_RESOURCE_PERF_PKG, false),
};
bool resctrl_enable_mon_event(enum resctrl_event_id eventid, bool any_cpu,

View File

@ -750,17 +750,10 @@ static ssize_t pseudo_lock_measure_trigger(struct file *file,
size_t count, loff_t *ppos)
{
struct rdtgroup *rdtgrp = file->private_data;
size_t buf_size;
char buf[32];
int ret;
int sel;
buf_size = min(count, (sizeof(buf) - 1));
if (copy_from_user(buf, user_buf, buf_size))
return -EFAULT;
buf[buf_size] = '\0';
ret = kstrtoint(buf, 10, &sel);
ret = kstrtoint_from_user(user_buf, count, 10, &sel);
if (ret == 0) {
if (sel != 1 && sel != 2 && sel != 3)
return -EINVAL;

View File

@ -685,7 +685,7 @@ static int __rdtgroup_move_task(struct task_struct *tsk,
static bool is_closid_match(struct task_struct *t, struct rdtgroup *r)
{
return (resctrl_arch_alloc_capable() && (r->type == RDTCTRL_GROUP) &&
return (r->type == RDTCTRL_GROUP &&
resctrl_arch_match_closid(t, r->closid));
}
@ -2858,7 +2858,7 @@ static int schemata_list_add(struct rdt_resource *r, enum resctrl_conf_type type
{
struct resctrl_schema *s;
const char *suffix = "";
int ret, cl;
int cl;
s = kzalloc_obj(*s);
if (!s)
@ -2882,14 +2882,12 @@ static int schemata_list_add(struct rdt_resource *r, enum resctrl_conf_type type
break;
}
ret = snprintf(s->name, sizeof(s->name), "%s%s", r->name, suffix);
if (ret >= sizeof(s->name)) {
cl = snprintf(s->name, sizeof(s->name), "%s%s", r->name, suffix);
if (cl >= sizeof(s->name)) {
kfree(s);
return -EINVAL;
}
cl = strlen(s->name);
/*
* If CDP is supported by this resource, but not enabled,
* include the suffix. This ensures the tabular format of the

View File

@ -505,6 +505,25 @@ bool resctrl_arch_mbm_cntr_assign_enabled(struct rdt_resource *r);
*/
int resctrl_arch_mbm_cntr_assign_set(struct rdt_resource *r, bool enable);
/**
* resctrl_arch_preconvert_bw() - Prepare bandwidth control value for arch use.
* @r: Resource whose schema was written.
* @val: Bandwidth control value written to the schemata file by userspace.
*
* Convert the user provided bandwidth control value to an appropriate form for
* consumption by the hardware driver for resource @r. Converted value is stored
* in rdt_ctrl_domain::staged_config[] for later consumption by
* resctrl_arch_update_domains(). Is not called when MBA software controller is
* enabled.
*
* Architectures for which this pre-conversion hook is not useful should supply
* an implementation of this function that just returns @val unmodified.
*
* Return:
* The converted value.
*/
u32 resctrl_arch_preconvert_bw(const struct rdt_resource *r, u32 val);
/*
* Update the ctrl_val and apply this config right now.
* Must be called on one of the domain's CPUs.

View File

@ -60,6 +60,8 @@ enum resctrl_event_id {
PMT_EVENT_AUTO_C6_RES,
PMT_EVENT_UNHALTED_REF_CYCLES,
PMT_EVENT_UOPS_RETIRED,
PMT_EVENT_INST_RETIRED,
PMT_EVENT_PCNT,
/* Must be the last */
QOS_NUM_EVENTS,