ANDROID: vendor_hooks: add hook for shmem memory stat
Add some vendor hooks for shmem memory stats. This help us track the number of shmem pages which are belong to the mapping we're interested in. If shmem pages are swapped out, we can track that number, too. Bug: 372282099 Change-Id: I0a18a690f37719400faa4a01b1d5d09e979f09c7 Signed-off-by: Jaewon Kim <jaewon31.kim@samsung.com>
This commit is contained in:
committed by
Treehugger Robot
parent
b5fd1cdaf6
commit
b235667f92
@@ -289,6 +289,8 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_regmap_update);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_shmem_suitable_orders);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_shmem_allowable_huge_orders);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_shmem_get_folio);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_shmem_mod_shmem);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_shmem_mod_swapped);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_slab_folio_alloced);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_kmalloc_large_alloced);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_ctl_dirty_rate);
|
||||
|
||||
@@ -16,6 +16,12 @@ struct folio_batch;
|
||||
DECLARE_RESTRICTED_HOOK(android_rvh_shmem_get_folio,
|
||||
TP_PROTO(struct shmem_inode_info *info, struct folio **folio, int order),
|
||||
TP_ARGS(info, folio, order), 3);
|
||||
DECLARE_HOOK(android_vh_shmem_mod_shmem,
|
||||
TP_PROTO(struct address_space *mapping, long nr_pages),
|
||||
TP_ARGS(mapping, nr_pages));
|
||||
DECLARE_HOOK(android_vh_shmem_mod_swapped,
|
||||
TP_PROTO(struct address_space *mapping, long nr_pages),
|
||||
TP_ARGS(mapping, nr_pages));
|
||||
DECLARE_RESTRICTED_HOOK(android_rvh_try_alloc_pages_gfp,
|
||||
TP_PROTO(struct page **page, unsigned int order,
|
||||
gfp_t gfp, enum zone_type highest_zoneidx),
|
||||
|
||||
@@ -211,6 +211,7 @@ static void filemap_unaccount_folio(struct address_space *mapping,
|
||||
__lruvec_stat_mod_folio(folio, NR_FILE_PAGES, -nr);
|
||||
if (folio_test_swapbacked(folio)) {
|
||||
__lruvec_stat_mod_folio(folio, NR_SHMEM, -nr);
|
||||
trace_android_vh_shmem_mod_shmem(folio->mapping, -nr);
|
||||
if (folio_test_pmd_mappable(folio))
|
||||
__lruvec_stat_mod_folio(folio, NR_SHMEM_THPS, -nr);
|
||||
} else if (folio_test_pmd_mappable(folio)) {
|
||||
|
||||
@@ -828,6 +828,7 @@ static int shmem_add_to_page_cache(struct folio *folio,
|
||||
goto unlock;
|
||||
shmem_update_stats(folio, nr);
|
||||
mapping->nrpages += nr;
|
||||
trace_android_vh_shmem_mod_shmem(folio->mapping, nr);
|
||||
unlock:
|
||||
xas_unlock_irq(&xas);
|
||||
} while (xas_nomem(&xas, gfp));
|
||||
@@ -852,6 +853,7 @@ static void shmem_delete_from_page_cache(struct folio *folio, void *radswap)
|
||||
|
||||
xa_lock_irq(&mapping->i_pages);
|
||||
error = shmem_replace_entry(mapping, folio->index, folio, radswap);
|
||||
trace_android_vh_shmem_mod_shmem(folio->mapping, -nr);
|
||||
folio->mapping = NULL;
|
||||
mapping->nrpages -= nr;
|
||||
shmem_update_stats(folio, -nr);
|
||||
@@ -1146,6 +1148,7 @@ whole_folios:
|
||||
}
|
||||
|
||||
shmem_recalc_inode(inode, 0, -nr_swaps_freed);
|
||||
trace_android_vh_shmem_mod_swapped(mapping, -nr_swaps_freed);
|
||||
}
|
||||
|
||||
void shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend)
|
||||
@@ -1568,6 +1571,7 @@ try_split:
|
||||
__GFP_HIGH | __GFP_NOMEMALLOC | __GFP_NOWARN,
|
||||
NULL) == 0) {
|
||||
shmem_recalc_inode(inode, 0, nr_pages);
|
||||
trace_android_vh_shmem_mod_swapped(folio->mapping, nr_pages);
|
||||
swap_shmem_alloc(swap, nr_pages);
|
||||
shmem_delete_from_page_cache(folio, swp_to_radix_entry(swap));
|
||||
|
||||
@@ -2206,6 +2210,7 @@ static int shmem_swapin_folio(struct inode *inode, pgoff_t index,
|
||||
goto failed;
|
||||
|
||||
shmem_recalc_inode(inode, 0, -nr_pages);
|
||||
trace_android_vh_shmem_mod_swapped(folio->mapping, -nr_pages);
|
||||
|
||||
if (sgp == SGP_WRITE)
|
||||
folio_mark_accessed(folio);
|
||||
|
||||
Reference in New Issue
Block a user