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