at master 3.5 kB view raw
1/* SPDX-License-Identifier: GPL-2.0-only */ 2/* 3 * include/linux/kmemleak.h 4 * 5 * Copyright (C) 2008 ARM Limited 6 * Written by Catalin Marinas <catalin.marinas@arm.com> 7 */ 8 9#ifndef __KMEMLEAK_H 10#define __KMEMLEAK_H 11 12#include <linux/slab.h> 13#include <linux/vmalloc.h> 14 15#ifdef CONFIG_DEBUG_KMEMLEAK 16 17extern void kmemleak_init(void) __init; 18extern void kmemleak_alloc(const void *ptr, size_t size, int min_count, 19 gfp_t gfp) __ref; 20extern void kmemleak_alloc_percpu(const void __percpu *ptr, size_t size, 21 gfp_t gfp) __ref; 22extern void kmemleak_vmalloc(const struct vm_struct *area, size_t size, 23 gfp_t gfp) __ref; 24extern void kmemleak_free(const void *ptr) __ref; 25extern void kmemleak_free_part(const void *ptr, size_t size) __ref; 26extern void kmemleak_free_percpu(const void __percpu *ptr) __ref; 27extern void kmemleak_update_trace(const void *ptr) __ref; 28extern void kmemleak_not_leak(const void *ptr) __ref; 29extern void kmemleak_transient_leak(const void *ptr) __ref; 30extern void kmemleak_ignore(const void *ptr) __ref; 31extern void kmemleak_ignore_percpu(const void __percpu *ptr) __ref; 32extern void kmemleak_scan_area(const void *ptr, size_t size, gfp_t gfp) __ref; 33extern void kmemleak_no_scan(const void *ptr) __ref; 34extern void kmemleak_alloc_phys(phys_addr_t phys, size_t size, 35 gfp_t gfp) __ref; 36extern void kmemleak_free_part_phys(phys_addr_t phys, size_t size) __ref; 37extern void kmemleak_ignore_phys(phys_addr_t phys) __ref; 38 39static inline void kmemleak_alloc_recursive(const void *ptr, size_t size, 40 int min_count, slab_flags_t flags, 41 gfp_t gfp) 42{ 43 if (!(flags & SLAB_NOLEAKTRACE)) 44 kmemleak_alloc(ptr, size, min_count, gfp); 45} 46 47static inline void kmemleak_free_recursive(const void *ptr, slab_flags_t flags) 48{ 49 if (!(flags & SLAB_NOLEAKTRACE)) 50 kmemleak_free(ptr); 51} 52 53static inline void kmemleak_erase(void **ptr) 54{ 55 *ptr = NULL; 56} 57 58#else 59 60static inline void kmemleak_init(void) 61{ 62} 63static inline void kmemleak_alloc(const void *ptr, size_t size, int min_count, 64 gfp_t gfp) 65{ 66} 67static inline void kmemleak_alloc_recursive(const void *ptr, size_t size, 68 int min_count, slab_flags_t flags, 69 gfp_t gfp) 70{ 71} 72static inline void kmemleak_alloc_percpu(const void __percpu *ptr, size_t size, 73 gfp_t gfp) 74{ 75} 76static inline void kmemleak_vmalloc(const struct vm_struct *area, size_t size, 77 gfp_t gfp) 78{ 79} 80static inline void kmemleak_free(const void *ptr) 81{ 82} 83static inline void kmemleak_free_part(const void *ptr, size_t size) 84{ 85} 86static inline void kmemleak_free_recursive(const void *ptr, slab_flags_t flags) 87{ 88} 89static inline void kmemleak_free_percpu(const void __percpu *ptr) 90{ 91} 92static inline void kmemleak_update_trace(const void *ptr) 93{ 94} 95static inline void kmemleak_not_leak(const void *ptr) 96{ 97} 98static inline void kmemleak_transient_leak(const void *ptr) 99{ 100} 101static inline void kmemleak_ignore_percpu(const void __percpu *ptr) 102{ 103} 104static inline void kmemleak_ignore(const void *ptr) 105{ 106} 107static inline void kmemleak_scan_area(const void *ptr, size_t size, gfp_t gfp) 108{ 109} 110static inline void kmemleak_erase(void **ptr) 111{ 112} 113static inline void kmemleak_no_scan(const void *ptr) 114{ 115} 116static inline void kmemleak_alloc_phys(phys_addr_t phys, size_t size, 117 gfp_t gfp) 118{ 119} 120static inline void kmemleak_free_part_phys(phys_addr_t phys, size_t size) 121{ 122} 123static inline void kmemleak_ignore_phys(phys_addr_t phys) 124{ 125} 126 127#endif /* CONFIG_DEBUG_KMEMLEAK */ 128 129#endif /* __KMEMLEAK_H */