函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\khugepaged.c Create Date:2022-07-27 17:41:06
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:collapse_huge_page

函数原型:static void collapse_huge_page(struct mm_struct *mm, unsigned long address, struct page **hpage, int node, int referenced)

返回类型:void

参数:

类型参数名称
struct mm_struct *mm
unsigned longaddress
struct page **hpage
intnode
intreferenced
956  isolated等于0, result等于0
962  VM_BUG_ON(address & ~HPAGE_PMD_MASK)
965  gfp等于Defrag for khugepaged will enter direct reclaim/compaction if necessary 按位或__GFP_THISNODE
973  lease a read lock
974  new_page等于khugepaged_alloc_page(hpage, gfp, node)
975  如果非new_page
976  result等于SCAN_ALLOC_HUGE_PAGE_FAIL
977  转到:out_nolock
980  如果此条件成立可能性小(为编译器优化)(mem_cgroup_try_charge(new_page, mm, gfp, & memcg, true))则
981  result等于SCAN_CGROUP_CHARGE_FAIL
982  转到:out_nolock
985  lock for reading
986  result等于If mmap_sem temporarily dropped, revalidate vma* before taking mmap_sem.* Return 0 if succeeds, otherwise return none-zero* value (scan code).
987  如果result
988  mem_cgroup_cancel_charge(new_page, memcg, true)
989  lease a read lock
990  转到:out_nolock
993  pmd等于mm_find_pmd(mm, address)
994  如果非pmd
995  result等于SCAN_PMD_NULL
996  mem_cgroup_cancel_charge(new_page, memcg, true)
997  lease a read lock
998  转到:out_nolock
1006  如果非Bring missing pages in from swap, to complete THP collapse.* Only done if khugepaged_scan_pmd believes it is worthwhile.* Called and returns without pte mapped or spinlocks held,* but with mmap_sem held to protect against vma changes.
1007  mem_cgroup_cancel_charge(new_page, memcg, true)
1008  lease a read lock
1009  转到:out_nolock
1012  lease a read lock
1018  lock for writing
1019  result等于SCAN_ANY_PROCESS
1020  如果非This has to be called after a get_task_mm()/mmget_not_zero()* followed by taking the mmap_sem for writing before modifying the* vmas or anything the coredump pretends not to change from under it则转到:out
1022  result等于If mmap_sem temporarily dropped, revalidate vma* before taking mmap_sem.* Return 0 if succeeds, otherwise return none-zero* value (scan code).
1023  如果result则转到:out
1026  如果mm_find_pmd(mm, address)不等于pmd则转到:out
1029  anon_vma_lock_write(Serialized by page_table_lock )
1031  mmu_notifier_range_init( & range, MMU_NOTIFY_CLEAR, 0, NULL, mm, address, address + HPAGE_PMD_SIZE)
1033  mmu_notifier_invalidate_range_start( & range)
1035  pte等于pte_offset_map(pmd, address)
1036  pte_ptl等于pte_lockptr(mm, pmd)
1038  pmd_ptl等于pmd_lock(mm, pmd)
1045  _pmd等于pmdp_collapse_flush(vma, address, pmd)
1046  自旋锁解锁
1047  mmu_notifier_invalidate_range_end( & range)
1049  加自旋锁
1050  isolated等于__collapse_huge_page_isolate(vma, address, pte)
1051  自旋锁解锁
1053  如果此条件成立可能性小(为编译器优化)(!isolated)则
1054  pte_unmap(pte)
1055  加自旋锁
1056  BUG_ON(!pmd_none( * pmd))
1062  pmd_populate(mm, pmd, pmd_pgtable(_pmd))
1063  自旋锁解锁
1064  anon_vma_unlock_write(Serialized by page_table_lock )
1065  result等于SCAN_FAIL
1066  转到:out
1073  anon_vma_unlock_write(Serialized by page_table_lock )
1075  __collapse_huge_page_copy(pte, new_page, vma, address, pte_ptl)
1076  pte_unmap(pte)
1077  __SetPageUptodate(new_page)
1078  pgtable等于pmd_pgtable(_pmd)
1080  _pmd等于mk_huge_pmd(new_page, Access permissions of this VMA. )
1081  _pmd等于maybe_pmd_mkwrite(pmd_mkdirty(_pmd), vma)
1088  smp_wmb()
1090  加自旋锁
1091  BUG_ON(!pmd_none( * pmd))
1092  page_add_new_anon_rmap - add pte mapping to a new anonymous page*@page: the page to add the mapping to*@vma: the vm area in which the mapping is added*@address: the user virtual address mapped*@compound: charge the page as compound or small page
1093  mem_cgroup_commit_charge(new_page, memcg, TSC's on different sockets may be reset asynchronously.* This may cause the TSC ADJUST value on socket 0 to be NOT 0., true)
1094  count_memcg_events(memcg, THP_COLLAPSE_ALLOC, 1)
1095  lru_cache_add_active_or_unevictable*@page: the page to be added to LRU*@vma: vma in which page is mapped for determining reclaimability* Place @page on the active or unevictable LRU list, depending on its* evictability
1096  pgtable_trans_huge_deposit(mm, pmd, pgtable)
1097  set_pmd_at(mm, address, pmd, _pmd)
1098  update_mmu_cache_pmd(vma, address, pmd)
1099  自旋锁解锁
1101  * hpage = NULL
1103  khugepaged_pages_collapsed自加
1104  result等于SCAN_SUCCEED
1105  out_up_write :
1106  lease a write lock
1107  out_nolock :
1108  trace_mm_collapse_huge_page(mm, isolated, result)
1109  返回
1110  out :
1111  mem_cgroup_cancel_charge(new_page, memcg, true)
1112  转到:out_up_write
调用者
名称描述
khugepaged_scan_pmd