Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\kmemleak.c Create Date:2022-07-28 16:21:29
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

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

Proto:static struct kmemleak_object *create_object(unsigned long ptr, size_t size, int min_count, gfp_t gfp)

Type:struct kmemleak_object

Parameter:

TypeParameterName
unsigned longptr
size_tsize
intmin_count
gfp_tgfp
578  object = Memory pool allocation and freeing. kmemleak_lock must not be held.
579  If Not object Then
580  pr_warn("Cannot allocate a kmemleak_object structure\n")
581  kmemleak_disable()
582  Return NULL
585  Initialization list head
586  Initialization list head
587  INIT_HLIST_HEAD( & memory ranges to be scanned inside an object (empty for all) )
588  Process spin lock initialization( & 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  If 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() () Then
601  pid of the current task = 0
602  strncpy(xecutable name , "hardirq", size of xecutable name )
603  Else if in_serving_softirq() Then
604  pid of the current task = 0
605  strncpy(xecutable name , "softirq", size of xecutable name )
606  Else
607  pid of the current task = pid
614  strncpy(xecutable name , comm, size of 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 = min - return minimum of two values of the same or compatible types*@x: first value*@y: second value(minimum and maximum address that may be valid pointers , untagged_ptr)
624  max_addr = max - return maximum of two values of the same or compatible types*@x: first value*@y: second value(max_addr, untagged_ptr + size)
625  link = rb_node
626  rb_parent = NULL
627  When link cycle
628  rb_parent = link
629  parent = rb_entry(rb_parent, structkmemleak_object, rb_node)
630  If ptr + size <= pointer Then link = rb_left
632  Else if pointer + size <= ptr Then link = rb_right
634  Else
643  object = NULL
644  Go to out
647  rb_link_node( & rb_node, rb_parent, link)
648  rb_insert_color( & rb_node, & search tree for object boundaries )
650  list_add_tail_rcu - add a new entry to rcu-protected list*@new: new entry to be added*@head: list head to add it before* Insert a new entry before the specified head
651  out :
652  write_unlock_irqrestore( & w_lock protecting the access to object_list and object_tree_root , flags)
653  Return object
Caller
NameDescribe
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_initKmemleak initialization.