Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\swapfile.c Create Date:2022-07-28 15:18:00
Last Modify:2020-03-17 22:19:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:page_trans_huge_map_swapcount

Proto:static int page_trans_huge_map_swapcount(struct page *page, int *total_mapcount, int *total_swapcount)

Type:int

Parameter:

TypeParameterName
struct page *page
int *total_mapcount
int *total_swapcount
1585  offset = 0
1587  struct swap_cluster_info * ci = NULL
1588  unsigned char * map = NULL
1589  swapcount = 0
1592  VM_BUG_ON_PAGE(PageHuge(page), page)
1594  If Not IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm',* 0 otherwise.(CONFIG_THP_SWAP) || Value is more likely to compile time(!PageTransCompound returns true for both transparent huge pages* and hugetlbfs pages, so it should only be called when it's known* that hugetlbfs pages aren't involved.) Then
1595  mapcount = page_trans_huge_mapcount(page, total_mapcount)
1596  If PageSwapCache(page) Then swapcount = How many references to page are currently swapped out?* This does not give an exact answer when swap count is continued,* but does include the high COUNT_CONTINUED flag to allow for that.
1598  If total_swapcount Then total_swapcount = swapcount
1600  Return mapcount + swapcount
1603  page = compound_head(page)
1605  _total_mapcount = _total_swapcount = map_swapcount = 0
1606  If PageSwapCache(page) Then
1609  val = page_private(page)
1610  si = _swap_info_get(entry)
1611  If si Then
1616  If map Then ci = lock_cluster(si, offset)
1618  When i < HPAGE_PMD_NR cycle
1619  mapcount = atomic_read( & * If the page can be mapped to userspace, encodes the number * of times this page is referenced by a page table.) + 1
1620  _total_mapcount += mapcount
1621  If map Then
1625  map_swapcount = max - return maximum of two values of the same or compatible types*@x: first value*@y: second value(map_swapcount, mapcount + swapcount)
1627  unlock_cluster(ci)
1628  If PageDoubleMap indicates that the compound page is mapped with PTEs as well* as PMDs.* This is required for optimization of rmap operations for THP: we can postpone* per small page mapcount accounting (and its overhead from atomic operations) Then
1629  map_swapcount -= 1
1630  _total_mapcount -= HPAGE_PMD_NR
1632  mapcount = compound_mapcount(page)
1633  map_swapcount += mapcount
1634  _total_mapcount += mapcount
1635  If total_mapcount Then total_mapcount = _total_mapcount
1637  If total_swapcount Then total_swapcount = _total_swapcount
1640  Return map_swapcount
Caller
NameDescribe
reuse_swap_pageWe can write to an anon page without COW if there are no other references* to it. And as a side-effect, free up its swap: because the old content* on disk will never be read, and seeking back there to write new content