mm: Don't build mm_dump_obj() on CONFIG_PRINTK=n kernels
The mem_dump_obj() functionality adds a few hundred bytes, which is a small price to pay. Except on kernels built with CONFIG_PRINTK=n, in which mem_dump_obj() messages will be suppressed. This commit therefore makes mem_dump_obj() be a static inline empty function on kernels built with CONFIG_PRINTK=n and excludes all of its support functions as well. This avoids kernel bloat on systems that cannot use mem_dump_obj(). Cc: Christoph Lameter <cl@linux.com> Cc: Pekka Enberg <penberg@kernel.org> Cc: David Rientjes <rientjes@google.com> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com> Cc: <linux-mm@kvack.org> Suggested-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
This commit is contained in:
parent
a38fd87484
commit
5bb1bb353c
|
@ -3135,7 +3135,11 @@ unsigned long wp_shared_mapping_range(struct address_space *mapping,
|
|||
|
||||
extern int sysctl_nr_trim_pages;
|
||||
|
||||
#ifdef CONFIG_PRINTK
|
||||
void mem_dump_obj(void *object);
|
||||
#else
|
||||
static inline void mem_dump_obj(void *object) {}
|
||||
#endif
|
||||
|
||||
#endif /* __KERNEL__ */
|
||||
#endif /* _LINUX_MM_H */
|
||||
|
|
|
@ -186,8 +186,10 @@ void kfree(const void *);
|
|||
void kfree_sensitive(const void *);
|
||||
size_t __ksize(const void *);
|
||||
size_t ksize(const void *);
|
||||
#ifdef CONFIG_PRINTK
|
||||
bool kmem_valid_obj(void *object);
|
||||
void kmem_dump_obj(void *object);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_HAVE_HARDENED_USERCOPY_ALLOCATOR
|
||||
void __check_heap_object(const void *ptr, unsigned long n, struct page *page,
|
||||
|
|
|
@ -241,7 +241,7 @@ pcpu_free_vm_areas(struct vm_struct **vms, int nr_vms)
|
|||
int register_vmap_purge_notifier(struct notifier_block *nb);
|
||||
int unregister_vmap_purge_notifier(struct notifier_block *nb);
|
||||
|
||||
#ifdef CONFIG_MMU
|
||||
#if defined(CONFIG_MMU) && defined(CONFIG_PRINTK)
|
||||
bool vmalloc_dump_obj(void *object);
|
||||
#else
|
||||
static inline bool vmalloc_dump_obj(void *object) { return false; }
|
||||
|
|
|
@ -3651,6 +3651,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t flags,
|
|||
EXPORT_SYMBOL(__kmalloc_node_track_caller);
|
||||
#endif /* CONFIG_NUMA */
|
||||
|
||||
#ifdef CONFIG_PRINTK
|
||||
void kmem_obj_info(struct kmem_obj_info *kpp, void *object, struct page *page)
|
||||
{
|
||||
struct kmem_cache *cachep;
|
||||
|
@ -3670,6 +3671,7 @@ void kmem_obj_info(struct kmem_obj_info *kpp, void *object, struct page *page)
|
|||
if (DEBUG && cachep->flags & SLAB_STORE_USER)
|
||||
kpp->kp_ret = *dbg_userword(cachep, objp);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* __do_kmalloc - allocate memory
|
||||
|
|
|
@ -619,6 +619,7 @@ static inline bool slab_want_init_on_free(struct kmem_cache *c)
|
|||
return false;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PRINTK
|
||||
#define KS_ADDRS_COUNT 16
|
||||
struct kmem_obj_info {
|
||||
void *kp_ptr;
|
||||
|
@ -630,5 +631,6 @@ struct kmem_obj_info {
|
|||
void *kp_stack[KS_ADDRS_COUNT];
|
||||
};
|
||||
void kmem_obj_info(struct kmem_obj_info *kpp, void *object, struct page *page);
|
||||
#endif
|
||||
|
||||
#endif /* MM_SLAB_H */
|
||||
|
|
|
@ -526,6 +526,7 @@ bool slab_is_available(void)
|
|||
return slab_state >= UP;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PRINTK
|
||||
/**
|
||||
* kmem_valid_obj - does the pointer reference a valid slab object?
|
||||
* @object: pointer to query.
|
||||
|
@ -600,6 +601,7 @@ void kmem_dump_obj(void *object)
|
|||
pr_info(" %pS\n", kp.kp_stack[i]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_SLOB
|
||||
/* Create a cache during boot when no slab services are available yet */
|
||||
|
|
|
@ -461,11 +461,13 @@ out:
|
|||
spin_unlock_irqrestore(&slob_lock, flags);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PRINTK
|
||||
void kmem_obj_info(struct kmem_obj_info *kpp, void *object, struct page *page)
|
||||
{
|
||||
kpp->kp_ptr = object;
|
||||
kpp->kp_page = page;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* End of slob allocator proper. Begin kmem_cache_alloc and kmalloc frontend.
|
||||
|
|
|
@ -3963,6 +3963,7 @@ int __kmem_cache_shutdown(struct kmem_cache *s)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PRINTK
|
||||
void kmem_obj_info(struct kmem_obj_info *kpp, void *object, struct page *page)
|
||||
{
|
||||
void *base;
|
||||
|
@ -4002,6 +4003,7 @@ void kmem_obj_info(struct kmem_obj_info *kpp, void *object, struct page *page)
|
|||
#endif
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/********************************************************************
|
||||
* Kmalloc subsystem
|
||||
|
|
|
@ -983,6 +983,7 @@ int __weak memcmp_pages(struct page *page1, struct page *page2)
|
|||
return ret;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PRINTK
|
||||
/**
|
||||
* mem_dump_obj - Print available provenance information
|
||||
* @object: object for which to find provenance information.
|
||||
|
@ -1013,3 +1014,4 @@ void mem_dump_obj(void *object)
|
|||
}
|
||||
pr_cont(" non-slab/vmalloc memory.\n");
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -3450,6 +3450,7 @@ void pcpu_free_vm_areas(struct vm_struct **vms, int nr_vms)
|
|||
}
|
||||
#endif /* CONFIG_SMP */
|
||||
|
||||
#ifdef CONFIG_PRINTK
|
||||
bool vmalloc_dump_obj(void *object)
|
||||
{
|
||||
struct vm_struct *vm;
|
||||
|
@ -3462,6 +3463,7 @@ bool vmalloc_dump_obj(void *object)
|
|||
vm->nr_pages, (unsigned long)vm->addr, vm->caller);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PROC_FS
|
||||
static void *s_start(struct seq_file *m, loff_t *pos)
|
||||
|
|
Loading…
Reference in New Issue