arch/sparc/mm/init_64.c
Source file repositories/reference/linux-study-clean/arch/sparc/mm/init_64.c
File Facts
- System
- Linux kernel
- Corpus path
arch/sparc/mm/init_64.c- Extension
.c- Size
- 77676 bytes
- Lines
- 3150
- Domain
- Architecture Layer
- Bucket
- arch/sparc
- Inferred role
- Architecture Layer: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/extable.hlinux/kernel.hlinux/sched.hlinux/string.hlinux/init.hlinux/memblock.hlinux/mm.hlinux/hugetlb.hlinux/initrd.hlinux/swap.hlinux/pagemap.hlinux/poison.hlinux/fs.hlinux/seq_file.hlinux/kprobes.hlinux/cache.hlinux/sort.hlinux/ioport.hlinux/percpu.hlinux/mmzone.hlinux/gfp.hasm/head.hasm/page.hasm/pgalloc.hasm/oplib.hasm/iommu.hasm/io.hlinux/uaccess.hasm/mmu_context.hasm/tlbflush.hasm/dma.hasm/starfire.h
Detected Declarations
struct node_mem_maskstruct mdesc_mlgroupstruct mdesc_mblockfunction cmp_p64function read_obp_memoryfunction flush_dcache_folio_implfunction set_dcache_dirtyfunction clear_dcache_dirty_cpufunction tsb_insertfunction flush_dcachefunction __update_mmu_tsb_insertfunction hugetlbpage_initfunction pud_huge_patchfunction arch_hugetlb_valid_sizefunction update_mmu_cache_rangefunction flush_dcache_foliofunction flush_icache_rangefunction mmu_infofunction in_obp_rangefunction cmp_ptransfunction read_obp_translationsfunction hypervisor_tlb_lockfunction remap_kernelfunction inherit_prom_mappingsfunction prom_worldfunction __flush_dcache_rangefunction mmu_context_wrapfunction CTX_VALIDfunction early_numafunction find_ramdiskfunction addr_to_mblockfunction memblock_nid_range_sun4ufunction memblock_nid_rangefunction memblock_set_nodefunction init_node_masks_nonnumafunction scan_pio_for_cfg_handlefunction mdesc_for_each_arcfunction scan_arcs_for_cfg_handlefunction of_node_to_nidfunction add_node_rangesfunction for_each_mem_rangefunction grab_mlgroupsfunction grab_mblocksfunction numa_parse_mdesc_group_cpusfunction mdesc_for_each_arcfunction find_mlgroupfunction __node_distancefunction find_best_numa_node_for_mlgroup
Annotated Snippet
struct node_mem_mask {
unsigned long mask;
unsigned long match;
};
static struct node_mem_mask node_masks[MAX_NUMNODES];
static int num_node_masks;
#ifdef CONFIG_NUMA
struct mdesc_mlgroup {
u64 node;
u64 latency;
u64 match;
u64 mask;
};
static struct mdesc_mlgroup *mlgroups;
static int num_mlgroups;
int numa_cpu_lookup_table[NR_CPUS];
cpumask_t numa_cpumask_lookup_table[MAX_NUMNODES];
struct mdesc_mblock {
u64 base;
u64 size;
u64 offset; /* RA-to-PA */
};
static struct mdesc_mblock *mblocks;
static int num_mblocks;
static struct mdesc_mblock * __init addr_to_mblock(unsigned long addr)
{
struct mdesc_mblock *m = NULL;
int i;
for (i = 0; i < num_mblocks; i++) {
m = &mblocks[i];
if (addr >= m->base &&
addr < (m->base + m->size)) {
break;
}
}
return m;
}
static u64 __init memblock_nid_range_sun4u(u64 start, u64 end, int *nid)
{
int prev_nid, new_nid;
prev_nid = NUMA_NO_NODE;
for ( ; start < end; start += PAGE_SIZE) {
for (new_nid = 0; new_nid < num_node_masks; new_nid++) {
struct node_mem_mask *p = &node_masks[new_nid];
if ((start & p->mask) == p->match) {
if (prev_nid == NUMA_NO_NODE)
prev_nid = new_nid;
break;
}
}
if (new_nid == num_node_masks) {
prev_nid = 0;
WARN_ONCE(1, "addr[%Lx] doesn't match a NUMA node rule. Some memory will be owned by node 0.",
start);
break;
}
if (prev_nid != new_nid)
break;
}
*nid = prev_nid;
return start > end ? end : start;
}
static u64 __init memblock_nid_range(u64 start, u64 end, int *nid)
{
u64 ret_end, pa_start, m_mask, m_match, m_end;
struct mdesc_mblock *mblock;
int _nid, i;
if (tlb_type != hypervisor)
return memblock_nid_range_sun4u(start, end, nid);
mblock = addr_to_mblock(start);
if (!mblock) {
WARN_ONCE(1, "memblock_nid_range: Can't find mblock addr[%Lx]",
Annotation
- Immediate include surface: `linux/extable.h`, `linux/kernel.h`, `linux/sched.h`, `linux/string.h`, `linux/init.h`, `linux/memblock.h`, `linux/mm.h`, `linux/hugetlb.h`.
- Detected declarations: `struct node_mem_mask`, `struct mdesc_mlgroup`, `struct mdesc_mblock`, `function cmp_p64`, `function read_obp_memory`, `function flush_dcache_folio_impl`, `function set_dcache_dirty`, `function clear_dcache_dirty_cpu`, `function tsb_insert`, `function flush_dcache`.
- Atlas domain: Architecture Layer / arch/sparc.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.