Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\khugepaged.c Create Date:2022-07-28 16:06:57
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:khugepaged_scan_pmd

Proto:static int khugepaged_scan_pmd(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long address, struct page **hpage)

Type:int

Parameter:

TypeParameterName
struct mm_struct *mm
struct vm_area_struct *vma
unsigned longaddress
struct page **hpage
1122  ret = 0 , none_or_zero = 0 , result = 0 , referenced = 0
1123  struct page * page = NULL
1126  node = NUMA_NO_NODE , unmapped = 0
1127  bool writable = false
1129  VM_BUG_ON(address & ~HPAGE_PMD_MASK)
1131  pmd = mm_find_pmd(mm, address)
1132  If Not pmd Then
1133  result = SCAN_PMD_NULL
1134  Go to out
1137  memset(khugepaged_node_load, 0, size of khugepaged_node_load )
1138  pte = pte_offset_map_lock(mm, pmd, address, & ptl)
1139  When _pte < pte + HPAGE_PMD_NR cycle
1141  pteval = _pte
1143  If ++unmapped <= khugepaged_max_ptes_swap Then
1144  Continue
1145  Else
1147  Go to out_unmap
1150  If pte_none(pteval) || is_zero_pfn(pte_pfn(pteval)) Then
1153  Continue
1154  Else
1156  Go to out_unmap
1159  If Not pte_present(pteval) Then
1161  Go to out_unmap
1163  If pte_write(pteval) Then writable = true
1166  page = vm_normal_page -- This function gets the "struct page" associated with a pte.* "Special" mappings do not wish to be associated with a "struct page" (either* it doesn't exist, or it exists but they don't want to touch it). In this
1169  Go to out_unmap
1173  If PageCompound(page) Then
1175  Go to out_unmap
1184  node = page_to_nid(page)
1185  If khugepaged_scan_abort(node) Then
1187  Go to out_unmap
1189  khugepaged_node_load[node]++
1190  If Not PageLRU(page) Then
1192  Go to out_unmap
1194  If PageLocked(page) Then
1196  Go to out_unmap
1198  If Not PageAnon(page) Then
1200  Go to out_unmap
1208  If page_count(page) != 1 + PageSwapCache(page) Then
1210  Go to out_unmap
1212  If pte_young(pteval) || page_is_young(page) || PageReferenced(page) || mmu_notifier_test_young(The address space we belong to. , address) Then referenced++
1217  If writable Then
1218  If referenced Then
1219  result = SCAN_SUCCEED
1220  ret = 1
1221  Else
1224  Else
1225  result = SCAN_PAGE_RO
1227  out_unmap :
1228  pte_unmap_unlock(pte, ptl)
1229  If ret Then
1230  node = khugepaged_find_target_node()
1232  collapse_huge_page(mm, address, hpage, node, referenced)
1234  out :
1235  trace_mm_khugepaged_scan_pmd(mm, page, writable, referenced, none_or_zero, result, unmapped)
1237  Return ret
Caller
NameDescribe
khugepaged_scan_mm_slot