arch/powerpc/mm/nohash/tlb.c
Source file repositories/reference/linux-study-clean/arch/powerpc/mm/nohash/tlb.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/mm/nohash/tlb.c- Extension
.c- Size
- 8073 bytes
- Lines
- 342
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/export.hlinux/mm.hlinux/init.hlinux/highmem.hlinux/pagemap.hlinux/preempt.hlinux/spinlock.hlinux/memblock.hlinux/of_fdt.hlinux/hugetlb.hasm/pgalloc.hasm/tlbflush.hasm/tlb.hasm/text-patching.hasm/cputhreads.hasm/hugetlb.hasm/paca.hmm/mmu_decl.h
Detected Declarations
struct tlb_flush_paramfunction mmu_get_tsizefunction mmu_get_tsizefunction local_flush_tlb_mmfunction __local_flush_tlb_pagefunction local_flush_tlb_pagefunction local_flush_tlb_page_psizefunction do_flush_tlb_mm_ipifunction do_flush_tlb_page_ipifunction flush_tlb_mmfunction __flush_tlb_pagefunction flush_tlb_pagefunction flush_tlb_kernel_rangefunction flush_tlb_rangefunction tlb_flushfunction early_init_mmuexport local_flush_tlb_mmexport local_flush_tlb_pageexport local_flush_tlb_page_psizeexport flush_tlb_mmexport flush_tlb_pageexport flush_tlb_kernel_rangeexport flush_tlb_range
Annotated Snippet
struct tlb_flush_param {
unsigned long addr;
unsigned int pid;
unsigned int tsize;
unsigned int ind;
};
static void do_flush_tlb_mm_ipi(void *param)
{
struct tlb_flush_param *p = param;
_tlbil_pid(p ? p->pid : 0);
}
static void do_flush_tlb_page_ipi(void *param)
{
struct tlb_flush_param *p = param;
_tlbil_va(p->addr, p->pid, p->tsize, p->ind);
}
/* Note on invalidations and PID:
*
* We snapshot the PID with preempt disabled. At this point, it can still
* change either because:
* - our context is being stolen (PID -> NO_CONTEXT) on another CPU
* - we are invaliating some target that isn't currently running here
* and is concurrently acquiring a new PID on another CPU
* - some other CPU is re-acquiring a lost PID for this mm
* etc...
*
* However, this shouldn't be a problem as we only guarantee
* invalidation of TLB entries present prior to this call, so we
* don't care about the PID changing, and invalidating a stale PID
* is generally harmless.
*/
void flush_tlb_mm(struct mm_struct *mm)
{
unsigned int pid;
preempt_disable();
pid = mm->context.id;
if (unlikely(pid == MMU_NO_CONTEXT))
goto no_context;
if (!mm_is_core_local(mm)) {
struct tlb_flush_param p = { .pid = pid };
/* Ignores smp_processor_id() even if set. */
smp_call_function_many(mm_cpumask(mm),
do_flush_tlb_mm_ipi, &p, 1);
}
_tlbil_pid(pid);
no_context:
preempt_enable();
}
EXPORT_SYMBOL(flush_tlb_mm);
void __flush_tlb_page(struct mm_struct *mm, unsigned long vmaddr,
int tsize, int ind)
{
struct cpumask *cpu_mask;
unsigned int pid;
/*
* This function as well as __local_flush_tlb_page() must only be called
* for user contexts.
*/
if (WARN_ON(!mm))
return;
preempt_disable();
pid = mm->context.id;
if (unlikely(pid == MMU_NO_CONTEXT))
goto bail;
cpu_mask = mm_cpumask(mm);
if (!mm_is_core_local(mm)) {
/* If broadcast tlbivax is supported, use it */
if (mmu_has_feature(MMU_FTR_USE_TLBIVAX_BCAST)) {
int lock = mmu_has_feature(MMU_FTR_LOCK_BCAST_INVAL);
if (lock)
raw_spin_lock(&tlbivax_lock);
_tlbivax_bcast(vmaddr, pid, tsize, ind);
if (lock)
raw_spin_unlock(&tlbivax_lock);
goto bail;
} else {
struct tlb_flush_param p = {
.pid = pid,
.addr = vmaddr,
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/export.h`, `linux/mm.h`, `linux/init.h`, `linux/highmem.h`, `linux/pagemap.h`, `linux/preempt.h`, `linux/spinlock.h`.
- Detected declarations: `struct tlb_flush_param`, `function mmu_get_tsize`, `function mmu_get_tsize`, `function local_flush_tlb_mm`, `function __local_flush_tlb_page`, `function local_flush_tlb_page`, `function local_flush_tlb_page_psize`, `function do_flush_tlb_mm_ipi`, `function do_flush_tlb_page_ipi`, `function flush_tlb_mm`.
- Atlas domain: Architecture Layer / arch/powerpc.
- 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.