2020-01-15 12:28:51 +03:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
#ifndef _RESCTRL_H
|
|
|
|
#define _RESCTRL_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 20:06:14 +03:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/list.h>
|
2020-07-08 19:39:24 +03:00
|
|
|
#include <linux/pid.h>
|
|
|
|
|
2020-01-15 12:28:51 +03: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
|
|
|
|
|
2021-07-28 20:06:18 +03: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 20:06:27 +03:00
|
|
|
#define CDP_NUM_TYPES (CDP_DATA + 1)
|
|
|
|
|
2021-07-28 20:06:26 +03: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;
|
|
|
|
};
|
|
|
|
|
2021-07-28 20:06:15 +03:00
|
|
|
/**
|
|
|
|
* struct rdt_domain - group of CPUs sharing a resctrl resource
|
|
|
|
* @list: all instances of this resource
|
|
|
|
* @id: unique id for this instance
|
|
|
|
* @cpu_mask: which CPUs share this resource
|
|
|
|
* @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
|
|
|
|
* @plr: pseudo-locked region (if any) associated with domain
|
2021-07-28 20:06:26 +03:00
|
|
|
* @staged_config: parsed configuration to be applied
|
2021-07-28 20:06:15 +03:00
|
|
|
*/
|
|
|
|
struct rdt_domain {
|
|
|
|
struct list_head list;
|
|
|
|
int id;
|
|
|
|
struct cpumask cpu_mask;
|
|
|
|
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;
|
|
|
|
struct pseudo_lock_region *plr;
|
2021-07-28 20:06:27 +03:00
|
|
|
struct resctrl_staged_config staged_config[CDP_NUM_TYPES];
|
2021-07-28 20:06:15 +03:00
|
|
|
};
|
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 20:06:14 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* struct resctrl_cache - Cache allocation related data
|
|
|
|
* @cbm_len: Length of the cache bit mask
|
|
|
|
* @min_cbm_bits: Minimum number of consecutive bits to be set
|
|
|
|
* @cbm_idx_mult: Multiplier of CBM index
|
|
|
|
* @cbm_idx_offset: Offset of CBM index. CBM index is computed by:
|
|
|
|
* closid * cbm_idx_multi + cbm_idx_offset
|
|
|
|
* in a cache bit mask
|
|
|
|
* @shareable_bits: Bitmask of shareable resource with other
|
|
|
|
* executing entities
|
|
|
|
* @arch_has_sparse_bitmaps: True if a bitmap like f00f is valid.
|
|
|
|
* @arch_has_empty_bitmaps: True if the '0' bitmap is valid.
|
|
|
|
* @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 cbm_idx_mult; // TODO remove this
|
|
|
|
unsigned int cbm_idx_offset; // TODO remove this
|
|
|
|
unsigned int shareable_bits;
|
|
|
|
bool arch_has_sparse_bitmaps;
|
|
|
|
bool arch_has_empty_bitmaps;
|
|
|
|
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
|
|
|
|
* @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;
|
|
|
|
u32 bw_gran;
|
|
|
|
u32 delay_linear;
|
|
|
|
bool arch_needs_linear;
|
|
|
|
enum membw_throttle_mode throttle_mode;
|
|
|
|
bool mba_sc;
|
|
|
|
u32 *mb_map;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct rdt_parse_data;
|
2021-07-28 20:06:22 +03: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 20:06:14 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* struct rdt_resource - attributes of a resctrl resource
|
|
|
|
* @rid: The index of the resource
|
|
|
|
* @alloc_enabled: Is allocation enabled on this machine
|
|
|
|
* @mon_enabled: Is monitoring enabled for this feature
|
|
|
|
* @alloc_capable: Is allocation available on this machine
|
|
|
|
* @mon_capable: Is monitor feature available on this machine
|
|
|
|
* @num_rmid: Number of RMIDs available
|
|
|
|
* @cache_level: Which cache level defines scope of this resource
|
|
|
|
* @cache: Cache allocation related data
|
|
|
|
* @membw: If the component has bandwidth controls, their properties.
|
|
|
|
* @domains: All domains for this resource
|
|
|
|
* @name: Name to use in "schemata" file.
|
|
|
|
* @data_width: Character width of data when displaying
|
|
|
|
* @default_ctrl: Specifies default cache cbm or memory B/W percent.
|
|
|
|
* @format_str: Per resource format string to show domain value
|
|
|
|
* @parse_ctrlval: Per resource function pointer to parse control values
|
|
|
|
* @evt_list: List of monitoring events
|
|
|
|
* @fflags: flags to choose base and info files
|
2021-07-28 20:06:24 +03: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 20:06:14 +03:00
|
|
|
*/
|
|
|
|
struct rdt_resource {
|
|
|
|
int rid;
|
|
|
|
bool alloc_enabled;
|
|
|
|
bool mon_enabled;
|
|
|
|
bool alloc_capable;
|
|
|
|
bool mon_capable;
|
|
|
|
int num_rmid;
|
|
|
|
int cache_level;
|
|
|
|
struct resctrl_cache cache;
|
|
|
|
struct resctrl_membw membw;
|
|
|
|
struct list_head domains;
|
|
|
|
char *name;
|
|
|
|
int data_width;
|
|
|
|
u32 default_ctrl;
|
|
|
|
const char *format_str;
|
|
|
|
int (*parse_ctrlval)(struct rdt_parse_data *data,
|
2021-07-28 20:06:22 +03:00
|
|
|
struct resctrl_schema *s,
|
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 20:06:14 +03:00
|
|
|
struct rdt_domain *d);
|
|
|
|
struct list_head evt_list;
|
|
|
|
unsigned long fflags;
|
2021-07-28 20:06:24 +03: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 20:06:14 +03:00
|
|
|
};
|
|
|
|
|
2021-07-28 20:06:16 +03:00
|
|
|
/**
|
|
|
|
* struct resctrl_schema - configuration abilities of a resource presented to
|
|
|
|
* user-space
|
|
|
|
* @list: Member of resctrl_schema_all.
|
2021-07-28 20:06:25 +03:00
|
|
|
* @name: The name to use in the "schemata" file.
|
2021-07-28 20:06:18 +03:00
|
|
|
* @conf_type: Whether this schema is specific to code/data.
|
2021-07-28 20:06:16 +03:00
|
|
|
* @res: The resource structure exported by the architecture to describe
|
|
|
|
* the hardware that is configured by this schema.
|
2021-07-28 20:06:20 +03: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 20:06:16 +03:00
|
|
|
*/
|
|
|
|
struct resctrl_schema {
|
|
|
|
struct list_head list;
|
2021-07-28 20:06:25 +03:00
|
|
|
char name[8];
|
2021-07-28 20:06:18 +03:00
|
|
|
enum resctrl_conf_type conf_type;
|
2021-07-28 20:06:16 +03:00
|
|
|
struct rdt_resource *res;
|
2021-07-28 20:06:21 +03:00
|
|
|
u32 num_closid;
|
2021-07-28 20:06:16 +03:00
|
|
|
};
|
2021-07-28 20:06:21 +03:00
|
|
|
|
|
|
|
/* The number of closid supported by this resource regardless of CDP */
|
|
|
|
u32 resctrl_arch_get_num_closid(struct rdt_resource *r);
|
|
|
|
|
2020-01-15 12:28:51 +03:00
|
|
|
#endif /* _RESCTRL_H */
|