Commit aa464ba9 authored by Nicholas Piggin's avatar Nicholas Piggin Committed by Andrew Morton
Browse files

lazy tlb: introduce lazy tlb mm refcount helper functions

Add explicit _lazy_tlb annotated functions for lazy tlb mm refcounting. 
This makes the lazy tlb mm references more obvious, and allows the
refcounting scheme to be modified in later changes.  There is no
functional change with this patch.

Link: https://lkml.kernel.org/r/20230203071837.1136453-3-npiggin@gmail.com


Signed-off-by: default avatarNicholas Piggin <npiggin@gmail.com>
Acked-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Nadav Amit <nadav.amit@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 6cad87b0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -253,7 +253,7 @@ static int ecard_init_mm(void)
	current->mm = mm;
	current->active_mm = mm;
	activate_mm(active_mm, mm);
	mmdrop(active_mm);
	mmdrop_lazy_tlb(active_mm);
	ecard_init_pgtables(mm);
	return 0;
}
+1 −1
Original line number Diff line number Diff line
@@ -1611,7 +1611,7 @@ void start_secondary(void *unused)
	if (IS_ENABLED(CONFIG_PPC32))
		setup_kup();

	mmgrab(&init_mm);
	mmgrab_lazy_tlb(&init_mm);
	current->active_mm = &init_mm;

	smp_store_cpu_info(cpu);
+2 −2
Original line number Diff line number Diff line
@@ -797,10 +797,10 @@ void exit_lazy_flush_tlb(struct mm_struct *mm, bool always_flush)
	if (current->active_mm == mm) {
		WARN_ON_ONCE(current->mm != NULL);
		/* Is a kernel thread and is using mm as the lazy tlb */
		mmgrab(&init_mm);
		mmgrab_lazy_tlb(&init_mm);
		current->active_mm = &init_mm;
		switch_mm_irqs_off(mm, &init_mm, current);
		mmdrop(mm);
		mmdrop_lazy_tlb(mm);
	}

	/*
+1 −1
Original line number Diff line number Diff line
@@ -1034,7 +1034,7 @@ static int exec_mmap(struct mm_struct *mm)
		mmput(old_mm);
		return 0;
	}
	mmdrop(active_mm);
	mmdrop_lazy_tlb(active_mm);
	return 0;
}

+16 −0
Original line number Diff line number Diff line
@@ -79,6 +79,22 @@ static inline void mmdrop_sched(struct mm_struct *mm)
}
#endif

/* Helpers for lazy TLB mm refcounting */
static inline void mmgrab_lazy_tlb(struct mm_struct *mm)
{
	mmgrab(mm);
}

static inline void mmdrop_lazy_tlb(struct mm_struct *mm)
{
	mmdrop(mm);
}

static inline void mmdrop_lazy_tlb_sched(struct mm_struct *mm)
{
	mmdrop_sched(mm);
}

/**
 * mmget() - Pin the address space associated with a &struct mm_struct.
 * @mm: The address space to pin.
Loading