函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称:lc_create - prepares to track objects in an active set*@name: descriptive name only used in lc_seq_printf_stats and lc_seq_dump_details*@max_pending_changes: maximum changes to accumulate until a transaction is required*@e_count: number of elements

函数原型:struct lru_cache *lc_create(const char *name, struct kmem_cache *cache, unsigned max_pending_changes, unsigned e_count, size_t e_size, size_t e_off)

返回类型:struct lru_cache

参数:

类型参数名称
const char *name
struct kmem_cache *cache
unsignedmax_pending_changes
unsignede_count
size_te_size
size_te_off
91  struct hlist_head * slot = NULL
92  struct lc_element * * element = NULL
95  cache_obj_size等于kmem_cache_size(cache)
98  WARN_ON(cache_obj_size < e_size)
99  如果cache_obj_size小于e_size则返回:NULL
104  如果e_count大于Arbitrary limit on maximum tracked objects. Practical limit is much* lower due to allocation failures, probably. For typical use cases,* nr_elements should be a few thousand at most.* This also limits the maximum value of lc_element.lc_index, allowing the则返回:NULL
107  slot等于分配数组内存并置零
108  如果非slot则转到:out_fail
110  element等于分配数组内存并置零
111  如果非element则转到:out_fail
114  lc等于分配内存并置零
115  如果非lc则转到:out_fail
118  初始化链表头
119  初始化链表头
120  初始化链表头
121  初始化链表头
123  name等于name
124  size of tracked objects, used to memset(,0,) them in lc_reset 等于e_size
125  offset of struct lc_element member in the tracked object 等于e_off
126  number of elements (indices) 等于e_count
127  allow to accumulate a few (index:label) changes, * but no more than max_pending_changes 等于max_pending_changes
128  the pre-created kmem cache to allocate the objects from 等于cache
129  lc_element等于element
130  nr_elements there 等于slot
133 i小于e_count循环
134  p等于kmem_cache_alloc(cache, GFP_KERNEL)
135  如果非p退出
137  memset(p, 0, size of tracked objects, used to memset(,0,) them in lc_reset )
138  e等于pe_off
139  ack "pointer" into lc_cache->element[index],* for paranoia, and for "lc_element_to_index" 等于i
140  we want to track a larger set of objects,* it needs to become arch independend u64 等于special label when on free list
141  r pending changes 等于special label when on free list
142  添加链表项
143  element[i]等于e
145  如果i恒等于e_count则返回:lc
149 i循环
150  p等于element[i]
151  kmem_cache_free(cache, p - e_off)
153  kfree(lc)
154  out_fail :
155  kfree(element)
156  kfree(slot)
157  返回:NULL