函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称:Create the metadata (struct kmemleak_object) corresponding to an allocated* memory block and add it to the object_list and object_tree_root.

函数原型:static struct kmemleak_object *create_object(unsigned long ptr, size_t size, int min_count, gfp_t gfp)

返回类型:struct kmemleak_object

参数:

类型参数名称
unsigned longptr
size_tsize
intmin_count
gfp_tgfp
578  object等于Memory pool allocation and freeing. kmemleak_lock must not be held.
579  如果非object
580  打印警告信息("Cannot allocate a kmemleak_object structure\n")
581  kmemleak_disable()
582  返回:NULL
585  初始化链表头
586  初始化链表头
587  INIT_HLIST_HEAD( & memory ranges to be scanned inside an object (empty for all) )
588  spin_lock_init( & lock)
589  atomic_set( & bject usage count; object freed when use_count == 0 , 1)
590  bject status flags 等于lag representing the memory block allocation status
591  pointer等于ptr
592  size等于size
593  pass surplus references to this pointer 等于0
594  minimum number of a pointers found before it is considered leak 等于min_count
595  he total number of pointers found pointing to this object 等于0
596  creation timestamp 等于jiffies
597  checksum for detecting modified objects 等于0
600  如果Are we doing bottom half or hardware interrupt processing?* in_irq() - We're in (hard) IRQ context* in_softirq() - We have BH disabled, or are processing softirqs* in_interrupt() - We're in NMI,IRQ,SoftIRQ context or have BH disabled* in_serving_softirq() ()则
601  pid of the current task 等于0
602  strncpy(xecutable name , "hardirq", xecutable name 的长度)
603  否则如果in_serving_softirq()则
604  pid of the current task 等于0
605  strncpy(xecutable name , "softirq", xecutable name 的长度)
606  否则
607  pid of the current task 等于pid
614  strncpy(xecutable name , comm, xecutable name 的长度)
618  trace_len等于Save stack trace to the given array of MAX_TRACE size.
620  write_lock_irqsave( & w_lock protecting the access to object_list and object_tree_root , flags)
622  untagged_ptr等于kasan_reset_tag((void * )ptr)
623  minimum and maximum address that may be valid pointers 等于两数取小(minimum and maximum address that may be valid pointers , untagged_ptr)
624  max_addr等于两数取大(max_addr, untagged_ptr + size)
625  link等于rb_node
626  rb_parent = NULL
627 link循环
628  rb_parent等于link
629  parent等于rb_entry(rb_parent, structkmemleak_object, rb_node)
630  如果ptrsize小于等于pointerlink等于rb_left
632  否则如果pointersize小于等于ptrlink等于rb_right
634  否则
643  object = NULL
644  转到:out
647  rb_link_node( & rb_node, rb_parent, link)
648  rb_insert_color( & rb_node, & search tree for object boundaries )
650  添加RCU链表项
651  out :
652  write_unlock_irqrestore( & w_lock protecting the access to object_list and object_tree_root , flags)
653  返回:object
调用者
名称描述
delete_object_partLook up the metadata (struct kmemleak_object) corresponding to ptr and* delete it. If the memory block is partially freed, the function may create* additional metadata for the remaining parts of the block.
kmemleak_allockmemleak_alloc - register a newly allocated object*@ptr: pointer to beginning of the object*@size: size of the object*@min_count: minimum number of references to this object. If during memory* scanning a number of references less than @min_count is found,
kmemleak_alloc_percpukmemleak_alloc_percpu - register a newly allocated __percpu object*@ptr: __percpu pointer to beginning of the object*@size: size of the object*@gfp: flags used for kmemleak internal memory allocations* This function is called from the kernel percpu
kmemleak_vmallockmemleak_vmalloc - register a newly vmalloc'ed object*@area: pointer to vm_struct*@size: size of the object*@gfp: __vmalloc() flags used for kmemleak internal memory allocations* This function is called from the vmalloc() kernel allocator when a new
kmemleak_init内存泄漏检测机制的初始化