函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称: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.

函数原型:static struct stable_node *stable_tree_insert(struct page *kpage)

返回类型:struct stable_node

参数:

类型参数名称
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_treenid
1816  again :
1817  parent = NULL
1818  new等于rb_node
1820 new循环
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  如果非stable_node_dup
1836  如果非stable_node_any
1838  转到:again
1852  VM_BUG_ON(!stable_node_dup ^ !!stable_node_any)
1853  如果非tree_page
1863  转到: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  如果ret小于0则new等于rb_left
1872  否则如果ret大于0则new等于rb_right
1874  否则
1875  need_chain = true
1876  退出
1880  stable_node_dup等于alloc_stable_node()
1881  如果非stable_node_dup则返回: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  如果非need_chain
1890  rb_link_node( & when node of stable tree , parent, new)
1891  rb_insert_color( & when node of stable tree , root)
1892  否则
1893  如果非is_stable_node_chain(stable_node)则
1894  orig等于stable_node
1897  如果非stable_node
1899  返回:NULL
1902  stable_node_chain_add_dup(stable_node_dup, stable_node)
1905  返回:stable_node_dup
调用者
名称描述
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