Flush-Cache/Page-Lock/Flush-TLB说明

37 篇文章 2 订阅

    Flush-Cache/Page-Lock/Flush-TLB说明

 

理论上顺序:

  1. 获得页面锁,保证后续flush操作完成之前不允许继续读写
  2. Flush cache
  3. 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

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值