函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称:Reaper for unused keys.

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

返回类型:void

参数:

类型参数名称
struct work_struct *work
170  LIST_HEAD(graveyard)
184  kenter("[%lx,%x]", key_gc_flags, gc_state)
186  limit等于ktime_get_real_seconds - Get the seconds portion of CLOCK_REALTIME* Returns the wall clock seconds since 1970. This replaces the* get_seconds() interface which is not y2038 safe on 32bit systems.
187  如果limit大于Delay between key revocation/expiry in secondslimit减等于Delay between key revocation/expiry in seconds
189  否则limit等于Delay between key revocation/expiry in seconds
193  gc_state与等于- We need to mark dead keys 按位或- We need to reap dead key links
194  gc_state左移等于1位
195  如果st_and_clear_bit - Clear a bit and return its old value*@nr: Bit to clear*@addr: Address to count from* This is an atomic fully-ordered operation (implied full memory barrier).gc_state或等于- We need to reap links 按位或- We need to restart the timer
198  如果st_and_clear_bit - Clear a bit and return its old value*@nr: Bit to clear*@addr: Address to count from* This is an atomic fully-ordered operation (implied full memory barrier).gc_state或等于- We need to mark dead keys
200  kdebug("new pass %x", gc_state)
202  new_timer等于Located here for timespec[64]_valid_strict
208  加自旋锁
209  cursor等于This function returns the first node (in sort order) of the tree.
211  continue_scanning :
212 cursor循环
213  key等于rb_entry(cursor, structkey, serial_node)
214  cursor等于rb_next(cursor)
216  如果_read - get a refcount's value*@r: the refcount* Return: the refcount's value恒等于0则转到:found_unreferenced_key
220  如果 type of key 恒等于key_gc_dead_keytype
231  如果gc_state按位与- We need to restart the timer
239  如果此条件成立可能性小(为编译器优化)(gc_state & - We need to reap dead key links )则如果 type of key 恒等于key_gc_dead_keytype
241  gc_state或等于- We found at least one dead key
245  如果 type of key 恒等于key_type_keyring则转到:found_keyring
249  如果此条件成立可能性小(为编译器优化)(gc_state & - We need to reap dead keys )则如果 type of key 恒等于key_gc_dead_keytype
251  转到:destroy_dead_key
253  skip_dead_key :
254  如果spin_is_contended( & key_serial_lock)或need_resched()则转到:contended
258  contended :
259  自旋锁解锁
261  maybe_resched :
262  如果cursor
263  cond_resched()
264  加自旋锁
265  转到:continue_scanning
272  kdebug("pass complete")
274  如果gc_state按位与- We need to restart the timer new_timer不等于Located here for timespec[64]_valid_strict
275  new_timer加等于Delay between key revocation/expiry in seconds
276  Schedule a garbage collection run.* - time precision isn't particularly important
279  如果此条件成立可能性小(为编译器优化)(gc_state & - We need to reap dead key links )或非链表为空
286  kdebug("gc sync")
287  synchronize_rcu - wait until a grace period has elapsed
290  如果非链表为空
291  kdebug("gc keys")
292  Garbage collect a list of unreferenced, detached keys
295  如果此条件成立可能性小(为编译器优化)(gc_state & (- We need to mark dead keys | - We need to reap dead key links ))则
297  如果非gc_state按位与- We found at least one dead key 的值则
301  kdebug("dead short")
304  否则
309  如果此条件成立可能性小(为编译器优化)(gc_state & - We need to reap dead keys )则
310  kdebug("dead wake")
311  smp_mb()
312  lear_bit - Clears a bit in memory*@nr: Bit to clear*@addr: Address to start counting from* This is a relaxed atomic operation (no implied memory barriers).
313  wake_up_bit - wake up a waiter on a bit*@word: the word being waited on, a kernel virtual address*@bit: the bit of the word being waited on* There is a standard hashed waitqueue table for generic use
316  如果gc_state按位与Internal persistent state schedule_work - put work task in global workqueue*@work: job to be done* Returns %false if @work was already on the kernel-global workqueue and* %true otherwise
318  kleave(" [end %x]", gc_state)
319  返回
324  found_unreferenced_key :
325  kdebug("unrefd key %d", key serial number )
326  rb_erase( & serial_node, & key_serial_tree)
327  自旋锁解锁
329  添加链表项
330  gc_state或等于Internal persistent state
331  转到:maybe_resched
336  found_restricted_keyring :
337  自旋锁解锁
338  keyring_restriction_gc(key, key_gc_dead_keytype)
339  转到:maybe_resched
346  found_keyring :
347  自旋锁解锁
348  keyring_gc(key, limit)
349  转到:maybe_resched
354  destroy_dead_key :
355  自旋锁解锁
356  kdebug("destroy key %d", key serial number )
357  lock for writing
358  type of key 等于Any key whose type gets unregistered will be re-typed to this if it can't be* immediately unlinked.
359  如果destroydestroy(key)
361  memset( & payload, security/ *********, payload的长度)
362  lease a write lock
363  转到:maybe_resched