Porting hooks from 5.10 and move zram to ko

Change-Id: I576f9dc68a31900b6fbbe629edbb01cf8a723d8d
Signed-off-by: huangzq2 <huangzq2@motorola.com>
Reviewed-on: https://gerrit.mot.com/2747021
Reviewed-by: Xiangpo Zhao <zhaoxp3@motorola.com>
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Submit-Approved: Jira Key
This commit is contained in:
huangzq2 2023-09-21 10:22:16 +08:00 • committed by Xiaojun Ji
commit f62f91132a
7 changed files with 130 additions and 0 deletions

View file

@ -20,6 +20,7 @@ CONFIG_IOMMU_IO_PGTABLE_FAST=y
CONFIG_QCOM_LLCC_PERFMON=m
CONFIG_SCHED_WALT=y
CONFIG_QGKI=y
CONFIG_ZRAM=m
CONFIG_REGULATOR_QTI_DEBUG=y
CONFIG_REGMAP_QTI_DEBUG=y
CONFIG_REGMAP_ALLOW_WRITE_DEBUGFS=y

View file

@ -17,11 +17,13 @@
#include <trace/hooks/fpsimd.h>
#include <trace/hooks/topology.h>
#include <trace/hooks/debug.h>
#include <trace/hooks/mm.h>
#include <trace/hooks/minidump.h>
#include <trace/hooks/wqlockup.h>
#include <trace/hooks/sysrqcrash.h>
#include <trace/hooks/cgroup.h>
#include <trace/hooks/sys.h>
#include <trace/hooks/vmscan.h>
/*
* Export tracepoints that act as a bare tracehook (ie: have no trace event
@ -71,5 +73,14 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sysrq_crash);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_find_busiest_group);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_map_util_freq);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_em_pd_energy);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rmqueue);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cgroup_set_task);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_syscall_prctl_finished);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_tune_scan_type);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_tune_swappiness);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_tune_inactive_ratio);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mem_cgroup_id_remove);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mem_cgroup_css_offline);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mem_cgroup_css_online);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mem_cgroup_free);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mem_cgroup_alloc);

78
include/trace/hooks/mm.h Normal file
View file

@ -0,0 +1,78 @@
/* SPDX-License-Identifier: GPL-2.0 */
#ifdef PROTECT_TRACE_INCLUDE_PATH
#undef PROTECT_TRACE_INCLUDE_PATH
#include <trace/hooks/save_incpath.h>
#include <trace/hooks/mm.h>
#include <trace/hooks/restore_incpath.h>
#else /* PROTECT_TRACE_INCLUDE_PATH */
#undef TRACE_SYSTEM
#define TRACE_SYSTEM mm
#define TRACE_INCLUDE_PATH trace/hooks
#if !defined(_TRACE_HOOK_MM_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_HOOK_MM_H
#include <linux/types.h>
#include <linux/mm.h>
#include <linux/oom.h>
#include <linux/tracepoint.h>
#include <trace/hooks/vendor_hooks.h>
#include <linux/rwsem.h>
#ifdef __GENKSYMS__
struct slabinfo;
struct cgroup_subsys_state;
struct device;
struct mem_cgroup;
struct readahead_control;
#else
/* struct slabinfo */
#include <../mm/slab.h>
/* struct cgroup_subsys_state */
#include <linux/cgroup-defs.h>
/* struct device */
#include <linux/device.h>
/* struct mem_cgroup */
#include <linux/memcontrol.h>
/* struct readahead_control */
#include <linux/pagemap.h>
#endif /* __GENKSYMS__ */
struct cma;
struct swap_slots_cache;
struct page_vma_mapped_walk;
DECLARE_HOOK(android_vh_rmqueue,
TP_PROTO(struct zone *preferred_zone, struct zone *zone,
unsigned int order, gfp_t gfp_flags,
unsigned int alloc_flags, int migratetype),
TP_ARGS(preferred_zone, zone, order,
gfp_flags, alloc_flags, migratetype));
DECLARE_HOOK(android_vh_mem_cgroup_alloc,
TP_PROTO(struct mem_cgroup *memcg),
TP_ARGS(memcg));
DECLARE_HOOK(android_vh_mem_cgroup_free,
TP_PROTO(struct mem_cgroup *memcg),
TP_ARGS(memcg));
DECLARE_HOOK(android_vh_mem_cgroup_id_remove,
TP_PROTO(struct mem_cgroup *memcg),
TP_ARGS(memcg));
DECLARE_HOOK(android_vh_mem_cgroup_css_online,
TP_PROTO(struct cgroup_subsys_state *css, struct mem_cgroup *memcg),
TP_ARGS(css, memcg));
DECLARE_HOOK(android_vh_mem_cgroup_css_offline,
TP_PROTO(struct cgroup_subsys_state *css, struct mem_cgroup *memcg),
TP_ARGS(css, memcg));
/* macro versions of hooks are no longer required */
#endif /* _TRACE_HOOK_MM_H */
/* This part must be outside protection */
#include <trace/define_trace.h>
#endif /* PROTECT_TRACE_INCLUDE_PATH */

View file

