mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-15 18:56:46 +07:00
eb254f323b
Pull x86 cache allocation interface from Thomas Gleixner: "This provides support for Intel's Cache Allocation Technology, a cache partitioning mechanism. The interface is odd, but the hardware interface of that CAT stuff is odd as well. We tried hard to come up with an abstraction, but that only allows rather simple partitioning, but no way of sharing and dealing with the per package nature of this mechanism. In the end we decided to expose the allocation bitmaps directly so all combinations of the hardware can be utilized. There are two ways of associating a cache partition: - Task A task can be added to a resource group. It uses the cache partition associated to the group. - CPU All tasks which are not member of a resource group use the group to which the CPU they are running on is associated with. That allows for simple CPU based partitioning schemes. The main expected user sare: - Virtualization so a VM can only trash only the associated part of the cash w/o disturbing others - Real-Time systems to seperate RT and general workloads. - Latency sensitive enterprise workloads - In theory this also can be used to protect against cache side channel attacks" [ Intel RDT is "Resource Director Technology". The interface really is rather odd and very specific, which delayed this pull request while I was thinking about it. The pull request itself came in early during the merge window, I just delayed it until things had calmed down and I had more time. But people tell me they'll use this, and the good news is that it is _so_ specific that it's rather independent of anything else, and no user is going to depend on the interface since it's pretty rare. So if push comes to shove, we can just remove the interface and nothing will break ] * 'x86-cache-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (31 commits) x86/intel_rdt: Implement show_options() for resctrlfs x86/intel_rdt: Call intel_rdt_sched_in() with preemption disabled x86/intel_rdt: Update task closid immediately on CPU in rmdir and unmount x86/intel_rdt: Fix setting of closid when adding CPUs to a group x86/intel_rdt: Update percpu closid immeditately on CPUs affected by changee x86/intel_rdt: Reset per cpu closids on unmount x86/intel_rdt: Select KERNFS when enabling INTEL_RDT_A x86/intel_rdt: Prevent deadlock against hotplug lock x86/intel_rdt: Protect info directory from removal x86/intel_rdt: Add info files to Documentation x86/intel_rdt: Export the minimum number of set mask bits in sysfs x86/intel_rdt: Propagate error in rdt_mount() properly x86/intel_rdt: Add a missing #include MAINTAINERS: Add maintainer for Intel RDT resource allocation x86/intel_rdt: Add scheduler hook x86/intel_rdt: Add schemata file x86/intel_rdt: Add tasks files x86/intel_rdt: Add cpus file x86/intel_rdt: Add mkdir to resctrl file system x86/intel_rdt: Add "info" files to resctrl file system ...
105 lines
3.2 KiB
C
105 lines
3.2 KiB
C
#ifndef _LINUX_CACHEINFO_H
|
|
#define _LINUX_CACHEINFO_H
|
|
|
|
#include <linux/bitops.h>
|
|
#include <linux/cpumask.h>
|
|
#include <linux/smp.h>
|
|
|
|
struct device_node;
|
|
struct attribute;
|
|
|
|
enum cache_type {
|
|
CACHE_TYPE_NOCACHE = 0,
|
|
CACHE_TYPE_INST = BIT(0),
|
|
CACHE_TYPE_DATA = BIT(1),
|
|
CACHE_TYPE_SEPARATE = CACHE_TYPE_INST | CACHE_TYPE_DATA,
|
|
CACHE_TYPE_UNIFIED = BIT(2),
|
|
};
|
|
|
|
/**
|
|
* struct cacheinfo - represent a cache leaf node
|
|
* @id: This cache's id. It is unique among caches with the same (type, level).
|
|
* @type: type of the cache - data, inst or unified
|
|
* @level: represents the hierarchy in the multi-level cache
|
|
* @coherency_line_size: size of each cache line usually representing
|
|
* the minimum amount of data that gets transferred from memory
|
|
* @number_of_sets: total number of sets, a set is a collection of cache
|
|
* lines sharing the same index
|
|
* @ways_of_associativity: number of ways in which a particular memory
|
|
* block can be placed in the cache
|
|
* @physical_line_partition: number of physical cache lines sharing the
|
|
* same cachetag
|
|
* @size: Total size of the cache
|
|
* @shared_cpu_map: logical cpumask representing all the cpus sharing
|
|
* this cache node
|
|
* @attributes: bitfield representing various cache attributes
|
|
* @of_node: if devicetree is used, this represents either the cpu node in
|
|
* case there's no explicit cache node or the cache node itself in the
|
|
* device tree
|
|
* @disable_sysfs: indicates whether this node is visible to the user via
|
|
* sysfs or not
|
|
* @priv: pointer to any private data structure specific to particular
|
|
* cache design
|
|
*
|
|
* While @of_node, @disable_sysfs and @priv are used for internal book
|
|
* keeping, the remaining members form the core properties of the cache
|
|
*/
|
|
struct cacheinfo {
|
|
unsigned int id;
|
|
enum cache_type type;
|
|
unsigned int level;
|
|
unsigned int coherency_line_size;
|
|
unsigned int number_of_sets;
|
|
unsigned int ways_of_associativity;
|
|
unsigned int physical_line_partition;
|
|
unsigned int size;
|
|
cpumask_t shared_cpu_map;
|
|
unsigned int attributes;
|
|
#define CACHE_WRITE_THROUGH BIT(0)
|
|
#define CACHE_WRITE_BACK BIT(1)
|
|
#define CACHE_WRITE_POLICY_MASK \
|
|
(CACHE_WRITE_THROUGH | CACHE_WRITE_BACK)
|
|
#define CACHE_READ_ALLOCATE BIT(2)
|
|
#define CACHE_WRITE_ALLOCATE BIT(3)
|
|
#define CACHE_ALLOCATE_POLICY_MASK \
|
|
(CACHE_READ_ALLOCATE | CACHE_WRITE_ALLOCATE)
|
|
#define CACHE_ID BIT(4)
|
|
|
|
struct device_node *of_node;
|
|
bool disable_sysfs;
|
|
void *priv;
|
|
};
|
|
|
|
struct cpu_cacheinfo {
|
|
struct cacheinfo *info_list;
|
|
unsigned int num_levels;
|
|
unsigned int num_leaves;
|
|
bool cpu_map_populated;
|
|
};
|
|
|
|
/*
|
|
* Helpers to make sure "func" is executed on the cpu whose cache
|
|
* attributes are being detected
|
|
*/
|
|
#define DEFINE_SMP_CALL_CACHE_FUNCTION(func) \
|
|
static inline void _##func(void *ret) \
|
|
{ \
|
|
int cpu = smp_processor_id(); \
|
|
*(int *)ret = __##func(cpu); \
|
|
} \
|
|
\
|
|
int func(unsigned int cpu) \
|
|
{ \
|
|
int ret; \
|
|
smp_call_function_single(cpu, _##func, &ret, true); \
|
|
return ret; \
|
|
}
|
|
|
|
struct cpu_cacheinfo *get_cpu_cacheinfo(unsigned int cpu);
|
|
int init_cache_level(unsigned int cpu);
|
|
int populate_cache_leaves(unsigned int cpu);
|
|
|
|
const struct attribute_group *cache_get_priv_group(struct cacheinfo *this_leaf);
|
|
|
|
#endif /* _LINUX_CACHEINFO_H */
|