diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 2d7bed528a89..b013d648356b 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -412,6 +412,9 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cow_user_page); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_swapin_add_anon_rmap); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_waiting_for_page_migration); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_migrate_page_states); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_count_pswpin); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_count_pswpout); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_count_swpout_vm_event); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_page_isolated_for_reclaim); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_inactive_is_low); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_snapshot_refaults); diff --git a/include/trace/hooks/mm.h b/include/trace/hooks/mm.h index 8e65846d821a..2b75c4e46f6a 100644 --- a/include/trace/hooks/mm.h +++ b/include/trace/hooks/mm.h @@ -164,6 +164,15 @@ DECLARE_HOOK(android_vh_waiting_for_page_migration, DECLARE_HOOK(android_vh_migrate_page_states, TP_PROTO(struct page *page, struct page *newpage), TP_ARGS(page, newpage)); +DECLARE_HOOK(android_vh_count_pswpin, + TP_PROTO(struct swap_info_struct *sis), + TP_ARGS(sis)); +DECLARE_HOOK(android_vh_count_pswpout, + TP_PROTO(struct swap_info_struct *sis), + TP_ARGS(sis)); +DECLARE_HOOK(android_vh_count_swpout_vm_event, + TP_PROTO(struct swap_info_struct *sis, struct page *page, bool *skip), + TP_ARGS(sis, page, skip)); DECLARE_HOOK(android_vh_page_isolated_for_reclaim, TP_PROTO(struct mm_struct *mm, struct page *page), TP_ARGS(mm, page)); diff --git a/mm/page_io.c b/mm/page_io.c index d5efe9558b8a..04b3a7ebfe9e 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -25,6 +25,7 @@ #include #include #include +#include static struct bio *get_swap_bio(gfp_t gfp_flags, struct page *page, bio_end_io_t end_io) @@ -256,6 +257,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc, struct bio *bio; int ret; struct swap_info_struct *sis = page_swap_info(page); + bool skip = false; VM_BUG_ON_PAGE(!PageSwapCache(page), page); if (data_race(sis->flags & SWP_FS_OPS)) { @@ -277,6 +279,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc, unlock_page(page); ret = mapping->a_ops->direct_IO(&kiocb, &from); if (ret == PAGE_SIZE) { + trace_android_vh_count_pswpout(sis); count_vm_event(PSWPOUT); ret = 0; } else { @@ -301,7 +304,9 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc, ret = bdev_write_page(sis->bdev, swap_page_sector(page), page, wbc); if (!ret) { - count_swpout_vm_event(page); + trace_android_vh_count_swpout_vm_event(sis, page, &skip); + if (!skip) + count_swpout_vm_event(page); return 0; } @@ -313,7 +318,9 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc, } bio->bi_opf = REQ_OP_WRITE | REQ_SWAP | wbc_to_write_flags(wbc); bio_associate_blkg_from_page(bio, page); - count_swpout_vm_event(page); + trace_android_vh_count_swpout_vm_event(sis, page, &skip); + if (!skip) + count_swpout_vm_event(page); set_page_writeback(page); unlock_page(page); submit_bio(bio); @@ -352,14 +359,17 @@ int swap_readpage(struct page *page, bool synchronous) struct address_space *mapping = swap_file->f_mapping; ret = mapping->a_ops->readpage(swap_file, page); - if (!ret) + if (!ret) { + trace_android_vh_count_pswpin(sis); count_vm_event(PSWPIN); + } goto out; } if (sis->flags & SWP_SYNCHRONOUS_IO) { ret = bdev_read_page(sis->bdev, swap_page_sector(page), page); if (!ret) { + trace_android_vh_count_pswpin(sis); count_vm_event(PSWPIN); goto out; } @@ -383,6 +393,7 @@ int swap_readpage(struct page *page, bool synchronous) get_task_struct(current); bio->bi_private = current; } + trace_android_vh_count_pswpin(sis); count_vm_event(PSWPIN); bio_get(bio); qc = submit_bio(bio);