arch/alpha/mm/tlbflush.c

Source file repositories/reference/linux-study-clean/arch/alpha/mm/tlbflush.c

File Facts

System
Linux kernel
Corpus path
arch/alpha/mm/tlbflush.c
Extension
.c
Size
2902 bytes
Lines
113
Domain
Architecture Layer
Bucket
arch/alpha
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct tlb_mm_and_addr {
	struct mm_struct *mm;
	unsigned long addr;
	int tbi_type;	/* 2 = DTB, 3 = ITB+DTB */
};

static void ipi_flush_mm_and_page(void *x)
{
	struct tlb_mm_and_addr *d = x;

	/* Part 1: mm context side (Alpha uses ASN/context as a key mechanism). */
	if (d->mm == current->active_mm && !asn_locked())
		__load_new_mm_context(d->mm);
	else
		flush_tlb_other(d->mm);

	/* Part 2: immediate per-VA invalidation on this CPU. */
	tbi(d->tbi_type, d->addr);
}

void migrate_flush_tlb_page(struct vm_area_struct *vma, unsigned long addr)
{
	struct mm_struct *mm = vma->vm_mm;
	struct tlb_mm_and_addr d = {
		.mm = mm,
		.addr = addr,
		.tbi_type = (vma->vm_flags & VM_EXEC) ? 3 : 2,
	};

	/*
	 * One synchronous rendezvous: every CPU runs ipi_flush_mm_and_page().
	 * This is the "combined" version of flush_tlb_mm + per-page invalidate.
	 */
	preempt_disable();
	on_each_cpu(ipi_flush_mm_and_page, &d, 1);

	/*
	 * mimic flush_tlb_mm()'s mm_users<=1 optimization.
	 */
	if (atomic_read(&mm->mm_users) <= 1) {

		int cpu, this_cpu;
		this_cpu = smp_processor_id();

		for (cpu = 0; cpu < NR_CPUS; cpu++) {
			if (!cpu_online(cpu) || cpu == this_cpu)
				continue;
			if (READ_ONCE(mm->context[cpu]))
				WRITE_ONCE(mm->context[cpu], 0);
		}
	}
	preempt_enable();
}

#endif

Annotation

Implementation Notes