0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef __KMEMLEAK_H
0010 #define __KMEMLEAK_H
0011
0012 #include <linux/slab.h>
0013 #include <linux/vmalloc.h>
0014
0015 #ifdef CONFIG_DEBUG_KMEMLEAK
0016
0017 extern void kmemleak_init(void) __init;
0018 extern void kmemleak_alloc(const void *ptr, size_t size, int min_count,
0019 gfp_t gfp) __ref;
0020 extern void kmemleak_alloc_percpu(const void __percpu *ptr, size_t size,
0021 gfp_t gfp) __ref;
0022 extern void kmemleak_vmalloc(const struct vm_struct *area, size_t size,
0023 gfp_t gfp) __ref;
0024 extern void kmemleak_free(const void *ptr) __ref;
0025 extern void kmemleak_free_part(const void *ptr, size_t size) __ref;
0026 extern void kmemleak_free_percpu(const void __percpu *ptr) __ref;
0027 extern void kmemleak_update_trace(const void *ptr) __ref;
0028 extern void kmemleak_not_leak(const void *ptr) __ref;
0029 extern void kmemleak_ignore(const void *ptr) __ref;
0030 extern void kmemleak_scan_area(const void *ptr, size_t size, gfp_t gfp) __ref;
0031 extern void kmemleak_no_scan(const void *ptr) __ref;
0032 extern void kmemleak_alloc_phys(phys_addr_t phys, size_t size,
0033 gfp_t gfp) __ref;
0034 extern void kmemleak_free_part_phys(phys_addr_t phys, size_t size) __ref;
0035 extern void kmemleak_ignore_phys(phys_addr_t phys) __ref;
0036
0037 static inline void kmemleak_alloc_recursive(const void *ptr, size_t size,
0038 int min_count, slab_flags_t flags,
0039 gfp_t gfp)
0040 {
0041 if (!(flags & SLAB_NOLEAKTRACE))
0042 kmemleak_alloc(ptr, size, min_count, gfp);
0043 }
0044
0045 static inline void kmemleak_free_recursive(const void *ptr, slab_flags_t flags)
0046 {
0047 if (!(flags & SLAB_NOLEAKTRACE))
0048 kmemleak_free(ptr);
0049 }
0050
0051 static inline void kmemleak_erase(void **ptr)
0052 {
0053 *ptr = NULL;
0054 }
0055
0056 #else
0057
0058 static inline void kmemleak_init(void)
0059 {
0060 }
0061 static inline void kmemleak_alloc(const void *ptr, size_t size, int min_count,
0062 gfp_t gfp)
0063 {
0064 }
0065 static inline void kmemleak_alloc_recursive(const void *ptr, size_t size,
0066 int min_count, slab_flags_t flags,
0067 gfp_t gfp)
0068 {
0069 }
0070 static inline void kmemleak_alloc_percpu(const void __percpu *ptr, size_t size,
0071 gfp_t gfp)
0072 {
0073 }
0074 static inline void kmemleak_vmalloc(const struct vm_struct *area, size_t size,
0075 gfp_t gfp)
0076 {
0077 }
0078 static inline void kmemleak_free(const void *ptr)
0079 {
0080 }
0081 static inline void kmemleak_free_part(const void *ptr, size_t size)
0082 {
0083 }
0084 static inline void kmemleak_free_recursive(const void *ptr, slab_flags_t flags)
0085 {
0086 }
0087 static inline void kmemleak_free_percpu(const void __percpu *ptr)
0088 {
0089 }
0090 static inline void kmemleak_update_trace(const void *ptr)
0091 {
0092 }
0093 static inline void kmemleak_not_leak(const void *ptr)
0094 {
0095 }
0096 static inline void kmemleak_ignore(const void *ptr)
0097 {
0098 }
0099 static inline void kmemleak_scan_area(const void *ptr, size_t size, gfp_t gfp)
0100 {
0101 }
0102 static inline void kmemleak_erase(void **ptr)
0103 {
0104 }
0105 static inline void kmemleak_no_scan(const void *ptr)
0106 {
0107 }
0108 static inline void kmemleak_alloc_phys(phys_addr_t phys, size_t size,
0109 gfp_t gfp)
0110 {
0111 }
0112 static inline void kmemleak_free_part_phys(phys_addr_t phys, size_t size)
0113 {
0114 }
0115 static inline void kmemleak_ignore_phys(phys_addr_t phys)
0116 {
0117 }
0118
0119 #endif
0120
0121 #endif