The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
tlb.h File Reference

TLB shootdown: a change to the page tables reaches the TLB of every core that can hold the old entry. More...

#include "common/stdint.h"
#include "kernel/cpu/cpu.h"

Go to the source code of this file.

Functions

void tlb_init (void)
 set up the shootdown.
void tlb_shootdown_user (struct user_space *space, uintptr_t start, uintptr_t end)
 flush [start, end) of a user space on the other cores that have it loaded, and wait until they have flushed.
void tlb_shootdown_kernel (uintptr_t start, uintptr_t end)
 flush [start, end) of the kernel half on all the other cores, and wait until they have flushed.
void tlb_do_pending (void)
 do the flush that another core asks of this core, if there is one.

Detailed Description

TLB shootdown: a change to the page tables reaches the TLB of every core that can hold the old entry.

the paging functions flush the TLB of the core that makes the change. the other cores can still hold the old entry: those that have the user space loaded (its cpu_mask), or every core for the kernel half. the caller of a shootdown sends those cores an IPI and waits until each has flushed. only then may it free the frames that the old entries pointed to. one request is out at a time, as in Linux's old i386 flush_tlb_others.

a core that spins on a spinlock with interrupts off does a pending flush while it waits (tlb_poll), so a caller that holds a lock while it waits for the other cores cannot deadlock with a core that waits for that lock.

Function Documentation

◆ tlb_init()

void tlb_init ( void )

set up the shootdown.

call once on the boot core, before the other cores start.

◆ tlb_shootdown_user()

void tlb_shootdown_user ( struct user_space * space,
uintptr_t start,
uintptr_t end )

flush [start, end) of a user space on the other cores that have it loaded, and wait until they have flushed.

call it after the change to the page tables and before the frames are freed. any context; interrupts can be on or off.

Parameters
spacethe user space whose page tables changed.
startthe first address, page-aligned.
endthe address after the range.

◆ tlb_shootdown_kernel()

void tlb_shootdown_kernel ( uintptr_t start,
uintptr_t end )

flush [start, end) of the kernel half on all the other cores, and wait until they have flushed.

as tlb_shootdown_user().

Parameters
startthe first address, page-aligned.
endthe address after the range.

◆ tlb_do_pending()

void tlb_do_pending ( void )

do the flush that another core asks of this core, if there is one.

the IPI handler calls it. call it with interrupts off.