diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 29fc23229be9..f894e7a8dbe7 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -550,3 +550,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_do_wp_page); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_do_swap_page); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_do_anonymous_page); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_uprobes_replace_page); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_swap_writepage); diff --git a/include/trace/hooks/mm.h b/include/trace/hooks/mm.h index 874b88291647..592e04d7fbf0 100644 --- a/include/trace/hooks/mm.h +++ b/include/trace/hooks/mm.h @@ -513,6 +513,9 @@ DECLARE_HOOK(android_vh_uprobes_replace_page, DECLARE_HOOK(android_vh_shmem_swapin_folio, TP_PROTO(struct folio *folio), TP_ARGS(folio)); +DECLARE_HOOK(android_vh_swap_writepage, + TP_PROTO(unsigned long *sis_flags, struct page *page), + TP_ARGS(sis_flags, page)); #endif /* _TRACE_HOOK_MM_H */ /* This part must be outside protection */ diff --git a/mm/page_io.c b/mm/page_io.c index 3880256fb1fd..fce30cc03123 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -27,6 +27,9 @@ #include #include "swap.h" +#undef CREATE_TRACE_POINTS +#include + static void __end_swap_bio_write(struct bio *bio) { struct folio *folio = bio_first_folio_all(bio); @@ -452,6 +455,7 @@ static void swap_writepage_bdev_async(struct folio *folio, void __swap_writepage(struct folio *folio, struct writeback_control *wbc) { struct swap_info_struct *sis = swp_swap_info(folio->swap); + unsigned long sis_flags = 0; VM_BUG_ON_FOLIO(!folio_test_swapcache(folio), folio); /* @@ -459,14 +463,16 @@ void __swap_writepage(struct folio *folio, struct writeback_control *wbc) * but that will never affect SWP_FS_OPS, so the data_race * is safe. */ - if (data_race(sis->flags & SWP_FS_OPS)) + sis_flags = data_race(sis->flags); + trace_android_vh_swap_writepage(&sis_flags, &folio->page); + if (sis_flags & SWP_FS_OPS) swap_writepage_fs(folio, wbc); /* * ->flags can be updated non-atomicially (scan_swap_map_slots), * but that will never affect __SWP_WRITE_SYNCHRONOUS_IO, so the data_race * is safe. */ - else if (data_race(sis->flags & __SWP_WRITE_SYNCHRONOUS_IO)) + else if (sis_flags & __SWP_WRITE_SYNCHRONOUS_IO) swap_writepage_bdev_sync(folio, wbc, sis); else swap_writepage_bdev_async(folio, wbc, sis);