@ -0,0 +1,24 @@
/* SPDX-License-Identifier: GPL-2.0 */
#undef TRACE_SYSTEM
#define TRACE_SYSTEM vmscan
#define TRACE_INCLUDE_PATH trace/hooks
#if !defined(_TRACE_HOOK_VMSCAN_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_HOOK_VMSCAN_H
#include <linux/tracepoint.h>
#include <trace/hooks/vendor_hooks.h>
DECLARE_HOOK(android_vh_tune_scan_type,
TP_PROTO(char *scan_type),
TP_ARGS(scan_type));
DECLARE_HOOK(android_vh_tune_swappiness,
TP_PROTO(int *swappiness),
TP_ARGS(swappiness));
DECLARE_HOOK(android_vh_tune_inactive_ratio,
TP_PROTO(unsigned long *inactive_ratio, int file),
TP_ARGS(inactive_ratio, file))
#endif /* _TRACE_HOOK_VMSCAN_H */
/* This part must be outside protection */
#include <trace/define_trace.h>

View file

@ -67,6 +67,7 @@
#include <linux/uaccess.h>
#include <trace/events/vmscan.h>
#include <trace/hooks/mm.h>
struct cgroup_subsys memory_cgrp_subsys __read_mostly;
EXPORT_SYMBOL(memory_cgrp_subsys);
@ -5005,6 +5006,7 @@ static DEFINE_IDR(mem_cgroup_idr);
static void mem_cgroup_id_remove(struct mem_cgroup *memcg)
{
if (memcg->id.id > 0) {
trace_android_vh_mem_cgroup_id_remove(memcg);
idr_remove(&mem_cgroup_idr, memcg->id.id);
memcg->id.id = 0;
}
@ -5098,6 +5100,7 @@ static void __mem_cgroup_free(struct mem_cgroup *memcg)
{
int node;
trace_android_vh_mem_cgroup_free(memcg);
for_each_node(node)
free_mem_cgroup_per_node_info(memcg, node);
free_percpu(memcg->vmstats_percpu);
@ -5179,6 +5182,7 @@ static struct mem_cgroup *mem_cgroup_alloc(void)
memcg->deferred_split_queue.split_queue_len = 0;
#endif
idr_replace(&mem_cgroup_idr, memcg, memcg->id.id);
trace_android_vh_mem_cgroup_alloc(memcg);
return memcg;
fail:
mem_cgroup_id_remove(memcg);
@ -5265,6 +5269,7 @@ static int mem_cgroup_css_online(struct cgroup_subsys_state *css)
/* Online state pins memcg ID, memcg ID pins CSS */
refcount_set(&memcg->id.ref, 1);
css_get(css);
trace_android_vh_mem_cgroup_css_online(css, memcg);
return 0;
}
@ -5273,6 +5278,7 @@ static void mem_cgroup_css_offline(struct cgroup_subsys_state *css)
struct mem_cgroup *memcg = mem_cgroup_from_css(css);
struct mem_cgroup_event *event, *tmp;
trace_android_vh_mem_cgroup_css_offline(css, memcg);
/*
* Unregister events and notify userspace.
* Notify userspace about cgroup removing only after rmdir of cgroup

View file

@ -70,6 +70,7 @@
#include <linux/nmi.h>
#include <linux/psi.h>
#include <linux/khugepaged.h>
#include <trace/hooks/mm.h>
#include <asm/sections.h>
#include <asm/tlbflush.h>
@ -3414,6 +3415,8 @@ struct page *rmqueue(struct zone *preferred_zone,
__count_zid_vm_events(PGALLOC, page_zonenum(page), 1 << order);
zone_statistics(preferred_zone, zone);
trace_android_vh_rmqueue(preferred_zone, zone, order,
gfp_flags, alloc_flags, migratetype);
local_irq_restore(flags);
out:

View file

@ -63,6 +63,9 @@
#define CREATE_TRACE_POINTS
#include <trace/events/vmscan.h>
#undef CREATE_TRACE_POINTS
#include <trace/hooks/vmscan.h>
struct scan_control {
/* How many pages shrink_list() should reclaim */
unsigned long nr_to_reclaim;
@ -2341,6 +2344,8 @@ static bool inactive_list_is_low(struct lruvec *lruvec, bool file,
lruvec_lru_size(lruvec, active_lru, MAX_NR_ZONES), active,
inactive_ratio, file);
trace_android_vh_tune_inactive_ratio(&inactive_ratio, is_file_lru(inactive_lru));
return inactive * inactive_ratio < active;
}
@ -2393,6 +2398,7 @@ static void get_scan_count(struct lruvec *lruvec, struct mem_cgroup *memcg,
goto out;
}
trace_android_vh_tune_swappiness(&swappiness);
/*
* Global reclaim will swap to prevent OOM even with no
* swappiness, but memcg users want to use this knob to
@ -2526,6 +2532,7 @@ static void get_scan_count(struct lruvec *lruvec, struct mem_cgroup *memcg,
fraction[1] = fp;
denominator = ap + fp + 1;
out:
trace_android_vh_tune_scan_type((char *)(&scan_balance));
*lru_pages = 0;
for_each_evictable_lru(lru) {
int file = is_file_lru(lru);