ANDROID: vendor_hooks: add hooks for slab memory leak debugging
Add hooks and additional fields in vm_struct and track structs to store and report additional information for slab memory leak debugging. Bug: 184928480 Change-Id: I6897a6a98d4eaaea492673cefd4111a7ba741940 Signed-off-by: Liujie Xie <xieliujie@oppo.com>
This commit is contained in:
@@ -293,3 +293,6 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sd_update_bus_speed_mode);
|
|||||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mmc_attach_sd);
|
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mmc_attach_sd);
|
||||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sdhci_get_cd);
|
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sdhci_get_cd);
|
||||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mmc_gpio_cd_irqt);
|
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mmc_gpio_cd_irqt);
|
||||||
|
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_save_vmalloc_stack);
|
||||||
|
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_show_stack_hash);
|
||||||
|
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_save_track_hash);
|
||||||
|
@@ -9,6 +9,7 @@
|
|||||||
#include <asm/page.h> /* pgprot_t */
|
#include <asm/page.h> /* pgprot_t */
|
||||||
#include <linux/rbtree.h>
|
#include <linux/rbtree.h>
|
||||||
#include <linux/overflow.h>
|
#include <linux/overflow.h>
|
||||||
|
#include <linux/android_vendor.h>
|
||||||
|
|
||||||
#include <asm/vmalloc.h>
|
#include <asm/vmalloc.h>
|
||||||
|
|
||||||
@@ -57,6 +58,7 @@ struct vm_struct {
|
|||||||
unsigned int nr_pages;
|
unsigned int nr_pages;
|
||||||
phys_addr_t phys_addr;
|
phys_addr_t phys_addr;
|
||||||
const void *caller;
|
const void *caller;
|
||||||
|
ANDROID_OEM_DATA(1);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct vmap_area {
|
struct vmap_area {
|
||||||
|
@@ -78,6 +78,15 @@ DECLARE_HOOK(android_vh_mm_dirty_limits,
|
|||||||
unsigned long nr_reclaimable, unsigned long pages_dirtied),
|
unsigned long nr_reclaimable, unsigned long pages_dirtied),
|
||||||
TP_ARGS(gdtc, strictlimit, dirty, bg_thresh,
|
TP_ARGS(gdtc, strictlimit, dirty, bg_thresh,
|
||||||
nr_reclaimable, pages_dirtied));
|
nr_reclaimable, pages_dirtied));
|
||||||
|
DECLARE_HOOK(android_vh_save_vmalloc_stack,
|
||||||
|
TP_PROTO(unsigned long flags, struct vm_struct *vm),
|
||||||
|
TP_ARGS(flags, vm));
|
||||||
|
DECLARE_HOOK(android_vh_show_stack_hash,
|
||||||
|
TP_PROTO(struct seq_file *m, struct vm_struct *v),
|
||||||
|
TP_ARGS(m, v));
|
||||||
|
DECLARE_HOOK(android_vh_save_track_hash,
|
||||||
|
TP_PROTO(unsigned long p),
|
||||||
|
TP_ARGS(p));
|
||||||
/* macro versions of hooks are no longer required */
|
/* macro versions of hooks are no longer required */
|
||||||
|
|
||||||
#endif /* _TRACE_HOOK_MM_H */
|
#endif /* _TRACE_HOOK_MM_H */
|
||||||
|
@@ -46,6 +46,7 @@ struct kmem_cache {
|
|||||||
#include <linux/kmemleak.h>
|
#include <linux/kmemleak.h>
|
||||||
#include <linux/random.h>
|
#include <linux/random.h>
|
||||||
#include <linux/sched/mm.h>
|
#include <linux/sched/mm.h>
|
||||||
|
#include <linux/android_vendor.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* State of the slab allocator.
|
* State of the slab allocator.
|
||||||
@@ -104,6 +105,9 @@ struct track {
|
|||||||
int cpu; /* Was running on cpu */
|
int cpu; /* Was running on cpu */
|
||||||
int pid; /* Pid context */
|
int pid; /* Pid context */
|
||||||
unsigned long when; /* When did the operation occur */
|
unsigned long when; /* When did the operation occur */
|
||||||
|
#ifdef CONFIG_STACKTRACE
|
||||||
|
ANDROID_OEM_DATA(1);
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
enum track_item { TRACK_ALLOC, TRACK_FREE };
|
enum track_item { TRACK_ALLOC, TRACK_FREE };
|
||||||
|
@@ -37,6 +37,7 @@
|
|||||||
#include <linux/random.h>
|
#include <linux/random.h>
|
||||||
|
|
||||||
#include <trace/events/kmem.h>
|
#include <trace/events/kmem.h>
|
||||||
|
#include <trace/hooks/mm.h>
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
@@ -609,6 +610,7 @@ static void set_track(struct kmem_cache *s, void *object,
|
|||||||
|
|
||||||
if (nr_entries < TRACK_ADDRS_COUNT)
|
if (nr_entries < TRACK_ADDRS_COUNT)
|
||||||
p->addrs[nr_entries] = 0;
|
p->addrs[nr_entries] = 0;
|
||||||
|
trace_android_vh_save_track_hash((unsigned long)p);
|
||||||
#endif
|
#endif
|
||||||
p->addr = addr;
|
p->addr = addr;
|
||||||
p->cpu = smp_processor_id();
|
p->cpu = smp_processor_id();
|
||||||
|
@@ -34,6 +34,7 @@
|
|||||||
#include <linux/bitops.h>
|
#include <linux/bitops.h>
|
||||||
#include <linux/rbtree_augmented.h>
|
#include <linux/rbtree_augmented.h>
|
||||||
#include <linux/overflow.h>
|
#include <linux/overflow.h>
|
||||||
|
#include <trace/hooks/mm.h>
|
||||||
|
|
||||||
#include <linux/uaccess.h>
|
#include <linux/uaccess.h>
|
||||||
#include <asm/tlbflush.h>
|
#include <asm/tlbflush.h>
|
||||||
@@ -2033,6 +2034,7 @@ static inline void setup_vmalloc_vm_locked(struct vm_struct *vm,
|
|||||||
vm->size = va->va_end - va->va_start;
|
vm->size = va->va_end - va->va_start;
|
||||||
vm->caller = caller;
|
vm->caller = caller;
|
||||||
va->vm = vm;
|
va->vm = vm;
|
||||||
|
trace_android_vh_save_vmalloc_stack(flags, vm);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setup_vmalloc_vm(struct vm_struct *vm, struct vmap_area *va,
|
static void setup_vmalloc_vm(struct vm_struct *vm, struct vmap_area *va,
|
||||||
@@ -3550,6 +3552,7 @@ static int s_show(struct seq_file *m, void *p)
|
|||||||
seq_puts(m, " vpages");
|
seq_puts(m, " vpages");
|
||||||
|
|
||||||
show_numa_info(m, v);
|
show_numa_info(m, v);
|
||||||
|
trace_android_vh_show_stack_hash(m, v);
|
||||||
seq_putc(m, '\n');
|
seq_putc(m, '\n');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user