Flush-Cache/Page-Lock/Flush-TLB说明
以下用numa_migrate_pages系统调用,内核中是kernel_migrate_pages服务函数,以X86体系结构作为说明
kernel_migrate_pages[mm/mempolicy.c]
do_migrate_pages.part.31()
migrate_to_node
queue_pages_range
walk_page_range
migrate_pages[mm/migrate.c]
PageHuge
unmap_and_move_huge_page/ unmap_and_move
__unmap_and_move
lock_page(page); //获得页面锁
get_new_page
try_to_unmap[mm/rmap.c]
rmap_walk
rmap_walk_anon/ rmap_walk_ksm/ rmap_walk_file
try_to_unmap_one (rwc->rmap_one)
flush_cache_page //flush cache
ptep_clear_flush
flush_tlb_mm_range//flush TLB(包括remote核)
flush_tlb_func_local
flush_tlb_func_common flush_tlb_others(=native_flush_tlb_others)
flush_tlb_func_remote
page_mapped
move_to_new_page //真正的页面移动(拷贝)
……
remove_migration_ptes
……
lock_page
__lock_page
wait_on_page_bit_common
test_and_set_bit_lock
test_and_set_bit
test_and_set_bit函数用原子指令锁住结构体page(每一个页面有一个对应的结构体struct page)中的&page->flags
其中,page->flags有很多flag,如下[include/linux/page-flags.h]:
/*
* Various page->flags bits:
*
* PG_reserved is set for special pages, which can never be swapped out. Some
* of them might not even exist...
*
* The PG_private bitflag is set on pagecache pages if they contain filesystem
* specific data (which is normally at page->private). It can be used by
* private allocations for its own usage.
*
* During initiation of disk I/O, PG_locked is set. This bit is set before I/O
* and cleared when writeback _starts_ or when read _completes_. PG_writeback
* is set before writeback starts and cleared when it finishes.
*
* PG_locked also pins a page in pagecache, and blocks truncation of the file
* while it is held.
……
enum pageflags {
PG_locked, /* Page is locked. Don't touch. */
……
……
}
Documentation/core-api/ cachetlb.rst