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>
(cherry picked from commit affce30e154624e0af9c6485586c5c5d27ad7834)
This commit is contained in:
Rui Chen
2024-12-26 21:24:34 +08:00
committed by Todd Kjos
parent 905751c077
commit 74ae8d16a9
6 changed files with 22 additions and 0 deletions
+1
View File
@@ -106,6 +106,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ufs_send_uic_command);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ufs_send_tm_command);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ufs_check_int_errors);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ufs_update_sdev);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_io_statistics);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cgroup_attach);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_iommu_setup_dma_ops);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_iommu_alloc_insert_iova);
+8
View File
@@ -37,6 +37,8 @@
#include <linux/rwsem.h>
#include <linux/uio.h>
#include <linux/atomic.h>
#include <linux/prefetch.h>
#include <trace/hooks/mm.h>
#include "internal.h"
@@ -1036,6 +1038,12 @@ do_holes:
dio_unpin_page(dio, 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;
+3
View File
@@ -12,6 +12,7 @@
#include <linux/backing-dev.h>
#include <linux/uio.h>
#include <linux/task_io_accounting_ops.h>
#include <trace/hooks/mm.h>
#include "trace.h"
#include "../internal.h"
@@ -393,6 +394,8 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter,
goto out;
}
trace_android_vh_io_statistics(inode->i_mapping, pos >> inode->i_blkbits,
nr_pages, !(dio->flags & IOMAP_DIO_WRITE), true);
bio = iomap_dio_alloc_bio(iter, dio, nr_pages, bio_opf);
fscrypt_set_bio_crypt_ctx(bio, inode, pos >> inode->i_blkbits,
GFP_KERNEL);
+4
View File
@@ -35,6 +35,10 @@ DECLARE_HOOK(android_vh_mem_cgroup_alloc,
DECLARE_HOOK(android_vh_mem_cgroup_free,
TP_PROTO(struct mem_cgroup *memcg),
TP_ARGS(memcg));
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));
struct cma;
DECLARE_HOOK(android_vh_cma_alloc_bypass,
+4
View File
@@ -55,6 +55,9 @@
#define CREATE_TRACE_POINTS
#include <trace/events/filemap.h>
#undef CREATE_TRACE_POINTS
#include <trace/hooks/mm.h>
/*
* FIXME: remove all knowledge of the buffer layer from the core VM
*/
@@ -4084,6 +4087,7 @@ retry:
if (unlikely(status < 0))
break;
}
trace_android_vh_io_statistics(mapping, folio->index, 1, false, false);
cond_resched();
if (unlikely(status == 0)) {
+2
View File
@@ -128,6 +128,7 @@
#include <linux/blk-cgroup.h>
#include <linux/fadvise.h>
#include <linux/sched/mm.h>
#include <trace/hooks/mm.h>
#include "internal.h"
@@ -260,6 +261,7 @@ void page_cache_ra_unbounded(struct readahead_control *ractl,
continue;
}
trace_android_vh_io_statistics(mapping, index + i, 1, true, false);
folio = filemap_alloc_folio(gfp_mask,
mapping_min_folio_order(mapping));
if (!folio)