函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称:assoc_array_gc - Garbage collect an associative array

函数原型:int assoc_array_gc(struct assoc_array *array, const struct assoc_array_ops *ops, bool (*iterator)(void *object, void *iterator_data), void *iterator_data)

返回类型:int

参数:

类型参数名称
struct assoc_array *array
const struct assoc_array_ops *ops
bool (*iterator
void *iterator_data
1467  打印调试信息("-->%s()\n", __func__)
1469  如果非The node at the root of the tree 则返回:0
1472  edit等于分配内存并置零
1473  如果非edit则返回:负ENOMEM
1475  array等于array
1476  ops等于ops
1477  ops_for_excised_subtree等于ops
1478  ptr等于The node at the root of the tree
1479  excised_subtree等于The node at the root of the tree
1481  new_root = new_parent = NULL
1482  new_ptr_pp等于new_root
1483  cursor等于The node at the root of the tree
1485  descend :
1489  如果assoc_array_ptr_is_shortcut(cursor)则
1490  shortcut等于assoc_array_ptr_to_shortcut(cursor)
1491  keylen等于und_up - round up to next specified power of 2*@x: the value to round*@y: multiple to round up to (must be a power of 2)* Rounds @x up to next multiple of @y (which must be a power of 2).* To perform arbitrary rounding up, use roundup() below.(skip_to_level, Key data retrieved in chunks of this size )
1492  keylen右移等于ASSOC_ARRAY_KEY_CHUNK_SHIFT
1493  new_s等于kmalloc(sizeof(structassoc_array_shortcut) + keylen * sizeof(unsignedlong), GFP_KERNEL)
1495  如果非new_s则转到:enomem
1497  打印调试信息("dup shortcut %p -> %p\n", shortcut, new_s)
1498  内存复制(new_s, shortcut, (sizeof(structassoc_array_shortcut) + keylen * sizeof(unsignedlong)))
1500  back_pointer等于new_parent
1501  parent_slot等于parent_slot
1502  new_ptr_pp等于new_parent等于assoc_array_shortcut_to_ptr(new_s)
1503  new_ptr_pp等于next_node
1504  cursor等于next_node
1508  node等于assoc_array_ptr_to_node(cursor)
1509  new_n等于分配内存并置零
1510  如果非new_n则转到:enomem
1512  打印调试信息("dup node %p -> %p\n", node, new_n)
1513  back_pointer等于new_parent
1514  parent_slot等于parent_slot
1515  new_ptr_pp等于new_parent等于assoc_array_node_to_ptr(new_n)
1516  new_ptr_pp = NULL
1517  slot等于0
1519  continue_node :
1521 slot小于Number of slots per node 循环
1522  ptr等于slots[slot]
1523  如果非ptr则继续下一循环
1526  如果assoc_array_ptr_is_leaf(ptr)则
1533  继续下一循环
1536  new_ptr_pp等于slots[slot]
1537  cursor等于ptr
1538  转到:descend
1541  打印调试信息("-- compress node %p --\n", new_n)
1546  nr_leaves_on_branch等于0
1547  nr_free等于0
1548 slot小于Number of slots per node 循环
1549  ptr等于slots[slot]
1550  如果非ptrnr_free自加
1552  否则如果assoc_array_ptr_is_leaf(ptr)则nr_leaves_on_branch自加
1555  打印调试信息("free=%d, leaves=%lu\n", nr_free, nr_leaves_on_branch)
1558  next_slot等于0
1559 slot小于Number of slots per node 循环
1563  ptr等于slots[slot]
1564  如果非ptrassoc_array_ptr_is_leaf(ptr)则继续下一循环
1567  s = NULL
1568  如果assoc_array_ptr_is_shortcut(ptr)则
1570  ptr等于next_node
1573  child等于assoc_array_ptr_to_node(ptr)
1574  nr_leaves_on_branch加等于nr_leaves_on_branch
1576  如果nr_leaves_on_branch小于等于nr_free加1则
1578  打印调试信息("[%d] fold node %lu/%d [nx %d]\n", slot, nr_leaves_on_branch, nr_free + 1, next_slot)
1585  BUG_ON(s)
1587  slots[slot] = NULL
1588  nr_free自加
1589  如果slot小于next_slotnext_slot等于slot
1592  p等于slots[i]
1593  如果非p则继续下一循环
1596 slots[next_slot]循环
1597  next_slot自加
1599  slots[next_slot++]等于p
1600  nr_free自减
1602  kfree(child)
1603  否则
1604  打印调试信息("[%d] retain node %lu/%d [nx %d]\n", slot, nr_leaves_on_branch, nr_free + 1, next_slot)
1610  打印调试信息("after: %lu\n", nr_leaves_on_branch)
1612  nr_leaves_on_tree等于nr_leaves_on_branch
1615  如果nr_free恒等于Number of slots per node 减1则
1616 slot小于Number of slots per node 循环如果ptr等于slots[slot]则
1618  退出
1622  打印调试信息("excise node %p with 1 shortcut\n", new_n)
1624  new_parent等于back_pointer
1625  slot等于parent_slot
1626  kfree(new_n)
1627  如果非new_parent
1628  back_pointer = NULL
1629  parent_slot等于0
1630  new_root等于ptr
1631  转到:gc_complete
1639  打印调试信息("excise preceding shortcut\n")
1642  slot等于parent_slot等于parent_slot
1643  kfree(s)
1644  如果非new_parent
1645  back_pointer = NULL
1646  parent_slot等于0
1647  new_root等于ptr
1648  转到:gc_complete
1652  back_pointer等于new_parent
1653  parent_slot等于slot
1655  slots[slot]等于ptr
1656  转到:ascend_old_tree
1663  ptr等于back_pointer
1664  如果非ptr则转到:gc_complete
1667  如果assoc_array_ptr_is_shortcut(ptr)则
1668  new_s等于assoc_array_ptr_to_shortcut(ptr)
1669  new_parent等于back_pointer
1670  slot等于parent_slot
1672  如果nr_leaves_on_branch小于等于Number of slots per node
1675  打印调试信息("excise shortcut\n")
1676  back_pointer等于new_parent
1677  parent_slot等于slot
1678  kfree(new_s)
1679  如果非new_parent
1681  转到:gc_complete
1687  否则
1688  new_parent等于ptr
1690  new_n等于assoc_array_ptr_to_node(new_parent)
1692  ascend_old_tree :
1693  ptr等于back_pointer
1694  如果assoc_array_ptr_is_shortcut(ptr)则
1695  shortcut等于assoc_array_ptr_to_shortcut(ptr)
1696  slot等于parent_slot
1697  cursor等于back_pointer
1698  如果非cursor则转到:gc_complete
1700  否则
1701  slot等于parent_slot
1702  cursor等于ptr
1704  BUG_ON(!cursor)
1705  node等于assoc_array_ptr_to_node(cursor)
1706  slot自加
1707  转到:continue_node
1709  gc_complete :
1710  to等于new_root
1711  assoc_array_apply_edit - Apply an edit script to an associative array*@edit: The script to apply.* Apply an edit script to an associative array to effect an insertion,* deletion or clearance. As the edit script includes preallocated memory,
1712  nr_leaves_on_tree等于nr_leaves_on_tree
1713  返回:0
1715  enomem :
1716  打印调试信息("enomem\n")
1717  Destructively iterate over an associative array. The caller must prevent* other simultaneous accesses.
1718  kfree(edit)
1719  返回:负ENOMEM
调用者
名称描述
keyring_gcGarbage collect pointers from a keyring.* Not called with any locks held. The keyring's key struct will not be* deallocated under us as only our caller may deallocate it.