Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:stable_tree_insert - insert stable tree node pointing to new ksm page* into the stable tree.* This function returns the stable tree node just allocated on success,* NULL otherwise.

Proto:static struct stable_node *stable_tree_insert(struct page *kpage)

Type:struct stable_node

Parameter:

TypeParameterName
struct page *kpage
1811  bool need_chain = false
1813  kpfn = page_to_pfn(kpage)
1814  nid = This helper is used for getting right index into array of tree roots.* When merge_across_nodes knob is set to 1, there are only two rb-trees for* stable and unstable pages from all nodes with roots in index 0. Otherwise,
1815  root = root_stable_tree + nid
1816  again :
1817  parent = NULL
1818  new = rb_node
1820  When new cycle
1824  cond_resched()
1825  stable_node = rb_entry( * new, structstable_node, node)
1826  stable_node_any = NULL
1827  tree_page = chain( & stable_node_dup, stable_node, root)
1828  If Not stable_node_dup Then
1836  If Not stable_node_any Then
1838  Go to again
1852  VM_BUG_ON(!stable_node_dup ^ !!stable_node_any)
1853  If Not tree_page Then
1863  Go to again
1866  ret = memcmp_pages(kpage, tree_page)
1867  Perform a free_page(), also freeing any swap cache associated with* this page if it is the last user of the page.
1869  parent = new
1870  If ret < 0 Then new = rb_left
1872  Else if ret > 0 Then new = rb_right
1874  Else
1875  need_chain = true
1876  Break
1880  stable_node_dup = alloc_stable_node()
1881  If Not stable_node_dup Then Return NULL
1884  INIT_HLIST_HEAD( & hlist)
1885  kpfn = kpfn
1886  set_page_stable_node(kpage, stable_node_dup)
1887  rmap_hlist_len = 0
1888  DO_NUMA(nid = nid)
1889  If Not need_chain Then
1890  rb_link_node( & when node of stable tree , parent, new)
1891  rb_insert_color( & when node of stable tree , root)
1892  Else
1893  If Not is_stable_node_chain(stable_node) Then
1894  orig = stable_node
1897  If Not stable_node Then
1899  Return NULL
1902  stable_node_chain_add_dup(stable_node_dup, stable_node)
1905  Return stable_node_dup
Caller
NameDescribe
cmp_and_merge_pagemp_and_merge_page - first see if page can be merged into the stable tree;* if not, compare checksum to previous and if it's the same, see if page can* be inserted into the unstable tree, or merged with a page already there and