diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 946590742647..f80f2486ed75 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -286,6 +286,8 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_tune_swappiness); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_logbuf_pr_cont); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_calc_alloc_flags); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_regmap_update); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_shmem_suitable_orders); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_shmem_allowable_huge_orders); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_shmem_get_folio); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_slab_folio_alloced); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_kmalloc_large_alloced); diff --git a/include/trace/hooks/mm.h b/include/trace/hooks/mm.h index 3f882265c50f..89f0843a5fcd 100644 --- a/include/trace/hooks/mm.h +++ b/include/trace/hooks/mm.h @@ -20,7 +20,14 @@ DECLARE_RESTRICTED_HOOK(android_rvh_try_alloc_pages_gfp, TP_PROTO(struct page **page, unsigned int order, gfp_t gfp, enum zone_type highest_zoneidx), TP_ARGS(page, order, gfp, highest_zoneidx), 1); - +DECLARE_RESTRICTED_HOOK(android_rvh_shmem_suitable_orders, + TP_PROTO(struct inode *inode, pgoff_t index, + unsigned long orders, unsigned long *suitable_orders), + TP_ARGS(inode, index, orders, suitable_orders), 4); +DECLARE_RESTRICTED_HOOK(android_rvh_shmem_allowable_huge_orders, + TP_PROTO(struct inode *inode, pgoff_t index, + struct vm_area_struct *vma, unsigned long *orders), + TP_ARGS(inode, index, vma, orders), 4); /* DECLARE_RESTRICTED_HOOK(android_rvh_set_skip_swapcache_flags, diff --git a/mm/shmem.c b/mm/shmem.c index 375f4d89d836..be8dd416ce44 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1804,6 +1804,8 @@ static struct folio *shmem_alloc_and_add_folio(struct vm_fault *vmf, suitable_orders = shmem_suitable_orders(inode, vmf, mapping, index, orders); + trace_android_rvh_shmem_suitable_orders(inode, index, + orders, &suitable_orders); order = highest_order(suitable_orders); while (suitable_orders) { pages = 1UL << order; @@ -2322,6 +2324,13 @@ repeat: /* Find hugepage orders that are allowed for anonymous shmem and tmpfs. */ orders = shmem_allowable_huge_orders(inode, vma, index, write_end, false); + trace_android_rvh_shmem_allowable_huge_orders(inode, index, vma, &orders); + /* + * With the above hook `order` is not always 0 anymore and the following + * if block does not get compiled out. With CONFIG_TRANSPARENT_HUGEPAGE=n + * vma_thp_gfp_mask() becomes undefined and linker fails. + */ +#ifdef CONFIG_TRANSPARENT_HUGEPAGE if (orders > 0) { gfp_t huge_gfp; @@ -2338,6 +2347,7 @@ repeat: if (PTR_ERR(folio) == -EEXIST) goto repeat; } +#endif folio = shmem_alloc_and_add_folio(vmf, gfp, inode, index, fault_mm, 0); if (IS_ERR(folio)) {