Flush-Cache/Page-Lock/Flush-TLB说明
理论上顺序:
- 获得页面锁,保证后续flush操作完成之前不允许继续读写
- Flush cache
- 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
__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
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)