函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\percpu.c Create Date:2022-07-27 15:51:57
Last Modify:2022-05-23 13:52:24 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:Balance work is used to populate or destroy chunks asynchronously. We* try to keep the number of populated free pages between* PCPU_EMPTY_POP_PAGES_LOW and HIGH for atomic allocations and at most one* empty chunk.

函数原型:static void pcpu_balance_workfn(struct work_struct *work)

返回类型:void

参数:

类型参数名称
struct work_struct *work
1835  gfp等于GFP_KERNEL按位或__GFP_NORETRY按位或DOC: Action modifiers* Action modifiers* ~~~~~~~~~~~~~~~~* %__GFP_NOWARN suppresses allocation failure reports.* %__GFP_COMP address compound page metadata.* %__GFP_ZERO returns a zeroed page on success.
1836  LIST_HEAD(to_free)
1837  free_head等于pcpu_slot[pcpu_nr_slots - 1]
1845  mutex_lock( & pcpu_alloc_mutex)
1846  spin_lock_irq( & pcpu_lock)
1849  WARN_ON( no [de]population allowed )
1852  如果chunk恒等于list_first_entry - get the first element from a list*@ptr: the list head to take the element from.*@type: the type of the struct this is embedded in.*@member: the name of the list_head within the struct.* Note, that list is expected to be not empty.(free_head, structpcpu_chunk, list)则继续下一循环
1855  链表项移动到头部
1858  spin_unlock_irq( & pcpu_lock)
1865  pcpu_depopulate_chunk - depopulate and unmap an area of a pcpu_chunk*@chunk: chunk to depopulate*@page_start: the start page*@page_end: the end page* For each cpu, depopulate and unmap pages [@page_start,@page_end)* from @chunk.* CONTEXT:
1866  spin_lock_irq( & pcpu_lock)
1867  pcpu_chunk_depopulated - post-depopulation bookkeeping*@chunk: pcpu_chunk which got depopulated*@page_start: the start page*@page_end: the end page* Pages in [@page_start,@page_end) have been depopulated from @chunk.
1868  spin_unlock_irq( & pcpu_lock)
1870  pcpu_destroy_chunk(chunk)
1871  cond_resched()
1884  retry_pop :
1885  如果pcpu_atomic_alloc_failed
1886  nr_to_pop等于PCPU_EMPTY_POP_PAGES_HIGH
1888  pcpu_atomic_alloc_failed = false
1889  否则
1890  nr_to_pop等于clamp - return a value clamped to a given range with strict typechecking*@val: current value*@lo: lowest allowable value*@hi: highest allowable value* This macro does strict typechecking of @lo/@hi to make sure they are of the* same type as @val(PCPU_EMPTY_POP_PAGES_HIGH - The number of empty populated pages, protected by pcpu_lock. The* reserved chunk doesn't contribute to the count., 0, PCPU_EMPTY_POP_PAGES_HIGH)
1895 slot小于pcpu_nr_slots循环
1896  nr_unpop等于0
1898  如果非nr_to_pop退出
1901  spin_lock_irq( & pcpu_lock)
1903  nr_unpop等于 # of pages served by this chunk # of populated pages
1904  如果nr_unpop退出
1907  spin_unlock_irq( & pcpu_lock)
1909  如果非nr_unpop则继续下一循环
1915  nr等于两数取小(re - rs, nr_to_pop)
1917  ret等于pcpu_populate_chunk - populate and map an area of a pcpu_chunk*@chunk: chunk of interest*@page_start: the start page*@page_end: the end page*@gfp: allocation flags passed to the underlying memory allocator* For each cpu, populate and map pages
1918  如果非ret
1919  nr_to_pop减等于nr
1920  spin_lock_irq( & pcpu_lock)
1921  pcpu_chunk_populated - post-population bookkeeping*@chunk: pcpu_chunk which got populated*@page_start: the start page*@page_end: the end page* Pages in [@page_start,@page_end) have been populated to @chunk. Update* the bookkeeping information accordingly
1922  spin_unlock_irq( & pcpu_lock)
1923  否则
1924  nr_to_pop等于0
1927  如果非nr_to_pop退出
1932  如果nr_to_pop
1934  chunk等于pcpu_create_chunk(gfp)
1935  如果chunk
1939  转到:retry_pop
1943  mutex_unlock - release the mutex*@lock: the mutex to be released* Unlock a mutex that has been locked by this task previously.* This function must not be used in interrupt context. Unlocking* of a not locked mutex is not allowed.