Commit a6186d89 authored by Catalin Marinas's avatar Catalin Marinas

kmemleak: Mark the early log buffer as __initdata

This buffer isn't needed after kmemleak was initialised so it can be
freed together with the .init.data section. This patch also marks
functions conditionally accessing the early log variables with __ref.
Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
parent 189d84ed
...@@ -23,18 +23,18 @@ ...@@ -23,18 +23,18 @@
#ifdef CONFIG_DEBUG_KMEMLEAK #ifdef CONFIG_DEBUG_KMEMLEAK
extern void kmemleak_init(void); extern void kmemleak_init(void) __ref;
extern void kmemleak_alloc(const void *ptr, size_t size, int min_count, extern void kmemleak_alloc(const void *ptr, size_t size, int min_count,
gfp_t gfp); gfp_t gfp) __ref;
extern void kmemleak_free(const void *ptr); extern void kmemleak_free(const void *ptr) __ref;
extern void kmemleak_free_part(const void *ptr, size_t size); extern void kmemleak_free_part(const void *ptr, size_t size) __ref;
extern void kmemleak_padding(const void *ptr, unsigned long offset, extern void kmemleak_padding(const void *ptr, unsigned long offset,
size_t size); size_t size) __ref;
extern void kmemleak_not_leak(const void *ptr); extern void kmemleak_not_leak(const void *ptr) __ref;
extern void kmemleak_ignore(const void *ptr); extern void kmemleak_ignore(const void *ptr) __ref;
extern void kmemleak_scan_area(const void *ptr, unsigned long offset, extern void kmemleak_scan_area(const void *ptr, unsigned long offset,
size_t length, gfp_t gfp); size_t length, gfp_t gfp) __ref;
extern void kmemleak_no_scan(const void *ptr); extern void kmemleak_no_scan(const void *ptr) __ref;
static inline void kmemleak_alloc_recursive(const void *ptr, size_t size, static inline void kmemleak_alloc_recursive(const void *ptr, size_t size,
int min_count, unsigned long flags, int min_count, unsigned long flags,
......
...@@ -232,8 +232,9 @@ struct early_log { ...@@ -232,8 +232,9 @@ struct early_log {
}; };
/* early logging buffer and current position */ /* early logging buffer and current position */
static struct early_log early_log[CONFIG_DEBUG_KMEMLEAK_EARLY_LOG_SIZE]; static struct early_log
static int crt_early_log; early_log[CONFIG_DEBUG_KMEMLEAK_EARLY_LOG_SIZE] __initdata;
static int crt_early_log __initdata;
static void kmemleak_disable(void); static void kmemleak_disable(void);
...@@ -718,8 +719,8 @@ static void object_no_scan(unsigned long ptr) ...@@ -718,8 +719,8 @@ static void object_no_scan(unsigned long ptr)
* Log an early kmemleak_* call to the early_log buffer. These calls will be * Log an early kmemleak_* call to the early_log buffer. These calls will be
* processed later once kmemleak is fully initialized. * processed later once kmemleak is fully initialized.
*/ */
static void log_early(int op_type, const void *ptr, size_t size, static void __init log_early(int op_type, const void *ptr, size_t size,
int min_count, unsigned long offset, size_t length) int min_count, unsigned long offset, size_t length)
{ {
unsigned long flags; unsigned long flags;
struct early_log *log; struct early_log *log;
...@@ -751,7 +752,8 @@ static void log_early(int op_type, const void *ptr, size_t size, ...@@ -751,7 +752,8 @@ static void log_early(int op_type, const void *ptr, size_t size,
* kernel allocators when a new block is allocated (kmem_cache_alloc, kmalloc, * kernel allocators when a new block is allocated (kmem_cache_alloc, kmalloc,
* vmalloc etc.). * vmalloc etc.).
*/ */
void kmemleak_alloc(const void *ptr, size_t size, int min_count, gfp_t gfp) void __ref kmemleak_alloc(const void *ptr, size_t size, int min_count,
gfp_t gfp)
{ {
pr_debug("%s(0x%p, %zu, %d)\n", __func__, ptr, size, min_count); pr_debug("%s(0x%p, %zu, %d)\n", __func__, ptr, size, min_count);
...@@ -766,7 +768,7 @@ EXPORT_SYMBOL_GPL(kmemleak_alloc); ...@@ -766,7 +768,7 @@ EXPORT_SYMBOL_GPL(kmemleak_alloc);
* Memory freeing function callback. This function is called from the kernel * Memory freeing function callback. This function is called from the kernel
* allocators when a block is freed (kmem_cache_free, kfree, vfree etc.). * allocators when a block is freed (kmem_cache_free, kfree, vfree etc.).
*/ */
void kmemleak_free(const void *ptr) void __ref kmemleak_free(const void *ptr)
{ {
pr_debug("%s(0x%p)\n", __func__, ptr); pr_debug("%s(0x%p)\n", __func__, ptr);
...@@ -781,7 +783,7 @@ EXPORT_SYMBOL_GPL(kmemleak_free); ...@@ -781,7 +783,7 @@ EXPORT_SYMBOL_GPL(kmemleak_free);
* Partial memory freeing function callback. This function is usually called * Partial memory freeing function callback. This function is usually called
* from bootmem allocator when (part of) a memory block is freed. * from bootmem allocator when (part of) a memory block is freed.
*/ */
void kmemleak_free_part(const void *ptr, size_t size) void __ref kmemleak_free_part(const void *ptr, size_t size)
{ {
pr_debug("%s(0x%p)\n", __func__, ptr); pr_debug("%s(0x%p)\n", __func__, ptr);
...@@ -796,7 +798,7 @@ EXPORT_SYMBOL_GPL(kmemleak_free_part); ...@@ -796,7 +798,7 @@ EXPORT_SYMBOL_GPL(kmemleak_free_part);
* Mark an already allocated memory block as a false positive. This will cause * Mark an already allocated memory block as a false positive. This will cause
* the block to no longer be reported as leak and always be scanned. * the block to no longer be reported as leak and always be scanned.
*/ */
void kmemleak_not_leak(const void *ptr) void __ref kmemleak_not_leak(const void *ptr)
{ {
pr_debug("%s(0x%p)\n", __func__, ptr); pr_debug("%s(0x%p)\n", __func__, ptr);
...@@ -812,7 +814,7 @@ EXPORT_SYMBOL(kmemleak_not_leak); ...@@ -812,7 +814,7 @@ EXPORT_SYMBOL(kmemleak_not_leak);
* corresponding block is not a leak and does not contain any references to * corresponding block is not a leak and does not contain any references to
* other allocated memory blocks. * other allocated memory blocks.
*/ */
void kmemleak_ignore(const void *ptr) void __ref kmemleak_ignore(const void *ptr)
{ {
pr_debug("%s(0x%p)\n", __func__, ptr); pr_debug("%s(0x%p)\n", __func__, ptr);
...@@ -826,8 +828,8 @@ EXPORT_SYMBOL(kmemleak_ignore); ...@@ -826,8 +828,8 @@ EXPORT_SYMBOL(kmemleak_ignore);
/* /*
* Limit the range to be scanned in an allocated memory block. * Limit the range to be scanned in an allocated memory block.
*/ */
void kmemleak_scan_area(const void *ptr, unsigned long offset, size_t length, void __ref kmemleak_scan_area(const void *ptr, unsigned long offset,
gfp_t gfp) size_t length, gfp_t gfp)
{ {
pr_debug("%s(0x%p)\n", __func__, ptr); pr_debug("%s(0x%p)\n", __func__, ptr);
...@@ -841,7 +843,7 @@ EXPORT_SYMBOL(kmemleak_scan_area); ...@@ -841,7 +843,7 @@ EXPORT_SYMBOL(kmemleak_scan_area);
/* /*
* Inform kmemleak not to scan the given memory block. * Inform kmemleak not to scan the given memory block.
*/ */
void kmemleak_no_scan(const void *ptr) void __ref kmemleak_no_scan(const void *ptr)
{ {
pr_debug("%s(0x%p)\n", __func__, ptr); pr_debug("%s(0x%p)\n", __func__, ptr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment