2020-01-15 09:28:51 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
#ifndef _RESCTRL_H
|
|
|
|
#define _RESCTRL_H
|
|
|
|
|
2024-06-28 21:56:08 +00:00
|
|
|
#include <linux/cacheinfo.h>
|
x86/resctrl: Split struct rdt_resource
resctrl is the defacto Linux ABI for SoC resource partitioning features.
To support it on another architecture, it needs to be abstracted from
the features provided by Intel RDT and AMD PQoS, and moved to /fs/.
struct rdt_resource contains a mix of architecture private details
and properties of the filesystem interface user-space uses.
Start by splitting struct rdt_resource, into an architecture private
'hw' struct, which contains the common resctrl structure that would be
used by any architecture. The foreach helpers are most commonly used by
the filesystem code, and should return the common resctrl structure.
for_each_rdt_resource() is changed to walk the common structure in its
parent arch private structure.
Move as much of the structure as possible into the common structure
in the core code's header file. The x86 hardware accessors remain
part of the architecture private code, as do num_closid, mon_scale
and mbm_width.
mon_scale and mbm_width are used to detect overflow of the hardware
counters, and convert them from their native size to bytes. Any
cross-architecture abstraction should be in terms of bytes, making
these properties private.
The hardware's num_closid is kept in the private structure to force the
filesystem code to use a helper to access it. MPAM would return a single
value for the system, regardless of the resource. Using the helper
prevents this field from being confused with the version of num_closid
that is being exposed to user-space (added in a later patch).
After this split, filesystem code touching a 'hw' struct indicates
where an abstraction is needed.
Splitting this structure only moves types around, and should not lead
to any change in behaviour.
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Jamie Iles <jamie@nuviainc.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Tested-by: Babu Moger <babu.moger@amd.com>
Link: https://lkml.kernel.org/r/20210728170637.25610-2-james.morse@arm.com
2021-07-28 17:06:14 +00:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/list.h>
|
2020-07-08 16:39:24 +00:00
|
|
|
#include <linux/pid.h>
|
2025-03-11 18:36:58 +00:00
|
|
|
#include <linux/resctrl_types.h>
|
2020-07-08 16:39:24 +00:00
|
|
|
|
2025-05-15 16:58:45 +00:00
|
|
|
#ifdef CONFIG_ARCH_HAS_CPU_RESCTRL
|
|
|
|
#include <asm/resctrl.h>
|
|
|
|
#endif
|
|
|
|
|
2024-02-13 18:44:19 +00:00
|
|
|
/* CLOSID, RMID value used by the default control group */
|
|
|
|
#define RESCTRL_RESERVED_CLOSID 0
|
|
|
|
#define RESCTRL_RESERVED_RMID 0
|
|
|
|
|
2024-02-13 18:44:35 +00:00
|
|
|
#define RESCTRL_PICK_ANY_CPU -1
|
|
|
|
|
2020-01-15 09:28:51 +00:00
|
|
|
#ifdef CONFIG_PROC_CPU_RESCTRL
|
|
|
|
|
|
|
|
int proc_resctrl_show(struct seq_file *m,
|
|
|
|
struct pid_namespace *ns,
|
|
|
|
struct pid *pid,
|
|
|
|
struct task_struct *tsk);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2022-09-02 15:48:16 +00:00
|
|
|
/* max value for struct rdt_domain's mbps_val */
|
|
|
|
#define MBA_MAX_MBPS U32_MAX
|
|
|
|
|
2025-03-11 18:37:02 +00:00
|
|
|
/* Walk all possible resources, with variants for only controls or monitors. */
|
|
|
|
#define for_each_rdt_resource(_r) \
|
|
|
|
for ((_r) = resctrl_arch_get_resource(0); \
|
|
|
|
(_r) && (_r)->rid < RDT_NUM_RESOURCES; \
|
|
|
|
(_r) = resctrl_arch_get_resource((_r)->rid + 1))
|
|
|
|
|
|
|
|
#define for_each_capable_rdt_resource(r) \
|
|
|
|
for_each_rdt_resource((r)) \
|
|
|
|
if ((r)->alloc_capable || (r)->mon_capable)
|
|
|
|
|
|
|
|
#define for_each_alloc_capable_rdt_resource(r) \
|
|
|
|
for_each_rdt_resource((r)) \
|
|
|
|
if ((r)->alloc_capable)
|
|
|
|
|
|
|
|
#define for_each_mon_capable_rdt_resource(r) \
|
|
|
|
for_each_rdt_resource((r)) \
|
|
|
|
if ((r)->mon_capable)
|
|
|
|
|
2025-05-15 16:58:47 +00:00
|
|
|
enum resctrl_res_level {
|
|
|
|
RDT_RESOURCE_L3,
|
|
|
|
RDT_RESOURCE_L2,
|
|
|
|
RDT_RESOURCE_MBA,
|
|
|
|
RDT_RESOURCE_SMBA,
|
|
|
|
|
|
|
|
/* Must be the last */
|
|
|
|
RDT_NUM_RESOURCES,
|
|
|
|
};
|
|
|
|
|
2021-07-28 17:06:18 +00:00
|
|
|
/**
|
|
|
|
* enum resctrl_conf_type - The type of configuration.
|
|
|
|
* @CDP_NONE: No prioritisation, both code and data are controlled or monitored.
|
|
|
|
* @CDP_CODE: Configuration applies to instruction fetches.
|
|
|
|
* @CDP_DATA: Configuration applies to reads and writes.
|
|
|
|
*/
|
|
|
|
enum resctrl_conf_type {
|
|
|
|
CDP_NONE,
|
|
|
|
CDP_CODE,
|
|
|
|
CDP_DATA,
|
|
|
|
};
|
|
|
|
|
2021-07-28 17:06:27 +00:00
|
|
|
#define CDP_NUM_TYPES (CDP_DATA + 1)
|
|
|
|
|
2025-03-11 18:37:11 +00:00
|
|
|
/*
|
|
|
|
* struct pseudo_lock_region - pseudo-lock region information
|
|
|
|
* @s: Resctrl schema for the resource to which this
|
|
|
|
* pseudo-locked region belongs
|
|
|
|
* @closid: The closid that this pseudo-locked region uses
|
|
|
|
* @d: RDT domain to which this pseudo-locked region
|
|
|
|
* belongs
|
|
|
|
* @cbm: bitmask of the pseudo-locked region
|
|
|
|
* @lock_thread_wq: waitqueue used to wait on the pseudo-locking thread
|
|
|
|
* completion
|
|
|
|
* @thread_done: variable used by waitqueue to test if pseudo-locking
|
|
|
|
* thread completed
|
|
|
|
* @cpu: core associated with the cache on which the setup code
|
|
|
|
* will be run
|
|
|
|
* @line_size: size of the cache lines
|
|
|
|
* @size: size of pseudo-locked region in bytes
|
|
|
|
* @kmem: the kernel memory associated with pseudo-locked region
|
|
|
|
* @minor: minor number of character device associated with this
|
|
|
|
* region
|
|
|
|
* @debugfs_dir: pointer to this region's directory in the debugfs
|
|
|
|
* filesystem
|
|
|
|
* @pm_reqs: Power management QoS requests related to this region
|
|
|
|
*/
|
|
|
|
struct pseudo_lock_region {
|
|
|
|
struct resctrl_schema *s;
|
|
|
|
u32 closid;
|
|
|
|
struct rdt_ctrl_domain *d;
|
|
|
|
u32 cbm;
|
|
|
|
wait_queue_head_t lock_thread_wq;
|
|
|
|
int thread_done;
|
|
|
|
int cpu;
|
|
|
|
unsigned int line_size;
|
|
|
|
unsigned int size;
|
|
|
|
void *kmem;
|
|
|
|
unsigned int minor;
|
|
|
|
struct dentry *debugfs_dir;
|
|
|
|
struct list_head pm_reqs;
|
|
|
|
};
|
|
|
|
|
2021-07-28 17:06:26 +00:00
|
|
|
/**
|
|
|
|
* struct resctrl_staged_config - parsed configuration to be applied
|
|
|
|
* @new_ctrl: new ctrl value to be loaded
|
|
|
|
* @have_new_ctrl: whether the user provided new_ctrl is valid
|
|
|
|
*/
|
|
|
|
struct resctrl_staged_config {
|
|
|
|
u32 new_ctrl;
|
|
|
|
bool have_new_ctrl;
|
|
|
|
};
|
|
|
|
|
2024-06-28 21:56:03 +00:00
|
|
|
enum resctrl_domain_type {
|
|
|
|
RESCTRL_CTRL_DOMAIN,
|
|
|
|
RESCTRL_MON_DOMAIN,
|
|
|
|
};
|
|
|
|
|
2021-07-28 17:06:15 +00:00
|
|
|
/**
|
2024-06-28 21:56:02 +00:00
|
|
|
* struct rdt_domain_hdr - common header for different domain types
|
2021-07-28 17:06:15 +00:00
|
|
|
* @list: all instances of this resource
|
|
|
|
* @id: unique id for this instance
|
2024-06-28 21:56:03 +00:00
|
|
|
* @type: type of this instance
|
2021-07-28 17:06:15 +00:00
|
|
|
* @cpu_mask: which CPUs share this resource
|
2024-06-28 21:56:02 +00:00
|
|
|
*/
|
|
|
|
struct rdt_domain_hdr {
|
|
|
|
struct list_head list;
|
|
|
|
int id;
|
2024-06-28 21:56:03 +00:00
|
|
|
enum resctrl_domain_type type;
|
2024-06-28 21:56:02 +00:00
|
|
|
struct cpumask cpu_mask;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2024-06-28 21:56:04 +00:00
|
|
|
* struct rdt_ctrl_domain - group of CPUs sharing a resctrl control resource
|
|
|
|
* @hdr: common header for different domain types
|
|
|
|
* @plr: pseudo-locked region (if any) associated with domain
|
|
|
|
* @staged_config: parsed configuration to be applied
|
|
|
|
* @mbps_val: When mba_sc is enabled, this holds the array of user
|
|
|
|
* specified control values for mba_sc in MBps, indexed
|
|
|
|
* by closid
|
|
|
|
*/
|
|
|
|
struct rdt_ctrl_domain {
|
|
|
|
struct rdt_domain_hdr hdr;
|
|
|
|
struct pseudo_lock_region *plr;
|
|
|
|
struct resctrl_staged_config staged_config[CDP_NUM_TYPES];
|
|
|
|
u32 *mbps_val;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct rdt_mon_domain - group of CPUs sharing a resctrl monitor resource
|
2024-06-28 21:56:02 +00:00
|
|
|
* @hdr: common header for different domain types
|
2024-06-28 21:56:08 +00:00
|
|
|
* @ci: cache info for this domain
|
2021-07-28 17:06:15 +00:00
|
|
|
* @rmid_busy_llc: bitmap of which limbo RMIDs are above threshold
|
|
|
|
* @mbm_total: saved state for MBM total bandwidth
|
|
|
|
* @mbm_local: saved state for MBM local bandwidth
|
|
|
|
* @mbm_over: worker to periodically read MBM h/w counters
|
|
|
|
* @cqm_limbo: worker to periodically read CQM h/w counters
|
|
|
|
* @mbm_work_cpu: worker CPU for MBM h/w counters
|
|
|
|
* @cqm_work_cpu: worker CPU for CQM h/w counters
|
|
|
|
*/
|
2024-06-28 21:56:04 +00:00
|
|
|
struct rdt_mon_domain {
|
2024-06-28 21:56:02 +00:00
|
|
|
struct rdt_domain_hdr hdr;
|
2024-06-28 21:56:08 +00:00
|
|
|
struct cacheinfo *ci;
|
2021-07-28 17:06:15 +00:00
|
|
|
unsigned long *rmid_busy_llc;
|
|
|
|
struct mbm_state *mbm_total;
|
|
|
|
struct mbm_state *mbm_local;
|
|
|
|
struct delayed_work mbm_over;
|
|
|
|
struct delayed_work cqm_limbo;
|
|
|
|
int mbm_work_cpu;
|
|
|
|
int cqm_work_cpu;
|
|
|
|
};
|
x86/resctrl: Split struct rdt_resource
resctrl is the defacto Linux ABI for SoC resource partitioning features.
To support it on another architecture, it needs to be abstracted from
the features provided by Intel RDT and AMD PQoS, and moved to /fs/.
struct rdt_resource contains a mix of architecture private details
and properties of the filesystem interface user-space uses.
Start by splitting struct rdt_resource, into an architecture private
'hw' struct, which contains the common resctrl structure that would be
used by any architecture. The foreach helpers are most commonly used by
the filesystem code, and should return the common resctrl structure.
for_each_rdt_resource() is changed to walk the common structure in its
parent arch private structure.
Move as much of the structure as possible into the common structure
in the core code's header file. The x86 hardware accessors remain
part of the architecture private code, as do num_closid, mon_scale
and mbm_width.
mon_scale and mbm_width are used to detect overflow of the hardware
counters, and convert them from their native size to bytes. Any
cross-architecture abstraction should be in terms of bytes, making
these properties private.
The hardware's num_closid is kept in the private structure to force the
filesystem code to use a helper to access it. MPAM would return a single
value for the system, regardless of the resource. Using the helper
prevents this field from being confused with the version of num_closid
that is being exposed to user-space (added in a later patch).
After this split, filesystem code touching a 'hw' struct indicates
where an abstraction is needed.
Splitting this structure only moves types around, and should not lead
to any change in behaviour.
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Jamie Iles <jamie@nuviainc.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Tested-by: Babu Moger <babu.moger@amd.com>
Link: https://lkml.kernel.org/r/20210728170637.25610-2-james.morse@arm.com
2021-07-28 17:06:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* struct resctrl_cache - Cache allocation related data
|
|
|
|
* @cbm_len: Length of the cache bit mask
|
2022-09-27 20:16:36 +00:00
|
|
|
* @min_cbm_bits: Minimum number of consecutive bits to be set.
|
|
|
|
* The value 0 means the architecture can support
|
|
|
|
* zero CBM.
|
x86/resctrl: Split struct rdt_resource
resctrl is the defacto Linux ABI for SoC resource partitioning features.
To support it on another architecture, it needs to be abstracted from
the features provided by Intel RDT and AMD PQoS, and moved to /fs/.
struct rdt_resource contains a mix of architecture private details
and properties of the filesystem interface user-space uses.
Start by splitting struct rdt_resource, into an architecture private
'hw' struct, which contains the common resctrl structure that would be
used by any architecture. The foreach helpers are most commonly used by
the filesystem code, and should return the common resctrl structure.
for_each_rdt_resource() is changed to walk the common structure in its
parent arch private structure.
Move as much of the structure as possible into the common structure
in the core code's header file. The x86 hardware accessors remain
part of the architecture private code, as do num_closid, mon_scale
and mbm_width.
mon_scale and mbm_width are used to detect overflow of the hardware
counters, and convert them from their native size to bytes. Any
cross-architecture abstraction should be in terms of bytes, making
these properties private.
The hardware's num_closid is kept in the private structure to force the
filesystem code to use a helper to access it. MPAM would return a single
value for the system, regardless of the resource. Using the helper
prevents this field from being confused with the version of num_closid
that is being exposed to user-space (added in a later patch).
After this split, filesystem code touching a 'hw' struct indicates
where an abstraction is needed.
Splitting this structure only moves types around, and should not lead
to any change in behaviour.
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Jamie Iles <jamie@nuviainc.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Tested-by: Babu Moger <babu.moger@amd.com>
Link: https://lkml.kernel.org/r/20210728170637.25610-2-james.morse@arm.com
2021-07-28 17:06:14 +00:00
|
|
|
* @shareable_bits: Bitmask of shareable resource with other
|
|
|
|
* executing entities
|
2023-10-10 10:42:36 +00:00
|
|
|
* @arch_has_sparse_bitmasks: True if a bitmask like f00f is valid.
|
x86/resctrl: Split struct rdt_resource
resctrl is the defacto Linux ABI for SoC resource partitioning features.
To support it on another architecture, it needs to be abstracted from
the features provided by Intel RDT and AMD PQoS, and moved to /fs/.
struct rdt_resource contains a mix of architecture private details
and properties of the filesystem interface user-space uses.
Start by splitting struct rdt_resource, into an architecture private
'hw' struct, which contains the common resctrl structure that would be
used by any architecture. The foreach helpers are most commonly used by
the filesystem code, and should return the common resctrl structure.
for_each_rdt_resource() is changed to walk the common structure in its
parent arch private structure.
Move as much of the structure as possible into the common structure
in the core code's header file. The x86 hardware accessors remain
part of the architecture private code, as do num_closid, mon_scale
and mbm_width.
mon_scale and mbm_width are used to detect overflow of the hardware
counters, and convert them from their native size to bytes. Any
cross-architecture abstraction should be in terms of bytes, making
these properties private.
The hardware's num_closid is kept in the private structure to force the
filesystem code to use a helper to access it. MPAM would return a single
value for the system, regardless of the resource. Using the helper
prevents this field from being confused with the version of num_closid
that is being exposed to user-space (added in a later patch).
After this split, filesystem code touching a 'hw' struct indicates
where an abstraction is needed.
Splitting this structure only moves types around, and should not lead
to any change in behaviour.
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Jamie Iles <jamie@nuviainc.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Tested-by: Babu Moger <babu.moger@amd.com>
Link: https://lkml.kernel.org/r/20210728170637.25610-2-james.morse@arm.com
2021-07-28 17:06:14 +00:00
|
|
|
* @arch_has_per_cpu_cfg: True if QOS_CFG register for this cache
|
|
|
|
* level has CPU scope.
|
|
|
|
*/
|
|
|
|
struct resctrl_cache {
|
|
|
|
unsigned int cbm_len;
|
|
|
|
unsigned int min_cbm_bits;
|
|
|
|
unsigned int shareable_bits;
|
2023-10-10 10:42:36 +00:00
|
|
|
bool arch_has_sparse_bitmasks;
|
x86/resctrl: Split struct rdt_resource
resctrl is the defacto Linux ABI for SoC resource partitioning features.
To support it on another architecture, it needs to be abstracted from
the features provided by Intel RDT and AMD PQoS, and moved to /fs/.
struct rdt_resource contains a mix of architecture private details
and properties of the filesystem interface user-space uses.
Start by splitting struct rdt_resource, into an architecture private
'hw' struct, which contains the common resctrl structure that would be
used by any architecture. The foreach helpers are most commonly used by
the filesystem code, and should return the common resctrl structure.
for_each_rdt_resource() is changed to walk the common structure in its
parent arch private structure.
Move as much of the structure as possible into the common structure
in the core code's header file. The x86 hardware accessors remain
part of the architecture private code, as do num_closid, mon_scale
and mbm_width.
mon_scale and mbm_width are used to detect overflow of the hardware
counters, and convert them from their native size to bytes. Any
cross-architecture abstraction should be in terms of bytes, making
these properties private.
The hardware's num_closid is kept in the private structure to force the
filesystem code to use a helper to access it. MPAM would return a single
value for the system, regardless of the resource. Using the helper
prevents this field from being confused with the version of num_closid
that is being exposed to user-space (added in a later patch).
After this split, filesystem code touching a 'hw' struct indicates
where an abstraction is needed.
Splitting this structure only moves types around, and should not lead
to any change in behaviour.
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Jamie Iles <jamie@nuviainc.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Tested-by: Babu Moger <babu.moger@amd.com>
Link: https://lkml.kernel.org/r/20210728170637.25610-2-james.morse@arm.com
2021-07-28 17:06:14 +00:00
|
|
|
bool arch_has_per_cpu_cfg;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* enum membw_throttle_mode - System's memory bandwidth throttling mode
|
|
|
|
* @THREAD_THROTTLE_UNDEFINED: Not relevant to the system
|
|
|
|
* @THREAD_THROTTLE_MAX: Memory bandwidth is throttled at the core
|
|
|
|
* always using smallest bandwidth percentage
|
|
|
|
* assigned to threads, aka "max throttling"
|
|
|
|
* @THREAD_THROTTLE_PER_THREAD: Memory bandwidth is throttled at the thread
|
|
|
|
*/
|
|
|
|
enum membw_throttle_mode {
|
|
|
|
THREAD_THROTTLE_UNDEFINED = 0,
|
|
|
|
THREAD_THROTTLE_MAX,
|
|
|
|
THREAD_THROTTLE_PER_THREAD,
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct resctrl_membw - Memory bandwidth allocation related data
|
|
|
|
* @min_bw: Minimum memory bandwidth percentage user can request
|
2025-03-11 18:36:52 +00:00
|
|
|
* @max_bw: Maximum memory bandwidth value, used as the reset value
|
x86/resctrl: Split struct rdt_resource
resctrl is the defacto Linux ABI for SoC resource partitioning features.
To support it on another architecture, it needs to be abstracted from
the features provided by Intel RDT and AMD PQoS, and moved to /fs/.
struct rdt_resource contains a mix of architecture private details
and properties of the filesystem interface user-space uses.
Start by splitting struct rdt_resource, into an architecture private
'hw' struct, which contains the common resctrl structure that would be
used by any architecture. The foreach helpers are most commonly used by
the filesystem code, and should return the common resctrl structure.
for_each_rdt_resource() is changed to walk the common structure in its
parent arch private structure.
Move as much of the structure as possible into the common structure
in the core code's header file. The x86 hardware accessors remain
part of the architecture private code, as do num_closid, mon_scale
and mbm_width.
mon_scale and mbm_width are used to detect overflow of the hardware
counters, and convert them from their native size to bytes. Any
cross-architecture abstraction should be in terms of bytes, making
these properties private.
The hardware's num_closid is kept in the private structure to force the
filesystem code to use a helper to access it. MPAM would return a single
value for the system, regardless of the resource. Using the helper
prevents this field from being confused with the version of num_closid
that is being exposed to user-space (added in a later patch).
After this split, filesystem code touching a 'hw' struct indicates
where an abstraction is needed.
Splitting this structure only moves types around, and should not lead
to any change in behaviour.
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Jamie Iles <jamie@nuviainc.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Tested-by: Babu Moger <babu.moger@amd.com>
Link: https://lkml.kernel.org/r/20210728170637.25610-2-james.morse@arm.com
2021-07-28 17:06:14 +00:00
|
|
|
* @bw_gran: Granularity at which the memory bandwidth is allocated
|
|
|
|
* @delay_linear: True if memory B/W delay is in linear scale
|
|
|
|
* @arch_needs_linear: True if we can't configure non-linear resources
|
|
|
|
* @throttle_mode: Bandwidth throttling mode when threads request
|
|
|
|
* different memory bandwidths
|
|
|
|
* @mba_sc: True if MBA software controller(mba_sc) is enabled
|
|
|
|
* @mb_map: Mapping of memory B/W percentage to memory B/W delay
|
|
|
|
*/
|
|
|
|
struct resctrl_membw {
|
|
|
|
u32 min_bw;
|
2025-03-11 18:36:52 +00:00
|
|
|
u32 max_bw;
|
x86/resctrl: Split struct rdt_resource
resctrl is the defacto Linux ABI for SoC resource partitioning features.
To support it on another architecture, it needs to be abstracted from
the features provided by Intel RDT and AMD PQoS, and moved to /fs/.
struct rdt_resource contains a mix of architecture private details
and properties of the filesystem interface user-space uses.
Start by splitting struct rdt_resource, into an architecture private
'hw' struct, which contains the common resctrl structure that would be
used by any architecture. The foreach helpers are most commonly used by
the filesystem code, and should return the common resctrl structure.
for_each_rdt_resource() is changed to walk the common structure in its
parent arch private structure.
Move as much of the structure as possible into the common structure
in the core code's header file. The x86 hardware accessors remain
part of the architecture private code, as do num_closid, mon_scale
and mbm_width.
mon_scale and mbm_width are used to detect overflow of the hardware
counters, and convert them from their native size to bytes. Any
cross-architecture abstraction should be in terms of bytes, making
these properties private.
The hardware's num_closid is kept in the private structure to force the
filesystem code to use a helper to access it. MPAM would return a single
value for the system, regardless of the resource. Using the helper
prevents this field from being confused with the version of num_closid
that is being exposed to user-space (added in a later patch).
After this split, filesystem code touching a 'hw' struct indicates
where an abstraction is needed.
Splitting this structure only moves types around, and should not lead
to any change in behaviour.
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Jamie Iles <jamie@nuviainc.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Tested-by: Babu Moger <babu.moger@amd.com>
Link: https://lkml.kernel.org/r/20210728170637.25610-2-james.morse@arm.com
2021-07-28 17:06:14 +00:00
|
|
|
u32 bw_gran;
|
|
|
|
u32 delay_linear;
|
|
|
|
bool arch_needs_linear;
|
|
|
|
enum membw_throttle_mode throttle_mode;
|
|
|
|
bool mba_sc;
|
|
|
|
u32 *mb_map;
|
|
|
|
};
|
|
|
|
|
2021-07-28 17:06:22 +00:00
|
|
|
struct resctrl_schema;
|
x86/resctrl: Split struct rdt_resource
resctrl is the defacto Linux ABI for SoC resource partitioning features.
To support it on another architecture, it needs to be abstracted from
the features provided by Intel RDT and AMD PQoS, and moved to /fs/.
struct rdt_resource contains a mix of architecture private details
and properties of the filesystem interface user-space uses.
Start by splitting struct rdt_resource, into an architecture private
'hw' struct, which contains the common resctrl structure that would be
used by any architecture. The foreach helpers are most commonly used by
the filesystem code, and should return the common resctrl structure.
for_each_rdt_resource() is changed to walk the common structure in its
parent arch private structure.
Move as much of the structure as possible into the common structure
in the core code's header file. The x86 hardware accessors remain
part of the architecture private code, as do num_closid, mon_scale
and mbm_width.
mon_scale and mbm_width are used to detect overflow of the hardware
counters, and convert them from their native size to bytes. Any
cross-architecture abstraction should be in terms of bytes, making
these properties private.
The hardware's num_closid is kept in the private structure to force the
filesystem code to use a helper to access it. MPAM would return a single
value for the system, regardless of the resource. Using the helper
prevents this field from being confused with the version of num_closid
that is being exposed to user-space (added in a later patch).
After this split, filesystem code touching a 'hw' struct indicates
where an abstraction is needed.
Splitting this structure only moves types around, and should not lead
to any change in behaviour.
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Jamie Iles <jamie@nuviainc.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Tested-by: Babu Moger <babu.moger@amd.com>
Link: https://lkml.kernel.org/r/20210728170637.25610-2-james.morse@arm.com
2021-07-28 17:06:14 +00:00
|
|
|
|
2024-06-28 21:56:01 +00:00
|
|
|
enum resctrl_scope {
|
|
|
|
RESCTRL_L2_CACHE = 2,
|
|
|
|
RESCTRL_L3_CACHE = 3,
|
2024-06-28 21:56:05 +00:00
|
|
|
RESCTRL_L3_NODE,
|
2024-06-28 21:56:01 +00:00
|
|
|
};
|
|
|
|
|
2025-03-11 18:36:49 +00:00
|
|
|
/**
|
|
|
|
* enum resctrl_schema_fmt - The format user-space provides for a schema.
|
|
|
|
* @RESCTRL_SCHEMA_BITMAP: The schema is a bitmap in hex.
|
|
|
|
* @RESCTRL_SCHEMA_RANGE: The schema is a decimal number.
|
|
|
|
*/
|
|
|
|
enum resctrl_schema_fmt {
|
|
|
|
RESCTRL_SCHEMA_BITMAP,
|
|
|
|
RESCTRL_SCHEMA_RANGE,
|
|
|
|
};
|
|
|
|
|
x86/resctrl: Split struct rdt_resource
resctrl is the defacto Linux ABI for SoC resource partitioning features.
To support it on another architecture, it needs to be abstracted from
the features provided by Intel RDT and AMD PQoS, and moved to /fs/.
struct rdt_resource contains a mix of architecture private details
and properties of the filesystem interface user-space uses.
Start by splitting struct rdt_resource, into an architecture private
'hw' struct, which contains the common resctrl structure that would be
used by any architecture. The foreach helpers are most commonly used by
the filesystem code, and should return the common resctrl structure.
for_each_rdt_resource() is changed to walk the common structure in its
parent arch private structure.
Move as much of the structure as possible into the common structure
in the core code's header file. The x86 hardware accessors remain
part of the architecture private code, as do num_closid, mon_scale
and mbm_width.
mon_scale and mbm_width are used to detect overflow of the hardware
counters, and convert them from their native size to bytes. Any
cross-architecture abstraction should be in terms of bytes, making
these properties private.
The hardware's num_closid is kept in the private structure to force the
filesystem code to use a helper to access it. MPAM would return a single
value for the system, regardless of the resource. Using the helper
prevents this field from being confused with the version of num_closid
that is being exposed to user-space (added in a later patch).
After this split, filesystem code touching a 'hw' struct indicates
where an abstraction is needed.
Splitting this structure only moves types around, and should not lead
to any change in behaviour.
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Jamie Iles <jamie@nuviainc.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Tested-by: Babu Moger <babu.moger@amd.com>
Link: https://lkml.kernel.org/r/20210728170637.25610-2-james.morse@arm.com
2021-07-28 17:06:14 +00:00
|
|
|
/**
|
|
|
|
* struct rdt_resource - attributes of a resctrl resource
|
|
|
|
* @rid: The index of the resource
|
|
|
|
* @alloc_capable: Is allocation available on this machine
|
|
|
|
* @mon_capable: Is monitor feature available on this machine
|
|
|
|
* @num_rmid: Number of RMIDs available
|
2024-06-28 21:56:03 +00:00
|
|
|
* @ctrl_scope: Scope of this resource for control functions
|
|
|
|
* @mon_scope: Scope of this resource for monitor functions
|
x86/resctrl: Split struct rdt_resource
resctrl is the defacto Linux ABI for SoC resource partitioning features.
To support it on another architecture, it needs to be abstracted from
the features provided by Intel RDT and AMD PQoS, and moved to /fs/.
struct rdt_resource contains a mix of architecture private details
and properties of the filesystem interface user-space uses.
Start by splitting struct rdt_resource, into an architecture private
'hw' struct, which contains the common resctrl structure that would be
used by any architecture. The foreach helpers are most commonly used by
the filesystem code, and should return the common resctrl structure.
for_each_rdt_resource() is changed to walk the common structure in its
parent arch private structure.
Move as much of the structure as possible into the common structure
in the core code's header file. The x86 hardware accessors remain
part of the architecture private code, as do num_closid, mon_scale
and mbm_width.
mon_scale and mbm_width are used to detect overflow of the hardware
counters, and convert them from their native size to bytes. Any
cross-architecture abstraction should be in terms of bytes, making
these properties private.
The hardware's num_closid is kept in the private structure to force the
filesystem code to use a helper to access it. MPAM would return a single
value for the system, regardless of the resource. Using the helper
prevents this field from being confused with the version of num_closid
that is being exposed to user-space (added in a later patch).
After this split, filesystem code touching a 'hw' struct indicates
where an abstraction is needed.
Splitting this structure only moves types around, and should not lead
to any change in behaviour.
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Jamie Iles <jamie@nuviainc.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Tested-by: Babu Moger <babu.moger@amd.com>
Link: https://lkml.kernel.org/r/20210728170637.25610-2-james.morse@arm.com
2021-07-28 17:06:14 +00:00
|
|
|
* @cache: Cache allocation related data
|
|
|
|
* @membw: If the component has bandwidth controls, their properties.
|
2024-06-28 21:56:03 +00:00
|
|
|
* @ctrl_domains: RCU list of all control domains for this resource
|
|
|
|
* @mon_domains: RCU list of all monitor domains for this resource
|
x86/resctrl: Split struct rdt_resource
resctrl is the defacto Linux ABI for SoC resource partitioning features.
To support it on another architecture, it needs to be abstracted from
the features provided by Intel RDT and AMD PQoS, and moved to /fs/.
struct rdt_resource contains a mix of architecture private details
and properties of the filesystem interface user-space uses.
Start by splitting struct rdt_resource, into an architecture private
'hw' struct, which contains the common resctrl structure that would be
used by any architecture. The foreach helpers are most commonly used by
the filesystem code, and should return the common resctrl structure.
for_each_rdt_resource() is changed to walk the common structure in its
parent arch private structure.
Move as much of the structure as possible into the common structure
in the core code's header file. The x86 hardware accessors remain
part of the architecture private code, as do num_closid, mon_scale
and mbm_width.
mon_scale and mbm_width are used to detect overflow of the hardware
counters, and convert them from their native size to bytes. Any
cross-architecture abstraction should be in terms of bytes, making
these properties private.
The hardware's num_closid is kept in the private structure to force the
filesystem code to use a helper to access it. MPAM would return a single
value for the system, regardless of the resource. Using the helper
prevents this field from being confused with the version of num_closid
that is being exposed to user-space (added in a later patch).
After this split, filesystem code touching a 'hw' struct indicates
where an abstraction is needed.
Splitting this structure only moves types around, and should not lead
to any change in behaviour.
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Jamie Iles <jamie@nuviainc.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Tested-by: Babu Moger <babu.moger@amd.com>
Link: https://lkml.kernel.org/r/20210728170637.25610-2-james.morse@arm.com
2021-07-28 17:06:14 +00:00
|
|
|
* @name: Name to use in "schemata" file.
|
2025-03-11 18:36:49 +00:00
|
|
|
* @schema_fmt: Which format string and parser is used for this schema.
|
x86/resctrl: Split struct rdt_resource
resctrl is the defacto Linux ABI for SoC resource partitioning features.
To support it on another architecture, it needs to be abstracted from
the features provided by Intel RDT and AMD PQoS, and moved to /fs/.
struct rdt_resource contains a mix of architecture private details
and properties of the filesystem interface user-space uses.
Start by splitting struct rdt_resource, into an architecture private
'hw' struct, which contains the common resctrl structure that would be
used by any architecture. The foreach helpers are most commonly used by
the filesystem code, and should return the common resctrl structure.
for_each_rdt_resource() is changed to walk the common structure in its
parent arch private structure.
Move as much of the structure as possible into the common structure
in the core code's header file. The x86 hardware accessors remain
part of the architecture private code, as do num_closid, mon_scale
and mbm_width.
mon_scale and mbm_width are used to detect overflow of the hardware
counters, and convert them from their native size to bytes. Any
cross-architecture abstraction should be in terms of bytes, making
these properties private.
The hardware's num_closid is kept in the private structure to force the
filesystem code to use a helper to access it. MPAM would return a single
value for the system, regardless of the resource. Using the helper
prevents this field from being confused with the version of num_closid
that is being exposed to user-space (added in a later patch).
After this split, filesystem code touching a 'hw' struct indicates
where an abstraction is needed.
Splitting this structure only moves types around, and should not lead
to any change in behaviour.
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Jamie Iles <jamie@nuviainc.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Tested-by: Babu Moger <babu.moger@amd.com>
Link: https://lkml.kernel.org/r/20210728170637.25610-2-james.morse@arm.com
2021-07-28 17:06:14 +00:00
|
|
|
* @evt_list: List of monitoring events
|
2025-03-11 18:37:07 +00:00
|
|
|
* @mbm_cfg_mask: Bandwidth sources that can be tracked when bandwidth
|
|
|
|
* monitoring events can be configured.
|
2021-07-28 17:06:24 +00:00
|
|
|
* @cdp_capable: Is the CDP feature available on this resource
|
x86/resctrl: Split struct rdt_resource
resctrl is the defacto Linux ABI for SoC resource partitioning features.
To support it on another architecture, it needs to be abstracted from
the features provided by Intel RDT and AMD PQoS, and moved to /fs/.
struct rdt_resource contains a mix of architecture private details
and properties of the filesystem interface user-space uses.
Start by splitting struct rdt_resource, into an architecture private
'hw' struct, which contains the common resctrl structure that would be
used by any architecture. The foreach helpers are most commonly used by
the filesystem code, and should return the common resctrl structure.
for_each_rdt_resource() is changed to walk the common structure in its
parent arch private structure.
Move as much of the structure as possible into the common structure
in the core code's header file. The x86 hardware accessors remain
part of the architecture private code, as do num_closid, mon_scale
and mbm_width.
mon_scale and mbm_width are used to detect overflow of the hardware
counters, and convert them from their native size to bytes. Any
cross-architecture abstraction should be in terms of bytes, making
these properties private.
The hardware's num_closid is kept in the private structure to force the
filesystem code to use a helper to access it. MPAM would return a single
value for the system, regardless of the resource. Using the helper
prevents this field from being confused with the version of num_closid
that is being exposed to user-space (added in a later patch).
After this split, filesystem code touching a 'hw' struct indicates
where an abstraction is needed.
Splitting this structure only moves types around, and should not lead
to any change in behaviour.
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Jamie Iles <jamie@nuviainc.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Tested-by: Babu Moger <babu.moger@amd.com>
Link: https://lkml.kernel.org/r/20210728170637.25610-2-james.morse@arm.com
2021-07-28 17:06:14 +00:00
|
|
|
*/
|
|
|
|
struct rdt_resource {
|
|
|
|
int rid;
|
|
|
|
bool alloc_capable;
|
|
|
|
bool mon_capable;
|
|
|
|
int num_rmid;
|
2024-06-28 21:56:03 +00:00
|
|
|
enum resctrl_scope ctrl_scope;
|
|
|
|
enum resctrl_scope mon_scope;
|
x86/resctrl: Split struct rdt_resource
resctrl is the defacto Linux ABI for SoC resource partitioning features.
To support it on another architecture, it needs to be abstracted from
the features provided by Intel RDT and AMD PQoS, and moved to /fs/.
struct rdt_resource contains a mix of architecture private details
and properties of the filesystem interface user-space uses.
Start by splitting struct rdt_resource, into an architecture private
'hw' struct, which contains the common resctrl structure that would be
used by any architecture. The foreach helpers are most commonly used by
the filesystem code, and should return the common resctrl structure.
for_each_rdt_resource() is changed to walk the common structure in its
parent arch private structure.
Move as much of the structure as possible into the common structure
in the core code's header file. The x86 hardware accessors remain
part of the architecture private code, as do num_closid, mon_scale
and mbm_width.
mon_scale and mbm_width are used to detect overflow of the hardware
counters, and convert them from their native size to bytes. Any
cross-architecture abstraction should be in terms of bytes, making
these properties private.
The hardware's num_closid is kept in the private structure to force the
filesystem code to use a helper to access it. MPAM would return a single
value for the system, regardless of the resource. Using the helper
prevents this field from being confused with the version of num_closid
that is being exposed to user-space (added in a later patch).
After this split, filesystem code touching a 'hw' struct indicates
where an abstraction is needed.
Splitting this structure only moves types around, and should not lead
to any change in behaviour.
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Jamie Iles <jamie@nuviainc.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Tested-by: Babu Moger <babu.moger@amd.com>
Link: https://lkml.kernel.org/r/20210728170637.25610-2-james.morse@arm.com
2021-07-28 17:06:14 +00:00
|
|
|
struct resctrl_cache cache;
|
|
|
|
struct resctrl_membw membw;
|
2024-06-28 21:56:03 +00:00
|
|
|
struct list_head ctrl_domains;
|
|
|
|
struct list_head mon_domains;
|
x86/resctrl: Split struct rdt_resource
resctrl is the defacto Linux ABI for SoC resource partitioning features.
To support it on another architecture, it needs to be abstracted from
the features provided by Intel RDT and AMD PQoS, and moved to /fs/.
struct rdt_resource contains a mix of architecture private details
and properties of the filesystem interface user-space uses.
Start by splitting struct rdt_resource, into an architecture private
'hw' struct, which contains the common resctrl structure that would be
used by any architecture. The foreach helpers are most commonly used by
the filesystem code, and should return the common resctrl structure.
for_each_rdt_resource() is changed to walk the common structure in its
parent arch private structure.
Move as much of the structure as possible into the common structure
in the core code's header file. The x86 hardware accessors remain
part of the architecture private code, as do num_closid, mon_scale
and mbm_width.
mon_scale and mbm_width are used to detect overflow of the hardware
counters, and convert them from their native size to bytes. Any
cross-architecture abstraction should be in terms of bytes, making
these properties private.
The hardware's num_closid is kept in the private structure to force the
filesystem code to use a helper to access it. MPAM would return a single
value for the system, regardless of the resource. Using the helper
prevents this field from being confused with the version of num_closid
that is being exposed to user-space (added in a later patch).
After this split, filesystem code touching a 'hw' struct indicates
where an abstraction is needed.
Splitting this structure only moves types around, and should not lead
to any change in behaviour.
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Jamie Iles <jamie@nuviainc.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Tested-by: Babu Moger <babu.moger@amd.com>
Link: https://lkml.kernel.org/r/20210728170637.25610-2-james.morse@arm.com
2021-07-28 17:06:14 +00:00
|
|
|
char *name;
|
2025-03-11 18:36:49 +00:00
|
|
|
enum resctrl_schema_fmt schema_fmt;
|
x86/resctrl: Split struct rdt_resource
resctrl is the defacto Linux ABI for SoC resource partitioning features.
To support it on another architecture, it needs to be abstracted from
the features provided by Intel RDT and AMD PQoS, and moved to /fs/.
struct rdt_resource contains a mix of architecture private details
and properties of the filesystem interface user-space uses.
Start by splitting struct rdt_resource, into an architecture private
'hw' struct, which contains the common resctrl structure that would be
used by any architecture. The foreach helpers are most commonly used by
the filesystem code, and should return the common resctrl structure.
for_each_rdt_resource() is changed to walk the common structure in its
parent arch private structure.
Move as much of the structure as possible into the common structure
in the core code's header file. The x86 hardware accessors remain
part of the architecture private code, as do num_closid, mon_scale
and mbm_width.
mon_scale and mbm_width are used to detect overflow of the hardware
counters, and convert them from their native size to bytes. Any
cross-architecture abstraction should be in terms of bytes, making
these properties private.
The hardware's num_closid is kept in the private structure to force the
filesystem code to use a helper to access it. MPAM would return a single
value for the system, regardless of the resource. Using the helper
prevents this field from being confused with the version of num_closid
that is being exposed to user-space (added in a later patch).
After this split, filesystem code touching a 'hw' struct indicates
where an abstraction is needed.
Splitting this structure only moves types around, and should not lead
to any change in behaviour.
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Jamie Iles <jamie@nuviainc.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Tested-by: Babu Moger <babu.moger@amd.com>
Link: https://lkml.kernel.org/r/20210728170637.25610-2-james.morse@arm.com
2021-07-28 17:06:14 +00:00
|
|
|
struct list_head evt_list;
|
2025-03-11 18:37:07 +00:00
|
|
|
unsigned int mbm_cfg_mask;
|
2021-07-28 17:06:24 +00:00
|
|
|
bool cdp_capable;
|
x86/resctrl: Split struct rdt_resource
resctrl is the defacto Linux ABI for SoC resource partitioning features.
To support it on another architecture, it needs to be abstracted from
the features provided by Intel RDT and AMD PQoS, and moved to /fs/.
struct rdt_resource contains a mix of architecture private details
and properties of the filesystem interface user-space uses.
Start by splitting struct rdt_resource, into an architecture private
'hw' struct, which contains the common resctrl structure that would be
used by any architecture. The foreach helpers are most commonly used by
the filesystem code, and should return the common resctrl structure.
for_each_rdt_resource() is changed to walk the common structure in its
parent arch private structure.
Move as much of the structure as possible into the common structure
in the core code's header file. The x86 hardware accessors remain
part of the architecture private code, as do num_closid, mon_scale
and mbm_width.
mon_scale and mbm_width are used to detect overflow of the hardware
counters, and convert them from their native size to bytes. Any
cross-architecture abstraction should be in terms of bytes, making
these properties private.
The hardware's num_closid is kept in the private structure to force the
filesystem code to use a helper to access it. MPAM would return a single
value for the system, regardless of the resource. Using the helper
prevents this field from being confused with the version of num_closid
that is being exposed to user-space (added in a later patch).
After this split, filesystem code touching a 'hw' struct indicates
where an abstraction is needed.
Splitting this structure only moves types around, and should not lead
to any change in behaviour.
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Jamie Iles <jamie@nuviainc.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Tested-by: Babu Moger <babu.moger@amd.com>
Link: https://lkml.kernel.org/r/20210728170637.25610-2-james.morse@arm.com
2021-07-28 17:06:14 +00:00
|
|
|
};
|
|
|
|
|
2025-03-11 18:36:47 +00:00
|
|
|
/*
|
|
|
|
* Get the resource that exists at this level. If the level is not supported
|
|
|
|
* a dummy/not-capable resource can be returned. Levels >= RDT_NUM_RESOURCES
|
|
|
|
* will return NULL.
|
|
|
|
*/
|
|
|
|
struct rdt_resource *resctrl_arch_get_resource(enum resctrl_res_level l);
|
|
|
|
|
2021-07-28 17:06:16 +00:00
|
|
|
/**
|
|
|
|
* struct resctrl_schema - configuration abilities of a resource presented to
|
|
|
|
* user-space
|
|
|
|
* @list: Member of resctrl_schema_all.
|
2021-07-28 17:06:25 +00:00
|
|
|
* @name: The name to use in the "schemata" file.
|
2025-03-11 18:36:50 +00:00
|
|
|
* @fmt_str: Format string to show domain value.
|
2021-07-28 17:06:18 +00:00
|
|
|
* @conf_type: Whether this schema is specific to code/data.
|
2021-07-28 17:06:16 +00:00
|
|
|
* @res: The resource structure exported by the architecture to describe
|
|
|
|
* the hardware that is configured by this schema.
|
2021-07-28 17:06:20 +00:00
|
|
|
* @num_closid: The number of closid that can be used with this schema. When
|
|
|
|
* features like CDP are enabled, this will be lower than the
|
|
|
|
* hardware supports for the resource.
|
2021-07-28 17:06:16 +00:00
|
|
|
*/
|
|
|
|
struct resctrl_schema {
|
|
|
|
struct list_head list;
|
2021-07-28 17:06:25 +00:00
|
|
|
char name[8];
|
2025-03-11 18:36:50 +00:00
|
|
|
const char *fmt_str;
|
2021-07-28 17:06:18 +00:00
|
|
|
enum resctrl_conf_type conf_type;
|
2021-07-28 17:06:16 +00:00
|
|
|
struct rdt_resource *res;
|
2021-07-28 17:06:21 +00:00
|
|
|
u32 num_closid;
|
2021-07-28 17:06:16 +00:00
|
|
|
};
|
2021-07-28 17:06:21 +00:00
|
|
|
|
2025-03-11 18:36:55 +00:00
|
|
|
struct resctrl_cpu_defaults {
|
|
|
|
u32 closid;
|
|
|
|
u32 rmid;
|
|
|
|
};
|
|
|
|
|
2025-03-11 18:37:05 +00:00
|
|
|
struct resctrl_mon_config_info {
|
|
|
|
struct rdt_resource *r;
|
|
|
|
struct rdt_mon_domain *d;
|
|
|
|
u32 evtid;
|
|
|
|
u32 mon_config;
|
|
|
|
};
|
|
|
|
|
2025-03-11 18:36:55 +00:00
|
|
|
/**
|
|
|
|
* resctrl_arch_sync_cpu_closid_rmid() - Refresh this CPU's CLOSID and RMID.
|
|
|
|
* Call via IPI.
|
|
|
|
* @info: If non-NULL, a pointer to a struct resctrl_cpu_defaults
|
|
|
|
* specifying the new CLOSID and RMID for tasks in the default
|
|
|
|
* resctrl ctrl and mon group when running on this CPU. If NULL,
|
|
|
|
* this CPU is not re-assigned to a different default group.
|
|
|
|
*
|
|
|
|
* Propagates reassignment of CPUs and/or tasks to different resctrl groups
|
|
|
|
* when requested by the resctrl core code.
|
|
|
|
*
|
|
|
|
* This function records the per-cpu defaults specified by @info (if any),
|
|
|
|
* and then reconfigures the CPU's hardware CLOSID and RMID for subsequent
|
|
|
|
* execution based on @current, in the same way as during a task switch.
|
|
|
|
*/
|
|
|
|
void resctrl_arch_sync_cpu_closid_rmid(void *info);
|
|
|
|
|
2025-03-11 18:36:53 +00:00
|
|
|
/**
|
|
|
|
* resctrl_get_default_ctrl() - Return the default control value for this
|
|
|
|
* resource.
|
|
|
|
* @r: The resource whose default control type is queried.
|
|
|
|
*/
|
|
|
|
static inline u32 resctrl_get_default_ctrl(struct rdt_resource *r)
|
|
|
|
{
|
|
|
|
switch (r->schema_fmt) {
|
|
|
|
case RESCTRL_SCHEMA_BITMAP:
|
|
|
|
return BIT_MASK(r->cache.cbm_len) - 1;
|
|
|
|
case RESCTRL_SCHEMA_RANGE:
|
|
|
|
return r->membw.max_bw;
|
|
|
|
}
|
|
|
|
|
|
|
|
return WARN_ON_ONCE(1);
|
|
|
|
}
|
|
|
|
|
2021-07-28 17:06:21 +00:00
|
|
|
/* The number of closid supported by this resource regardless of CDP */
|
|
|
|
u32 resctrl_arch_get_num_closid(struct rdt_resource *r);
|
2024-08-22 19:02:11 +00:00
|
|
|
u32 resctrl_arch_system_num_rmid_idx(void);
|
2021-07-28 17:06:28 +00:00
|
|
|
int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid);
|
2022-09-02 15:48:19 +00:00
|
|
|
|
2025-05-15 16:58:39 +00:00
|
|
|
bool resctrl_arch_is_evt_configurable(enum resctrl_event_id evt);
|
2025-03-11 18:37:04 +00:00
|
|
|
|
2025-03-11 18:37:05 +00:00
|
|
|
/**
|
|
|
|
* resctrl_arch_mon_event_config_write() - Write the config for an event.
|
|
|
|
* @config_info: struct resctrl_mon_config_info describing the resource, domain
|
|
|
|
* and event.
|
|
|
|
*
|
|
|
|
* Reads resource, domain and eventid from @config_info and writes the
|
|
|
|
* event config_info->mon_config into hardware.
|
|
|
|
*
|
|
|
|
* Called via IPI to reach a CPU that is a member of the specified domain.
|
|
|
|
*/
|
|
|
|
void resctrl_arch_mon_event_config_write(void *config_info);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* resctrl_arch_mon_event_config_read() - Read the config for an event.
|
|
|
|
* @config_info: struct resctrl_mon_config_info describing the resource, domain
|
|
|
|
* and event.
|
|
|
|
*
|
|
|
|
* Reads resource, domain and eventid from @config_info and reads the
|
|
|
|
* hardware config value into config_info->mon_config.
|
|
|
|
*
|
|
|
|
* Called via IPI to reach a CPU that is a member of the specified domain.
|
|
|
|
*/
|
|
|
|
void resctrl_arch_mon_event_config_read(void *config_info);
|
|
|
|
|
2025-03-11 18:37:14 +00:00
|
|
|
/* For use by arch code to remap resctrl's smaller CDP CLOSID range */
|
|
|
|
static inline u32 resctrl_get_config_index(u32 closid,
|
|
|
|
enum resctrl_conf_type type)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
default:
|
|
|
|
case CDP_NONE:
|
|
|
|
return closid;
|
|
|
|
case CDP_CODE:
|
|
|
|
return closid * 2 + 1;
|
|
|
|
case CDP_DATA:
|
|
|
|
return closid * 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-05-15 16:58:46 +00:00
|
|
|
bool resctrl_arch_get_cdp_enabled(enum resctrl_res_level l);
|
|
|
|
int resctrl_arch_set_cdp_enabled(enum resctrl_res_level l, bool enable);
|
|
|
|
|
2022-09-02 15:48:19 +00:00
|
|
|
/*
|
|
|
|
* Update the ctrl_val and apply this config right now.
|
|
|
|
* Must be called on one of the domain's CPUs.
|
|
|
|
*/
|
2024-06-28 21:56:04 +00:00
|
|
|
int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_ctrl_domain *d,
|
2022-09-02 15:48:19 +00:00
|
|
|
u32 closid, enum resctrl_conf_type t, u32 cfg_val);
|
|
|
|
|
2024-06-28 21:56:04 +00:00
|
|
|
u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_ctrl_domain *d,
|
2021-08-11 16:38:31 +00:00
|
|
|
u32 closid, enum resctrl_conf_type type);
|
2024-06-28 21:56:04 +00:00
|
|
|
int resctrl_online_ctrl_domain(struct rdt_resource *r, struct rdt_ctrl_domain *d);
|
|
|
|
int resctrl_online_mon_domain(struct rdt_resource *r, struct rdt_mon_domain *d);
|
|
|
|
void resctrl_offline_ctrl_domain(struct rdt_resource *r, struct rdt_ctrl_domain *d);
|
|
|
|
void resctrl_offline_mon_domain(struct rdt_resource *r, struct rdt_mon_domain *d);
|
2024-02-13 18:44:34 +00:00
|
|
|
void resctrl_online_cpu(unsigned int cpu);
|
2024-02-13 18:44:36 +00:00
|
|
|
void resctrl_offline_cpu(unsigned int cpu);
|
2022-09-02 15:48:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* resctrl_arch_rmid_read() - Read the eventid counter corresponding to rmid
|
|
|
|
* for this resource and domain.
|
|
|
|
* @r: resource that the counter should be read from.
|
|
|
|
* @d: domain that the counter should be read from.
|
2024-02-13 18:44:19 +00:00
|
|
|
* @closid: closid that matches the rmid. Depending on the architecture, the
|
|
|
|
* counter may match traffic of both @closid and @rmid, or @rmid
|
|
|
|
* only.
|
2022-09-02 15:48:24 +00:00
|
|
|
* @rmid: rmid of the counter to read.
|
|
|
|
* @eventid: eventid to read, e.g. L3 occupancy.
|
2022-09-02 15:48:29 +00:00
|
|
|
* @val: result of the counter read in bytes.
|
2024-02-13 18:44:29 +00:00
|
|
|
* @arch_mon_ctx: An architecture specific value from
|
|
|
|
* resctrl_arch_mon_ctx_alloc(), for MPAM this identifies
|
|
|
|
* the hardware monitor allocated for this read request.
|
2022-09-02 15:48:24 +00:00
|
|
|
*
|
x86/resctrl: Allow resctrl_arch_rmid_read() to sleep
MPAM's cache occupancy counters can take a little while to settle once the
monitor has been configured. The maximum settling time is described to the
driver via a firmware table. The value could be large enough that it makes
sense to sleep. To avoid exposing this to resctrl, it should be hidden behind
MPAM's resctrl_arch_rmid_read().
resctrl_arch_rmid_read() may be called via IPI meaning it is unable to sleep.
In this case, it should return an error if it needs to sleep. This will only
affect MPAM platforms where the cache occupancy counter isn't available
immediately, nohz_full is in use, and there are no housekeeping CPUs in the
necessary domain.
There are three callers of resctrl_arch_rmid_read(): __mon_event_count() and
__check_limbo() are both called from a non-migrateable context.
mon_event_read() invokes __mon_event_count() using smp_call_on_cpu(), which
adds work to the target CPUs workqueue. rdtgroup_mutex() is held, meaning this
cannot race with the resctrl cpuhp callback. __check_limbo() is invoked via
schedule_delayed_work_on() also adds work to a per-cpu workqueue.
The remaining call is add_rmid_to_limbo() which is called in response to
a user-space syscall that frees an RMID. This opportunistically reads the LLC
occupancy counter on the current domain to see if the RMID is over the dirty
threshold. This has to disable preemption to avoid reading the wrong domain's
value. Disabling preemption here prevents resctrl_arch_rmid_read() from
sleeping.
add_rmid_to_limbo() walks each domain, but only reads the counter on one
domain. If the system has more than one domain, the RMID will always be added
to the limbo list. If the RMIDs usage was not over the threshold, it will be
removed from the list when __check_limbo() runs. Make this the default
behaviour. Free RMIDs are always added to the limbo list for each domain.
The user visible effect of this is that a clean RMID is not available for
re-allocation immediately after 'rmdir()' completes. This behaviour was never
portable as it never happened on a machine with multiple domains.
Removing this path allows resctrl_arch_rmid_read() to sleep if its called with
interrupts unmasked. Document this is the expected behaviour, and add
a might_sleep() annotation to catch changes that won't work on arm64.
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Shaopeng Tan <tan.shaopeng@fujitsu.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Reviewed-by: Babu Moger <babu.moger@amd.com>
Tested-by: Shaopeng Tan <tan.shaopeng@fujitsu.com>
Tested-by: Peter Newman <peternewman@google.com>
Tested-by: Babu Moger <babu.moger@amd.com>
Tested-by: Carl Worth <carl@os.amperecomputing.com> # arm64
Link: https://lore.kernel.org/r/20240213184438.16675-15-james.morse@arm.com
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
2024-02-13 18:44:28 +00:00
|
|
|
* Some architectures need to sleep when first programming some of the counters.
|
|
|
|
* (specifically: arm64's MPAM cache occupancy counters can return 'not ready'
|
|
|
|
* for a short period of time). Call from a non-migrateable process context on
|
|
|
|
* a CPU that belongs to domain @d. e.g. use smp_call_on_cpu() or
|
|
|
|
* schedule_work_on(). This function can be called with interrupts masked,
|
|
|
|
* e.g. using smp_call_function_any(), but may consistently return an error.
|
2022-09-02 15:48:24 +00:00
|
|
|
*
|
|
|
|
* Return:
|
|
|
|
* 0 on success, or -EIO, -EINVAL etc on error.
|
|
|
|
*/
|
2024-06-28 21:56:04 +00:00
|
|
|
int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_mon_domain *d,
|
2024-02-13 18:44:19 +00:00
|
|
|
u32 closid, u32 rmid, enum resctrl_event_id eventid,
|
2024-02-13 18:44:29 +00:00
|
|
|
u64 *val, void *arch_mon_ctx);
|
2024-02-13 18:44:19 +00:00
|
|
|
|
x86/resctrl: Allow resctrl_arch_rmid_read() to sleep
MPAM's cache occupancy counters can take a little while to settle once the
monitor has been configured. The maximum settling time is described to the
driver via a firmware table. The value could be large enough that it makes
sense to sleep. To avoid exposing this to resctrl, it should be hidden behind
MPAM's resctrl_arch_rmid_read().
resctrl_arch_rmid_read() may be called via IPI meaning it is unable to sleep.
In this case, it should return an error if it needs to sleep. This will only
affect MPAM platforms where the cache occupancy counter isn't available
immediately, nohz_full is in use, and there are no housekeeping CPUs in the
necessary domain.
There are three callers of resctrl_arch_rmid_read(): __mon_event_count() and
__check_limbo() are both called from a non-migrateable context.
mon_event_read() invokes __mon_event_count() using smp_call_on_cpu(), which
adds work to the target CPUs workqueue. rdtgroup_mutex() is held, meaning this
cannot race with the resctrl cpuhp callback. __check_limbo() is invoked via
schedule_delayed_work_on() also adds work to a per-cpu workqueue.
The remaining call is add_rmid_to_limbo() which is called in response to
a user-space syscall that frees an RMID. This opportunistically reads the LLC
occupancy counter on the current domain to see if the RMID is over the dirty
threshold. This has to disable preemption to avoid reading the wrong domain's
value. Disabling preemption here prevents resctrl_arch_rmid_read() from
sleeping.
add_rmid_to_limbo() walks each domain, but only reads the counter on one
domain. If the system has more than one domain, the RMID will always be added
to the limbo list. If the RMIDs usage was not over the threshold, it will be
removed from the list when __check_limbo() runs. Make this the default
behaviour. Free RMIDs are always added to the limbo list for each domain.
The user visible effect of this is that a clean RMID is not available for
re-allocation immediately after 'rmdir()' completes. This behaviour was never
portable as it never happened on a machine with multiple domains.
Removing this path allows resctrl_arch_rmid_read() to sleep if its called with
interrupts unmasked. Document this is the expected behaviour, and add
a might_sleep() annotation to catch changes that won't work on arm64.
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Shaopeng Tan <tan.shaopeng@fujitsu.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Reviewed-by: Babu Moger <babu.moger@amd.com>
Tested-by: Shaopeng Tan <tan.shaopeng@fujitsu.com>
Tested-by: Peter Newman <peternewman@google.com>
Tested-by: Babu Moger <babu.moger@amd.com>
Tested-by: Carl Worth <carl@os.amperecomputing.com> # arm64
Link: https://lore.kernel.org/r/20240213184438.16675-15-james.morse@arm.com
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
2024-02-13 18:44:28 +00:00
|
|
|
/**
|
|
|
|
* resctrl_arch_rmid_read_context_check() - warn about invalid contexts
|
|
|
|
*
|
|
|
|
* When built with CONFIG_DEBUG_ATOMIC_SLEEP generate a warning when
|
|
|
|
* resctrl_arch_rmid_read() is called with preemption disabled.
|
|
|
|
*
|
|
|
|
* The contract with resctrl_arch_rmid_read() is that if interrupts
|
|
|
|
* are unmasked, it can sleep. This allows NOHZ_FULL systems to use an
|
|
|
|
* IPI, (and fail if the call needed to sleep), while most of the time
|
|
|
|
* the work is scheduled, allowing the call to sleep.
|
|
|
|
*/
|
|
|
|
static inline void resctrl_arch_rmid_read_context_check(void)
|
|
|
|
{
|
|
|
|
if (!irqs_disabled())
|
|
|
|
might_sleep();
|
|
|
|
}
|
2021-07-28 17:06:21 +00:00
|
|
|
|
2025-03-11 18:36:57 +00:00
|
|
|
/**
|
|
|
|
* resctrl_find_domain() - Search for a domain id in a resource domain list.
|
|
|
|
* @h: The domain list to search.
|
|
|
|
* @id: The domain id to search for.
|
|
|
|
* @pos: A pointer to position in the list id should be inserted.
|
|
|
|
*
|
|
|
|
* Search the domain list to find the domain id. If the domain id is
|
|
|
|
* found, return the domain. NULL otherwise. If the domain id is not
|
|
|
|
* found (and NULL returned) then the first domain with id bigger than
|
|
|
|
* the input id can be returned to the caller via @pos.
|
|
|
|
*/
|
|
|
|
struct rdt_domain_hdr *resctrl_find_domain(struct list_head *h, int id,
|
|
|
|
struct list_head **pos);
|
|
|
|
|
2022-09-02 15:48:22 +00:00
|
|
|
/**
|
|
|
|
* resctrl_arch_reset_rmid() - Reset any private state associated with rmid
|
|
|
|
* and eventid.
|
|
|
|
* @r: The domain's resource.
|
|
|
|
* @d: The rmid's domain.
|
2024-02-13 18:44:19 +00:00
|
|
|
* @closid: closid that matches the rmid. Depending on the architecture, the
|
|
|
|
* counter may match traffic of both @closid and @rmid, or @rmid only.
|
2022-09-02 15:48:22 +00:00
|
|
|
* @rmid: The rmid whose counter values should be reset.
|
|
|
|
* @eventid: The eventid whose counter values should be reset.
|
|
|
|
*
|
|
|
|
* This can be called from any CPU.
|
|
|
|
*/
|
2024-06-28 21:56:04 +00:00
|
|
|
void resctrl_arch_reset_rmid(struct rdt_resource *r, struct rdt_mon_domain *d,
|
2024-02-13 18:44:19 +00:00
|
|
|
u32 closid, u32 rmid,
|
|
|
|
enum resctrl_event_id eventid);
|
2022-09-02 15:48:22 +00:00
|
|
|
|
2023-01-13 15:20:37 +00:00
|
|
|
/**
|
|
|
|
* resctrl_arch_reset_rmid_all() - Reset all private state associated with
|
|
|
|
* all rmids and eventids.
|
|
|
|
* @r: The resctrl resource.
|
|
|
|
* @d: The domain for which all architectural counter state will
|
|
|
|
* be cleared.
|
|
|
|
*
|
|
|
|
* This can be called from any CPU.
|
|
|
|
*/
|
2024-06-28 21:56:04 +00:00
|
|
|
void resctrl_arch_reset_rmid_all(struct rdt_resource *r, struct rdt_mon_domain *d);
|
2023-01-13 15:20:37 +00:00
|
|
|
|
2025-03-11 18:36:59 +00:00
|
|
|
/**
|
|
|
|
* resctrl_arch_reset_all_ctrls() - Reset the control for each CLOSID to its
|
|
|
|
* default.
|
|
|
|
* @r: The resctrl resource to reset.
|
|
|
|
*
|
|
|
|
* This can be called from any CPU.
|
|
|
|
*/
|
|
|
|
void resctrl_arch_reset_all_ctrls(struct rdt_resource *r);
|
|
|
|
|
2022-09-02 15:48:27 +00:00
|
|
|
extern unsigned int resctrl_rmid_realloc_threshold;
|
2022-09-02 15:48:28 +00:00
|
|
|
extern unsigned int resctrl_rmid_realloc_limit;
|
2022-09-02 15:48:27 +00:00
|
|
|
|
2025-05-15 16:58:39 +00:00
|
|
|
int resctrl_init(void);
|
|
|
|
void resctrl_exit(void);
|
2025-03-11 18:36:56 +00:00
|
|
|
|
2025-05-15 16:58:49 +00:00
|
|
|
#ifdef CONFIG_RESCTRL_FS_PSEUDO_LOCK
|
|
|
|
u64 resctrl_arch_get_prefetch_disable_bits(void);
|
|
|
|
int resctrl_arch_pseudo_lock_fn(void *_plr);
|
|
|
|
int resctrl_arch_measure_cycles_lat_fn(void *_plr);
|
|
|
|
int resctrl_arch_measure_l2_residency(void *_plr);
|
|
|
|
int resctrl_arch_measure_l3_residency(void *_plr);
|
|
|
|
#else
|
|
|
|
static inline u64 resctrl_arch_get_prefetch_disable_bits(void) { return 0; }
|
|
|
|
static inline int resctrl_arch_pseudo_lock_fn(void *_plr) { return 0; }
|
|
|
|
static inline int resctrl_arch_measure_cycles_lat_fn(void *_plr) { return 0; }
|
|
|
|
static inline int resctrl_arch_measure_l2_residency(void *_plr) { return 0; }
|
|
|
|
static inline int resctrl_arch_measure_l3_residency(void *_plr) { return 0; }
|
|
|
|
#endif /* CONFIG_RESCTRL_FS_PSEUDO_LOCK */
|
2020-01-15 09:28:51 +00:00
|
|
|
#endif /* _RESCTRL_H */
|