ANDROID: fs: add vendor hook to collect IO statistics

Add vendor hook to get metainfo of direct/buffered read and write.
Determine hot files in each performance-sensitive user scenario.

Bug: 380502059
Change-Id: Ie7604852df637d6664afd72e87bd6d4b14bbc2a2
Signed-off-by: Rui Chen <chenrui9@honor.com>
This commit is contained in:
Rui Chen 2024-11-30 17:17:10 +08:00 committed by Sandeep Dhavale
parent 35fae48401
commit 5f45a7ef79
6 changed files with 20 additions and 1 deletions

View File

@ -566,3 +566,4 @@ EXPORT_SYMBOL_GPL(GKI_struct_gic_chip_data);
#include <linux/swap_slots.h>
const struct swap_slots_cache *GKI_struct_swap_slots_cache;
EXPORT_SYMBOL_GPL(GKI_struct_swap_slots_cache);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_io_statistics);

View File

@ -39,6 +39,9 @@
#include <linux/uio.h>
#include <linux/atomic.h>
#include <linux/prefetch.h>
#ifndef __GENKSYMS__
#include <trace/hooks/mm.h>
#endif
#include "internal.h"
@ -1070,6 +1073,11 @@ static int do_direct_IO(struct dio *dio, struct dio_submit *sdio,
put_page(page);
goto out;
}
trace_android_vh_io_statistics(dio->inode->i_mapping,
sdio->block_in_file >> sdio->blkfactor,
this_chunk_blocks >> sdio->blkfactor,
iov_iter_rw(sdio->iter) == READ, true);
sdio->next_block_for_io += this_chunk_blocks;
sdio->block_in_file += this_chunk_blocks;

View File

@ -11,6 +11,9 @@
#include <linux/backing-dev.h>
#include <linux/uio.h>
#include <linux/task_io_accounting_ops.h>
#ifndef __GENKSYMS__
#include <trace/hooks/mm.h>
#endif
#include "trace.h"
#include "../internal.h"
@ -277,6 +280,8 @@ iomap_dio_bio_actor(struct inode *inode, loff_t pos, loff_t length,
goto out;
}
trace_android_vh_io_statistics(inode->i_mapping, pos >> inode->i_blkbits,
nr_pages, !(dio->flags & IOMAP_DIO_WRITE), true);
bio = bio_alloc(GFP_KERNEL, nr_pages);
fscrypt_set_bio_crypt_ctx(bio, inode, pos >> inode->i_blkbits,
GFP_KERNEL);

View File

@ -370,6 +370,10 @@ DECLARE_HOOK(android_vh_do_swap_page_spf,
DECLARE_HOOK(android_vh_tune_fault_around_bytes,
TP_PROTO(unsigned long *fault_around_bytes),
TP_ARGS(fault_around_bytes));
DECLARE_HOOK(android_vh_io_statistics,
TP_PROTO(struct address_space *mapping, unsigned int index,
unsigned int nr_page, bool read, bool direct),
TP_ARGS(mapping, index, nr_page, read, direct));
DECLARE_HOOK(android_vh_do_anonymous_page,
TP_PROTO(struct vm_area_struct *vma, struct page *page),
TP_ARGS(vma, page));

View File

@ -3525,6 +3525,7 @@ ssize_t generic_perform_write(struct file *file,
break;
copied = status;
trace_android_vh_io_statistics(mapping, page->index, 1, false, false);
cond_resched();
iov_iter_advance(i, copied);

View File

@ -222,7 +222,7 @@ void page_cache_ra_unbounded(struct readahead_control *ractl,
read_pages(ractl, &page_pool, true);
continue;
}
trace_android_vh_io_statistics(mapping, index + i, 1, true, false);
page = __page_cache_alloc(gfp_mask);
if (!page)
break;