Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:This function splits huge page into normal pages. @page can point to any* subpage of huge page to split. Split doesn't change the position of @page.* Only caller must hold pin on the @page, otherwise split fails with -EBUSY.* The huge page must be locked.

Proto:int split_huge_page_to_list(struct page *page, struct list_head *list)

Type:int

Parameter:

TypeParameterName
struct page *page
struct list_head *list
2697  head = compound_head(page)
2698  pgdata = NODE_DATA(page_to_nid(head))
2699  ds_queue = get_deferred_split_queue(page)
2700  struct anon_vma * anon_vma = NULL
2701  struct address_space * mapping = NULL
2707  VM_BUG_ON_PAGE(is_huge_zero_page(head), head)
2708  VM_BUG_ON_PAGE(!PageLocked(page), page)
2709  VM_BUG_ON_PAGE(!PageCompound(page), page)
2711  If Only test-and-set exist for PG_writeback. The unconditional operators are* risky: they bypass page accounting. Then Return -EBUSY
2714  If PageAnon(head) Then
2723  anon_vma = Getting a lock on a stable anon_vma from a page off the LRU is tricky!* Since there is no serialization what so ever against page_remove_rmap()* the best this function can do is return a locked anon_vma that might* have been relevant to this page
2724  If Not anon_vma Then
2725  ret = -EBUSY
2726  Go to out
2728  end = -1
2729  mapping = NULL
2730  anon_vma_lock_write(anon_vma)
2731  Else
2732  mapping = See page-flags.h for PAGE_MAPPING_FLAGS
2735  If Not mapping Then
2736  ret = -EBUSY
2737  Go to out
2740  anon_vma = NULL
2741  i_mmap_lock_read(mapping)
2750  end = DIV_ROUND_UP(NOTE: in a 32bit arch with a preemptable kernel and* an UP compile the i_size_read/write must be atomic* with respect to the local cpu (unlike with preempt disabled),* but they don't need to be atomic with respect to other cpus like in* true SMP (so they , PAGE_SIZE)
2757  If Not Racy check whether the huge page can be split Then
2758  ret = -EBUSY
2759  Go to out_unlock
2762  mlocked = PageMlocked(page)
2763  unmap_page(head)
2764  VM_BUG_ON_PAGE(compound_mapcount(head), head)
2767  If mlocked Then lru_add_drain()
2771  spin_lock_irqsave( & Write-intensive fields used by page reclaim , flags)
2773  If mapping Then
2774  XA_STATE() - Declare an XArray operation state.*@name: Name of this operation state (usually xas).*@array: Array to operate on.*@index: Initial index of interest.* Declare and initialise an xa_state on the stack.(xas, & i_pages, Return the pagecache index of the passed page. Regular pagecache pages* use ->index whereas swapcache pages use swp_offset(->private))
2780  xa_lock( & i_pages)
2781  If xas_load() - Load an entry from the XArray (advanced).*@xas: XArray operation state.* Usually walks the @xas to the appropriate state to load the entry* stored at xa_index. However, it will do nothing and return %NULL if*@xas is in an error state != head Then Go to fail
2786  spin_lock( & split_queue_lock)
2787  count = page_count(head)
2788  mapcount = total_mapcount(head)
2789  If Not mapcount && page_ref_freeze(head, 1 + extra_pins) Then
2791  split_queue_len--
2794  If mapping Then
2801  spin_unlock( & split_queue_lock)
2802  __split_huge_page(page, list, end, flags)
2803  If PageSwapCache(head) Then
2807  Else ret = 0
2809  Else
2811  pr_alert("total_mapcount: %u, page_count(): %u\n", mapcount, count)
2813  If PageTail(page) Then dump_page(head, NULL)
2815  dump_page(page, "total_mapcount(head) > 0")
2816  BUG()
2818  spin_unlock( & split_queue_lock)
2819  fail :
2819  If mapping Then xa_unlock( & i_pages)
2821  spin_unlock_irqrestore( & Write-intensive fields used by page reclaim , flags)
2822  remap_page(head)
2823  ret = -EBUSY
2826  out_unlock :
2827  If anon_vma Then
2828  anon_vma_unlock_write(anon_vma)
2829  put_anon_vma(anon_vma)
2831  If mapping Then i_mmap_unlock_read(mapping)
2833  out :
2834  Disable counters
2835  Return ret
Caller
NameDescribe
shrink_page_listshrink_page_list() returns the number of reclaimed pages
migrate_pagesmigrate_pages - migrate the pages specified in a list, to the free pages* supplied as the target for the page migration*@from: The list of pages to be migrated.*@get_new_page: The function used to allocate free pages to be used
split_huge_page