mm.h 10 KB

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