mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
ANDROID: mm: add vendor hook in fault and read file
Add a vendor hook to notify vendor module fault and read events. Bug: 362665923 Bug: 351175506 Change-Id: I4c46e9e00aa5f5555fd42a6b0815563497658b34 Signed-off-by: Sooyong Suk <s.suk@samsung.corp-partner.google.com> (cherry picked from commit a9867d872e24fbe658e05f32b770e4b36c6e3773)
This commit is contained in:
@@ -447,3 +447,6 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_swapmem_gather_add_bypass);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_swapmem_gather_finish);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_oom_swapmem_gather_init);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_oom_swapmem_gather_finish);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_do_read_fault);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_filemap_read);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_filemap_map_pages);
|
||||
|
||||
@@ -261,6 +261,16 @@ DECLARE_HOOK(android_vh_oom_swapmem_gather_init,
|
||||
DECLARE_HOOK(android_vh_oom_swapmem_gather_finish,
|
||||
TP_PROTO(struct mm_struct *mm),
|
||||
TP_ARGS(mm));
|
||||
DECLARE_HOOK(android_vh_do_read_fault,
|
||||
TP_PROTO(struct vm_fault *vmf, unsigned long fault_around_bytes),
|
||||
TP_ARGS(vmf, fault_around_bytes));
|
||||
DECLARE_HOOK(android_vh_filemap_read,
|
||||
TP_PROTO(struct file *file, loff_t pos, size_t size),
|
||||
TP_ARGS(file, pos, size));
|
||||
DECLARE_HOOK(android_vh_filemap_map_pages,
|
||||
TP_PROTO(struct file *file, pgoff_t first_pgoff,
|
||||
pgoff_t last_pgoff, vm_fault_t ret),
|
||||
TP_ARGS(file, first_pgoff, last_pgoff, ret));
|
||||
#endif /* _TRACE_HOOK_MM_H */
|
||||
|
||||
/* This part must be outside protection */
|
||||
|
||||
@@ -2736,6 +2736,7 @@ ssize_t filemap_read(struct kiocb *iocb, struct iov_iter *iter,
|
||||
|
||||
iov_iter_truncate(iter, inode->i_sb->s_maxbytes);
|
||||
folio_batch_init(&fbatch);
|
||||
trace_android_vh_filemap_read(filp, iocb->ki_pos, iov_iter_count(iter));
|
||||
|
||||
do {
|
||||
cond_resched();
|
||||
@@ -3438,11 +3439,13 @@ vm_fault_t filemap_map_pages(struct vm_fault *vmf,
|
||||
struct page *page;
|
||||
unsigned int mmap_miss = READ_ONCE(file->f_ra.mmap_miss);
|
||||
vm_fault_t ret = 0;
|
||||
pgoff_t first_pgoff = 0;
|
||||
|
||||
rcu_read_lock();
|
||||
folio = first_map_page(mapping, &xas, end_pgoff);
|
||||
if (!folio)
|
||||
goto out;
|
||||
first_pgoff = xas.xa_index;
|
||||
|
||||
if (filemap_map_pmd(vmf, &folio->page)) {
|
||||
ret = VM_FAULT_NOPAGE;
|
||||
@@ -3498,6 +3501,8 @@ unlock:
|
||||
out:
|
||||
rcu_read_unlock();
|
||||
WRITE_ONCE(file->f_ra.mmap_miss, mmap_miss);
|
||||
trace_android_vh_filemap_map_pages(file, first_pgoff, last_pgoff, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(filemap_map_pages);
|
||||
|
||||
@@ -4690,6 +4690,8 @@ static vm_fault_t do_read_fault(struct vm_fault *vmf)
|
||||
ret = do_fault_around(vmf);
|
||||
if (ret)
|
||||
return ret;
|
||||
} else {
|
||||
trace_android_vh_do_read_fault(vmf, fault_around_bytes);
|
||||
}
|
||||
|
||||
ret = vmf_can_call_fault(vmf);
|
||||
|
||||
Reference in New Issue
Block a user