ANDROID: vendor_hooks: Add hooks for memory when debug

Add vendors hooks for recording memory used

Bug: 182443489
Signed-off-by: Liujie Xie <xieliujie@oppo.com>
Change-Id: I62d8bb2b6650d8b187b433f97eb833ef0b784df1
This commit is contained in:
Liujie Xie 2021-03-11 20:40:06 +08:00 committed by Todd Kjos
parent 00185a421a
commit 24149445ad
7 changed files with 37 additions and 4 deletions

View File

@ -205,3 +205,9 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_set_memory_rw);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_set_module_permit_before_init);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_set_module_permit_after_init);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_util_est_update);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_meminfo_proc_show);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_exit_mm);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alloc_pages_slowpath);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_show_mem);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_print_slabinfo_header);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cache_show);

View File

@ -18,7 +18,7 @@
#endif
#include <asm/page.h>
#include "internal.h"
#include <trace/hooks/mm.h>
void __attribute__((weak)) arch_report_meminfo(struct seq_file *m)
{
}
@ -145,6 +145,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
show_val_kb(m, "CmaFree: ",
global_zone_page_state(NR_FREE_CMA_PAGES));
#endif
trace_android_vh_meminfo_proc_show(m);
hugetlb_report_meminfo(m);

View File

@ -32,6 +32,25 @@ DECLARE_HOOK(android_vh_pagecache_get_page,
TP_PROTO(struct address_space *mapping, pgoff_t index,
int fgp_flags, gfp_t gfp_mask, struct page *page),
TP_ARGS(mapping, index, fgp_flags, gfp_mask, page));
DECLARE_HOOK(android_vh_meminfo_proc_show,
TP_PROTO(struct seq_file *m),
TP_ARGS(m));
DECLARE_HOOK(android_vh_exit_mm,
TP_PROTO(struct mm_struct *mm),
TP_ARGS(mm));
DECLARE_HOOK(android_vh_show_mem,
TP_PROTO(unsigned int filter, nodemask_t *nodemask),
TP_ARGS(filter, nodemask));
DECLARE_HOOK(android_vh_alloc_pages_slowpath,
TP_PROTO(gfp_t gfp_mask, unsigned int order, unsigned long delta),
TP_ARGS(gfp_mask, order, delta));
DECLARE_HOOK(android_vh_print_slabinfo_header,
TP_PROTO(struct seq_file *m),
TP_ARGS(m));
struct slabinfo;
DECLARE_HOOK(android_vh_cache_show,
TP_PROTO(struct seq_file *m, struct slabinfo *sinfo, struct kmem_cache *s),
TP_ARGS(m, sinfo, s));
/* macro versions of hooks are no longer required */
#endif /* _TRACE_HOOK_MM_H */

View File

@ -68,6 +68,7 @@
#include <linux/uaccess.h>
#include <asm/unistd.h>
#include <asm/mmu_context.h>
#include <trace/hooks/mm.h>
static void __unhash_process(struct task_struct *p, bool group_dead)
{
@ -484,6 +485,7 @@ static void exit_mm(void)
enter_lazy_tlb(mm, current);
task_unlock(current);
mm_update_next_owner(mm);
trace_android_vh_exit_mm(mm);
mmput(mm);
if (test_thread_flag(TIF_MEMDIE))
exit_oom_victim();

View File

@ -7,7 +7,7 @@
#include <linux/mm.h>
#include <linux/cma.h>
#include <trace/hooks/mm.h>
void show_mem(unsigned int filter, nodemask_t *nodemask)
{
pg_data_t *pgdat;
@ -41,4 +41,5 @@ void show_mem(unsigned int filter, nodemask_t *nodemask)
#ifdef CONFIG_MEMORY_FAILURE
printk("%lu pages hwpoisoned\n", atomic_long_read(&num_poisoned_pages));
#endif
trace_android_vh_show_mem(filter, nodemask);
}

View File

@ -4692,7 +4692,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
int no_progress_loops;
unsigned int cpuset_mems_cookie;
int reserve_flags;
unsigned long alloc_start = jiffies;
/*
* We also sanity check to catch abuse of atomic reserves being used by
* callers that are not in atomic context.
@ -4934,6 +4934,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
warn_alloc(gfp_mask, ac->nodemask,
"page allocation failure: order:%u", order);
got_pg:
trace_android_vh_alloc_pages_slowpath(gfp_mask, order, alloc_start);
return page;
}

View File

@ -27,7 +27,8 @@
#define CREATE_TRACE_POINTS
#include <trace/events/kmem.h>
#undef CREATE_TRACE_POINTS
#include <trace/hooks/mm.h>
#include "internal.h"
#include "slab.h"
@ -933,6 +934,7 @@ static void print_slabinfo_header(struct seq_file *m)
seq_puts(m, " : globalstat <listallocs> <maxobjs> <grown> <reaped> <error> <maxfreeable> <nodeallocs> <remotefrees> <alienoverflow>");
seq_puts(m, " : cpustat <allochit> <allocmiss> <freehit> <freemiss>");
#endif
trace_android_vh_print_slabinfo_header(m);
seq_putc(m, '\n');
}
@ -968,6 +970,7 @@ static void cache_show(struct kmem_cache *s, struct seq_file *m)
seq_printf(m, " : slabdata %6lu %6lu %6lu",
sinfo.active_slabs, sinfo.num_slabs, sinfo.shared_avail);
slabinfo_show_stats(m, s);
trace_android_vh_cache_show(m, &sinfo, s);
seq_putc(m, '\n');
}