arch/sparc/mm/tlb.c
Source file repositories/reference/linux-study-clean/arch/sparc/mm/tlb.c
File Facts
- System
- Linux kernel
- Corpus path
arch/sparc/mm/tlb.c- Extension
.c- Size
- 6952 bytes
- Lines
- 315
- 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/kernel.hlinux/percpu.hlinux/mm.hlinux/swap.hlinux/preempt.hlinux/pagemap.hkunit/visibility.hasm/tlbflush.hasm/cacheflush.hasm/mmu_context.hasm/tlb.h
Detected Declarations
function flush_tlb_pendingfunction arch_enter_lazy_mmu_modefunction arch_flush_lazy_mmu_modefunction arch_leave_lazy_mmu_modefunction tlb_batch_add_onefunction tlb_batch_addfunction tlb_batch_pmd_scanfunction __set_pmd_acctfunction set_pmd_atfunction pmdp_establishfunction pmdp_invalidatefunction pgtable_trans_huge_depositfunction pgtable_trans_huge_withdraw
Annotated Snippet
if (tb->tlb_nr == 1) {
global_flush_tlb_page(mm, tb->vaddrs[0]);
} else {
#ifdef CONFIG_SMP
smp_flush_tlb_pending(tb->mm, tb->tlb_nr,
&tb->vaddrs[0]);
#else
__flush_tlb_pending(CTX_HWBITS(tb->mm->context),
tb->tlb_nr, &tb->vaddrs[0]);
#endif
}
}
tb->tlb_nr = 0;
out:
put_cpu_var(tlb_batch);
}
void arch_enter_lazy_mmu_mode(void)
{
preempt_disable();
}
/* For lazy_mmu_mode KUnit tests */
EXPORT_SYMBOL_IF_KUNIT(arch_enter_lazy_mmu_mode);
void arch_flush_lazy_mmu_mode(void)
{
struct tlb_batch *tb = this_cpu_ptr(&tlb_batch);
if (tb->tlb_nr)
flush_tlb_pending();
}
EXPORT_SYMBOL_IF_KUNIT(arch_flush_lazy_mmu_mode);
void arch_leave_lazy_mmu_mode(void)
{
arch_flush_lazy_mmu_mode();
preempt_enable();
}
EXPORT_SYMBOL_IF_KUNIT(arch_leave_lazy_mmu_mode);
static void tlb_batch_add_one(struct mm_struct *mm, unsigned long vaddr,
bool exec, unsigned int hugepage_shift)
{
struct tlb_batch *tb = &get_cpu_var(tlb_batch);
unsigned long nr;
vaddr &= PAGE_MASK;
if (exec)
vaddr |= 0x1UL;
nr = tb->tlb_nr;
if (unlikely(nr != 0 && mm != tb->mm)) {
flush_tlb_pending();
nr = 0;
}
if (!is_lazy_mmu_mode_active()) {
flush_tsb_user_page(mm, vaddr, hugepage_shift);
global_flush_tlb_page(mm, vaddr);
goto out;
}
if (nr == 0) {
tb->mm = mm;
tb->hugepage_shift = hugepage_shift;
}
if (tb->hugepage_shift != hugepage_shift) {
flush_tlb_pending();
tb->hugepage_shift = hugepage_shift;
nr = 0;
}
tb->vaddrs[nr] = vaddr;
tb->tlb_nr = ++nr;
if (nr >= TLB_BATCH_NR)
flush_tlb_pending();
out:
put_cpu_var(tlb_batch);
}
void tlb_batch_add(struct mm_struct *mm, unsigned long vaddr,
pte_t *ptep, pte_t orig, int fullmm,
unsigned int hugepage_shift)
{
if (tlb_type != hypervisor &&
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/percpu.h`, `linux/mm.h`, `linux/swap.h`, `linux/preempt.h`, `linux/pagemap.h`, `kunit/visibility.h`, `asm/tlbflush.h`.
- Detected declarations: `function flush_tlb_pending`, `function arch_enter_lazy_mmu_mode`, `function arch_flush_lazy_mmu_mode`, `function arch_leave_lazy_mmu_mode`, `function tlb_batch_add_one`, `function tlb_batch_add`, `function tlb_batch_pmd_scan`, `function __set_pmd_acct`, `function set_pmd_at`, `function pmdp_establish`.
- 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.