1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifdef PROTECT_TRACE_INCLUDE_PATH 3 #undef PROTECT_TRACE_INCLUDE_PATH 4 5 #include <trace/hooks/save_incpath.h> 6 #include <trace/hooks/mm.h> 7 #include <trace/hooks/restore_incpath.h> 8 9 #else /* PROTECT_TRACE_INCLUDE_PATH */ 10 11 #undef TRACE_SYSTEM 12 #define TRACE_SYSTEM mm 13 14 #define TRACE_INCLUDE_PATH trace/hooks 15 16 #if !defined(_TRACE_HOOK_MM_H) || defined(TRACE_HEADER_MULTI_READ) 17 #define _TRACE_HOOK_MM_H 18 19 #include <linux/types.h> 20 21 #include <linux/mm.h> 22 #include <linux/oom.h> 23 #include <linux/tracepoint.h> 24 #include <trace/hooks/vendor_hooks.h> 25 #include <linux/rwsem.h> 26 27 #ifdef __GENKSYMS__ 28 struct slabinfo; 29 struct cgroup_subsys_state; 30 struct device; 31 struct mem_cgroup; 32 struct readahead_control; 33 #else 34 /* struct slabinfo */ 35 #include <../mm/slab.h> 36 /* struct cgroup_subsys_state */ 37 #include <linux/cgroup-defs.h> 38 /* struct device */ 39 #include <linux/device.h> 40 /* struct mem_cgroup */ 41 #include <linux/memcontrol.h> 42 /* struct readahead_control */ 43 #include <linux/pagemap.h> 44 #endif /* __GENKSYMS__ */ 45 struct cma; 46 struct swap_slots_cache; 47 struct page_vma_mapped_walk; 48 49 DECLARE_RESTRICTED_HOOK(android_rvh_set_skip_swapcache_flags, 50 TP_PROTO(gfp_t *flags), 51 TP_ARGS(flags), 1); 52 DECLARE_RESTRICTED_HOOK(android_rvh_set_gfp_zone_flags, 53 TP_PROTO(gfp_t *flags), 54 TP_ARGS(flags), 1); 55 DECLARE_RESTRICTED_HOOK(android_rvh_set_readahead_gfp_mask, 56 TP_PROTO(gfp_t *flags), 57 TP_ARGS(flags), 1); 58 DECLARE_HOOK(android_vh_cma_alloc_start, 59 TP_PROTO(s64 *ts), 60 TP_ARGS(ts)); 61 DECLARE_HOOK(android_vh_cma_alloc_finish, 62 TP_PROTO(struct cma *cma, struct page *page, unsigned long count, 63 unsigned int align, gfp_t gfp_mask, s64 ts), 64 TP_ARGS(cma, page, count, align, gfp_mask, ts)); 65 DECLARE_HOOK(android_vh_rmqueue, 66 TP_PROTO(struct zone *preferred_zone, struct zone *zone, 67 unsigned int order, gfp_t gfp_flags, 68 unsigned int alloc_flags, int migratetype), 69 TP_ARGS(preferred_zone, zone, order, 70 gfp_flags, alloc_flags, migratetype)); 71 DECLARE_HOOK(android_vh_pagecache_get_page, 72 TP_PROTO(struct address_space *mapping, pgoff_t index, 73 int fgp_flags, gfp_t gfp_mask, struct page *page), 74 TP_ARGS(mapping, index, fgp_flags, gfp_mask, page)); 75 DECLARE_HOOK(android_vh_filemap_fault_get_page, 76 TP_PROTO(struct vm_fault *vmf, struct page **page, bool *retry), 77 TP_ARGS(vmf, page, retry)); 78 DECLARE_HOOK(android_vh_filemap_fault_cache_page, 79 TP_PROTO(struct vm_fault *vmf, struct page *page), 80 TP_ARGS(vmf, page)); 81 DECLARE_HOOK(android_vh_meminfo_proc_show, 82 TP_PROTO(struct seq_file *m), 83 TP_ARGS(m)); 84 DECLARE_HOOK(android_vh_exit_mm, 85 TP_PROTO(struct mm_struct *mm), 86 TP_ARGS(mm)); 87 DECLARE_HOOK(android_vh_get_from_fragment_pool, 88 TP_PROTO(struct mm_struct *mm, struct vm_unmapped_area_info *info, 89 unsigned long *addr), 90 TP_ARGS(mm, info, addr)); 91 DECLARE_HOOK(android_vh_exclude_reserved_zone, 92 TP_PROTO(struct mm_struct *mm, struct vm_unmapped_area_info *info), 93 TP_ARGS(mm, info)); 94 DECLARE_HOOK(android_vh_include_reserved_zone, 95 TP_PROTO(struct mm_struct *mm, struct vm_unmapped_area_info *info, 96 unsigned long *addr), 97 TP_ARGS(mm, info, addr)); 98 DECLARE_HOOK(android_vh_show_mem, 99 TP_PROTO(unsigned int filter, nodemask_t *nodemask), 100 TP_ARGS(filter, nodemask)); 101 DECLARE_HOOK(android_vh_alloc_pages_slowpath_begin, 102 TP_PROTO(gfp_t gfp_mask, unsigned int order, unsigned long *pdata), 103 TP_ARGS(gfp_mask, order, pdata)); 104 DECLARE_HOOK(android_vh_alloc_pages_slowpath_end, 105 TP_PROTO(gfp_t gfp_mask, unsigned int order, unsigned long data), 106 TP_ARGS(gfp_mask, order, data)); 107 struct dirty_throttle_control; 108 DECLARE_HOOK(android_vh_mm_dirty_limits, 109 TP_PROTO(struct dirty_throttle_control *const gdtc, bool strictlimit, 110 unsigned long dirty, unsigned long bg_thresh, 111 unsigned long nr_reclaimable, unsigned long pages_dirtied), 112 TP_ARGS(gdtc, strictlimit, dirty, bg_thresh, 113 nr_reclaimable, pages_dirtied)); 114 DECLARE_HOOK(android_vh_oom_check_panic, 115 TP_PROTO(struct oom_control *oc, int *ret), 116 TP_ARGS(oc, ret)); 117 DECLARE_HOOK(android_vh_save_vmalloc_stack, 118 TP_PROTO(unsigned long flags, struct vm_struct *vm), 119 TP_ARGS(flags, vm)); 120 DECLARE_HOOK(android_vh_show_stack_hash, 121 TP_PROTO(struct seq_file *m, struct vm_struct *v), 122 TP_ARGS(m, v)); 123 DECLARE_HOOK(android_vh_save_track_hash, 124 TP_PROTO(bool alloc, unsigned long p), 125 TP_ARGS(alloc, p)); 126 DECLARE_HOOK(android_vh_vmpressure, 127 TP_PROTO(struct mem_cgroup *memcg, bool *bypass), 128 TP_ARGS(memcg, bypass)); 129 DECLARE_HOOK(android_vh_mem_cgroup_alloc, 130 TP_PROTO(struct mem_cgroup *memcg), 131 TP_ARGS(memcg)); 132 DECLARE_HOOK(android_vh_mem_cgroup_free, 133 TP_PROTO(struct mem_cgroup *memcg), 134 TP_ARGS(memcg)); 135 DECLARE_HOOK(android_vh_mem_cgroup_id_remove, 136 TP_PROTO(struct mem_cgroup *memcg), 137 TP_ARGS(memcg)); 138 DECLARE_HOOK(android_vh_mem_cgroup_css_online, 139 TP_PROTO(struct cgroup_subsys_state *css, struct mem_cgroup *memcg), 140 TP_ARGS(css, memcg)); 141 DECLARE_HOOK(android_vh_mem_cgroup_css_offline, 142 TP_PROTO(struct cgroup_subsys_state *css, struct mem_cgroup *memcg), 143 TP_ARGS(css, memcg)); 144 DECLARE_HOOK(android_vh_kmalloc_slab, 145 TP_PROTO(unsigned int index, gfp_t flags, struct kmem_cache **s), 146 TP_ARGS(index, flags, s)); 147 DECLARE_HOOK(android_vh_mmap_region, 148 TP_PROTO(struct vm_area_struct *vma, unsigned long addr), 149 TP_ARGS(vma, addr)); 150 DECLARE_HOOK(android_vh_try_to_unmap_one, 151 TP_PROTO(struct vm_area_struct *vma, struct page *page, unsigned long addr, bool ret), 152 TP_ARGS(vma, page, addr, ret)); 153 DECLARE_HOOK(android_vh_do_page_trylock, 154 TP_PROTO(struct page *page, struct rw_semaphore *sem, 155 bool *got_lock, bool *success), 156 TP_ARGS(page, sem, got_lock, success)); 157 DECLARE_HOOK(android_vh_drain_all_pages_bypass, 158 TP_PROTO(gfp_t gfp_mask, unsigned int order, unsigned long alloc_flags, 159 int migratetype, unsigned long did_some_progress, 160 bool *bypass), 161 TP_ARGS(gfp_mask, order, alloc_flags, migratetype, did_some_progress, bypass)); 162 DECLARE_HOOK(android_vh_update_page_mapcount, 163 TP_PROTO(struct page *page, bool inc_size, bool compound, 164 bool *first_mapping, bool *success), 165 TP_ARGS(page, inc_size, compound, first_mapping, success)); 166 DECLARE_HOOK(android_vh_add_page_to_lrulist, 167 TP_PROTO(struct page *page, bool compound, enum lru_list lru), 168 TP_ARGS(page, compound, lru)); 169 DECLARE_HOOK(android_vh_del_page_from_lrulist, 170 TP_PROTO(struct page *page, bool compound, enum lru_list lru), 171 TP_ARGS(page, compound, lru)); 172 DECLARE_HOOK(android_vh_show_mapcount_pages, 173 TP_PROTO(void *unused), 174 TP_ARGS(unused)); 175 DECLARE_HOOK(android_vh_do_traversal_lruvec, 176 TP_PROTO(struct lruvec *lruvec), 177 TP_ARGS(lruvec)); 178 DECLARE_HOOK(android_vh_page_should_be_protected, 179 TP_PROTO(struct page *page, bool *should_protect), 180 TP_ARGS(page, should_protect)); 181 DECLARE_HOOK(android_vh_mark_page_accessed, 182 TP_PROTO(struct page *page), 183 TP_ARGS(page)); 184 DECLARE_HOOK(android_vh_cma_drain_all_pages_bypass, 185 TP_PROTO(unsigned int migratetype, bool *bypass), 186 TP_ARGS(migratetype, bypass)); 187 DECLARE_HOOK(android_vh_pcplist_add_cma_pages_bypass, 188 TP_PROTO(int migratetype, bool *bypass), 189 TP_ARGS(migratetype, bypass)); 190 DECLARE_HOOK(android_vh_subpage_dma_contig_alloc, 191 TP_PROTO(bool *allow_subpage_alloc, struct device *dev, size_t *size), 192 TP_ARGS(allow_subpage_alloc, dev, size)); 193 DECLARE_HOOK(android_vh_ra_tuning_max_page, 194 TP_PROTO(struct readahead_control *ractl, unsigned long *max_page), 195 TP_ARGS(ractl, max_page)); 196 DECLARE_RESTRICTED_HOOK(android_rvh_handle_pte_fault_end, 197 TP_PROTO(struct vm_fault *vmf, unsigned long highest_memmap_pfn), 198 TP_ARGS(vmf, highest_memmap_pfn), 1); 199 DECLARE_HOOK(android_vh_handle_pte_fault_end, 200 TP_PROTO(struct vm_fault *vmf, unsigned long highest_memmap_pfn), 201 TP_ARGS(vmf, highest_memmap_pfn)); 202 DECLARE_HOOK(android_vh_cow_user_page, 203 TP_PROTO(struct vm_fault *vmf, struct page *page), 204 TP_ARGS(vmf, page)); 205 DECLARE_HOOK(android_vh_swapin_add_anon_rmap, 206 TP_PROTO(struct vm_fault *vmf, struct page *page), 207 TP_ARGS(vmf, page)); 208 DECLARE_HOOK(android_vh_waiting_for_page_migration, 209 TP_PROTO(struct page *page), 210 TP_ARGS(page)); 211 DECLARE_HOOK(android_vh_migrate_page_states, 212 TP_PROTO(struct page *page, struct page *newpage), 213 TP_ARGS(page, newpage)); 214 DECLARE_HOOK(android_vh_page_referenced_one_end, 215 TP_PROTO(struct vm_area_struct *vma, struct page *page, int referenced), 216 TP_ARGS(vma, page, referenced)); 217 DECLARE_HOOK(android_vh_count_pswpin, 218 TP_PROTO(struct swap_info_struct *sis), 219 TP_ARGS(sis)); 220 DECLARE_HOOK(android_vh_count_pswpout, 221 TP_PROTO(struct swap_info_struct *sis), 222 TP_ARGS(sis)); 223 DECLARE_HOOK(android_vh_count_swpout_vm_event, 224 TP_PROTO(struct swap_info_struct *sis, struct page *page, bool *skip), 225 TP_ARGS(sis, page, skip)); 226 DECLARE_HOOK(android_vh_swap_slot_cache_active, 227 TP_PROTO(bool swap_slot_cache_active), 228 TP_ARGS(swap_slot_cache_active)); 229 DECLARE_RESTRICTED_HOOK(android_rvh_drain_slots_cache_cpu, 230 TP_PROTO(struct swap_slots_cache *cache, unsigned int type, 231 bool free_slots, bool *skip), 232 TP_ARGS(cache, type, free_slots, skip), 1); 233 DECLARE_HOOK(android_vh_drain_slots_cache_cpu, 234 TP_PROTO(struct swap_slots_cache *cache, unsigned int type, 235 bool free_slots, bool *skip), 236 TP_ARGS(cache, type, free_slots, skip)); 237 DECLARE_RESTRICTED_HOOK(android_rvh_alloc_swap_slot_cache, 238 TP_PROTO(struct swap_slots_cache *cache, int *ret, bool *skip), 239 TP_ARGS(cache, ret, skip), 1); 240 DECLARE_HOOK(android_vh_alloc_swap_slot_cache, 241 TP_PROTO(struct swap_slots_cache *cache, int *ret, bool *skip), 242 TP_ARGS(cache, ret, skip)); 243 DECLARE_RESTRICTED_HOOK(android_rvh_free_swap_slot, 244 TP_PROTO(swp_entry_t entry, struct swap_slots_cache *cache, bool *skip), 245 TP_ARGS(entry, cache, skip), 1); 246 DECLARE_HOOK(android_vh_free_swap_slot, 247 TP_PROTO(swp_entry_t entry, struct swap_slots_cache *cache, bool *skip), 248 TP_ARGS(entry, cache, skip)); 249 DECLARE_RESTRICTED_HOOK(android_rvh_get_swap_page, 250 TP_PROTO(struct page *page, swp_entry_t *entry, 251 struct swap_slots_cache *cache, bool *found), 252 TP_ARGS(page, entry, cache, found), 1); 253 DECLARE_HOOK(android_vh_get_swap_page, 254 TP_PROTO(struct page *page, swp_entry_t *entry, 255 struct swap_slots_cache *cache, bool *found), 256 TP_ARGS(page, entry, cache, found)); 257 DECLARE_HOOK(android_vh_madvise_cold_or_pageout, 258 TP_PROTO(struct vm_area_struct *vma, bool *allow_shared), 259 TP_ARGS(vma, allow_shared)); 260 DECLARE_HOOK(android_vh_page_isolated_for_reclaim, 261 TP_PROTO(struct mm_struct *mm, struct page *page), 262 TP_ARGS(mm, page)); 263 DECLARE_HOOK(android_vh_account_swap_pages, 264 TP_PROTO(struct swap_info_struct *si, bool *skip), 265 TP_ARGS(si, skip)); 266 DECLARE_HOOK(android_vh_unuse_swap_page, 267 TP_PROTO(struct swap_info_struct *si, struct page *page), 268 TP_ARGS(si, page)); 269 DECLARE_HOOK(android_vh_init_swap_info_struct, 270 TP_PROTO(struct swap_info_struct *p, struct plist_head *swap_avail_heads), 271 TP_ARGS(p, swap_avail_heads)); 272 DECLARE_HOOK(android_vh_si_swapinfo, 273 TP_PROTO(struct swap_info_struct *si, bool *skip), 274 TP_ARGS(si, skip)); 275 DECLARE_RESTRICTED_HOOK(android_rvh_alloc_si, 276 TP_PROTO(struct swap_info_struct **p, bool *skip), 277 TP_ARGS(p, skip), 1); 278 DECLARE_HOOK(android_vh_alloc_si, 279 TP_PROTO(struct swap_info_struct **p, bool *skip), 280 TP_ARGS(p, skip)); 281 DECLARE_HOOK(android_vh_free_pages, 282 TP_PROTO(struct page *page, unsigned int order), 283 TP_ARGS(page, order)); 284 DECLARE_HOOK(android_vh_set_shmem_page_flag, 285 TP_PROTO(struct page *page), 286 TP_ARGS(page)); 287 DECLARE_HOOK(android_vh_remove_vmalloc_stack, 288 TP_PROTO(struct vm_struct *vm), 289 TP_ARGS(vm)); 290 DECLARE_HOOK(android_vh_alloc_pages_reclaim_bypass, 291 TP_PROTO(gfp_t gfp_mask, int order, int alloc_flags, 292 int migratetype, struct page **page), 293 TP_ARGS(gfp_mask, order, alloc_flags, migratetype, page)); 294 DECLARE_HOOK(android_vh_alloc_pages_failure_bypass, 295 TP_PROTO(gfp_t gfp_mask, int order, int alloc_flags, 296 int migratetype, struct page **page), 297 TP_ARGS(gfp_mask, order, alloc_flags, migratetype, page)); 298 DECLARE_HOOK(android_vh_test_clear_look_around_ref, 299 TP_PROTO(struct page *page), 300 TP_ARGS(page)); 301 DECLARE_HOOK(android_vh_look_around_migrate_page, 302 TP_PROTO(struct page *old_page, struct page *new_page), 303 TP_ARGS(old_page, new_page)); 304 DECLARE_HOOK(android_vh_look_around, 305 TP_PROTO(struct page_vma_mapped_walk *pvmw, struct page *page, 306 struct vm_area_struct *vma, int *referenced), 307 TP_ARGS(pvmw, page, vma, referenced)); 308 /* macro versions of hooks are no longer required */ 309 310 #endif /* _TRACE_HOOK_MM_H */ 311 312 /* This part must be outside protection */ 313 #include <trace/define_trace.h> 314 315 #endif /* PROTECT_TRACE_INCLUDE_PATH */ 316