arch/powerpc/kernel/cacheinfo.c
Source file repositories/reference/linux-study-clean/arch/powerpc/kernel/cacheinfo.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/kernel/cacheinfo.c- Extension
.c- Size
- 24160 bytes
- Lines
- 955
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/cpu.hlinux/cpumask.hlinux/kernel.hlinux/kobject.hlinux/list.hlinux/notifier.hlinux/of.hlinux/percpu.hlinux/slab.hlinux/sysfs.hasm/cputhreads.hasm/smp.hcacheinfo.h
Detected Declarations
struct cache_dirstruct cache_index_dirstruct cache_type_infostruct cachefunction cache_initfunction release_cache_debugcheckfunction release_cachefunction cache_cpu_setfunction cache_sizefunction cache_size_kbfunction cache_get_line_sizefunction cache_nr_setsfunction cache_associativityfunction list_for_each_entryfunction cache_node_is_unifiedfunction cache_is_unified_dfunction link_cache_listsfunction do_subsidiary_caches_debugcheckfunction get_group_idfunction do_subsidiary_cachesfunction cache_index_releasefunction cache_index_showfunction size_showfunction line_size_showfunction nr_sets_showfunction associativity_showfunction type_showfunction level_showfunction show_shared_cpumapfunction shared_cpu_map_showfunction shared_cpu_list_showfunction cacheinfo_create_index_opt_attrsfunction cacheinfo_create_index_dirfunction cacheinfo_sysfs_populatefunction cacheinfo_cpu_onlinefunction definedfunction remove_index_dirsfunction remove_cache_dirfunction cache_cpu_clearfunction cacheinfo_cpu_offlinefunction cacheinfo_teardownfunction cacheinfo_rebuild
Annotated Snippet
struct cache_dir {
struct kobject *kobj; /* bare (not embedded) kobject for cache
* directory */
struct cache_index_dir *index; /* list of index objects */
};
/* "index" object: each cpu's cache directory has an index
* subdirectory corresponding to a cache object associated with the
* cpu. This object's lifetime is managed via the embedded kobject.
*/
struct cache_index_dir {
struct kobject kobj;
struct cache_index_dir *next; /* next index in parent directory */
struct cache *cache;
};
/* Template for determining which OF properties to query for a given
* cache type */
struct cache_type_info {
const char *name;
const char *size_prop;
/* Allow for both [di]-cache-line-size and
* [di]-cache-block-size properties. According to the PowerPC
* Processor binding, -line-size should be provided if it
* differs from the cache block size (that which is operated
* on by cache instructions), so we look for -line-size first.
* See cache_get_line_size(). */
const char *line_size_props[2];
const char *nr_sets_prop;
};
/* These are used to index the cache_type_info array. */
#define CACHE_TYPE_UNIFIED 0 /* cache-size, cache-block-size, etc. */
#define CACHE_TYPE_UNIFIED_D 1 /* d-cache-size, d-cache-block-size, etc */
#define CACHE_TYPE_INSTRUCTION 2
#define CACHE_TYPE_DATA 3
static const struct cache_type_info cache_type_info[] = {
{
/* Embedded systems that use cache-size, cache-block-size,
* etc. for the Unified (typically L2) cache. */
.name = "Unified",
.size_prop = "cache-size",
.line_size_props = { "cache-line-size",
"cache-block-size", },
.nr_sets_prop = "cache-sets",
},
{
/* PowerPC Processor binding says the [di]-cache-*
* must be equal on unified caches, so just use
* d-cache properties. */
.name = "Unified",
.size_prop = "d-cache-size",
.line_size_props = { "d-cache-line-size",
"d-cache-block-size", },
.nr_sets_prop = "d-cache-sets",
},
{
.name = "Instruction",
.size_prop = "i-cache-size",
.line_size_props = { "i-cache-line-size",
"i-cache-block-size", },
.nr_sets_prop = "i-cache-sets",
},
{
.name = "Data",
.size_prop = "d-cache-size",
.line_size_props = { "d-cache-line-size",
"d-cache-block-size", },
.nr_sets_prop = "d-cache-sets",
},
};
/* Cache object: each instance of this corresponds to a distinct cache
* in the system. There are separate objects for Harvard caches: one
* each for instruction and data, and each refers to the same OF node.
* The refcount of the OF node is elevated for the lifetime of the
* cache object. A cache object is released when its shared_cpu_map
* is cleared (see cache_cpu_clear).
*
* A cache object is on two lists: an unsorted global list
* (cache_list) of cache objects; and a singly-linked list
* representing the local cache hierarchy, which is ordered by level
* (e.g. L1d -> L1i -> L2 -> L3).
*/
struct cache {
struct device_node *ofnode; /* OF node for this cache, may be cpu */
struct cpumask shared_cpu_map; /* online CPUs using this cache */
Annotation
- Immediate include surface: `linux/cpu.h`, `linux/cpumask.h`, `linux/kernel.h`, `linux/kobject.h`, `linux/list.h`, `linux/notifier.h`, `linux/of.h`, `linux/percpu.h`.
- Detected declarations: `struct cache_dir`, `struct cache_index_dir`, `struct cache_type_info`, `struct cache`, `function cache_init`, `function release_cache_debugcheck`, `function release_cache`, `function cache_cpu_set`, `function cache_size`, `function cache_size_kb`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.