函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\swap_state.c Create Date:2022-07-27 16:44:47
Last Modify:2020-03-17 22:02:06 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:add_to_swap_cache resembles add_to_page_cache_locked on swapper_space,* but sets SwapCache flag and private instead of mapping and index.

函数原型:int add_to_swap_cache(struct page *page, swp_entry_t entry, gfp_t gfp)

返回类型:int

参数:

类型参数名称
struct page *page
swp_entry_tentry
gfp_tgfp
116  address_space等于swap_address_space(entry)
117  idx等于Extract the `offset' field from a swp_entry_t. The swp_entry_t is in* arch-independent format
118  XA_STATE_ORDER() - Declare an XArray operation state.*@name: Name of this operation state (usually xas).*@array: Array to operate on.*@index: Initial index of interest.*@order: Order of entry.* Declare and initialise an xa_state on the stack(xas, & i_pages, idx, compound_order(page))
119  nr等于Returns the number of pages in this potentially compound page.
121  VM_BUG_ON_PAGE(!PageLocked(page), page)
122  VM_BUG_ON_PAGE(PageSwapCache(page), page)
123  VM_BUG_ON_PAGE(!PageSwapBacked(page), page)
125  page_ref_add(page, nr)
126  SetPageSwapCache(page)
128  循环
129  xas_lock_irq( & xas)
130  xas_create_range() - Ensure that stores to this range will succeed*@xas: XArray operation state.* Creates all of the slots in the range covered by @xas. Sets @xas to* create single-index entries and positions it at the beginning of the* range
131  如果xas_error() - Return an errno stored in the xa_state.*@xas: XArray operation state.* Return: 0 if no error has been noted. A negative errno if one has.则转到:unlock
133 i小于nr循环
135  set_page_private(page + i, val + i)
139  nrpages加等于nr
140  __mod_node_page_state(page_pgdat(page), NR_FILE_PAGES, nr)
141  ADD_CACHE_INFO(add_total, nr)
142  unlock :
143  xas_unlock_irq( & xas)
144 xas_nomem() - Allocate memory if needed.*@xas: XArray operation state.*@gfp: Memory allocation flags.* If we need to add new nodes to the XArray, we try to allocate memory* with GFP_NOWAIT while holding the lock, which will usually succeed.循环
146  如果非xas_error() - Return an errno stored in the xa_state.*@xas: XArray operation state.* Return: 0 if no error has been noted. A negative errno if one has.则返回:0
149  ClearPageSwapCache(page)
150  page_ref_sub(page, nr)
151  返回:xas_error() - Return an errno stored in the xa_state.*@xas: XArray operation state.* Return: 0 if no error has been noted. A negative errno if one has.
调用者
名称描述
add_to_swapadd_to_swap - allocate swap space for a page*@page: page we want to move to swap* Allocate swap space for the page and add the page to the* swap cache. Caller needs to hold the page lock.
__read_swap_cache_async