ANDROID: vendor_hook: add hooks in dm_bufio.c

1. android_vh_dm_bufio_shrink_scan_bypass
To adjust dm_bufio-buffer shrinker's policy in some cases.
2. cleanup_old_buffers_bypass
To adjust the policy of dm_bufio-buffer periodic eviction
in some cases.

Bug: 281467813

Signed-off-by: Peifeng Li <lipeifeng@oppo.com>
Change-Id: I29a9d91d18d2e279170533db83b59cfc3b17ebe2
This commit is contained in:
Peifeng Li
2023-05-08 14:52:00 +08:00
committed by Todd Kjos
parent ddfd56a6ad
commit b5d2e9c99d
3 changed files with 27 additions and 0 deletions

View File

@@ -250,6 +250,8 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_page_trylock_set);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_page_trylock_clear);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_page_trylock_get_result);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_do_page_trylock);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_dm_bufio_shrink_scan_bypass);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cleanup_old_buffers_bypass);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_page_referenced_check_bypass);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_drain_all_pages_bypass);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cma_drain_all_pages_bypass);

View File

@@ -19,6 +19,8 @@
#include <linux/rbtree.h>
#include <linux/stacktrace.h>
#include <trace/hooks/mm.h>
#define DM_MSG_PREFIX "bufio"
/*
@@ -1683,6 +1685,13 @@ static void shrink_work(struct work_struct *w)
static unsigned long dm_bufio_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
{
struct dm_bufio_client *c;
bool bypass = false;
trace_android_vh_dm_bufio_shrink_scan_bypass(
dm_bufio_current_allocated,
&bypass);
if (bypass)
return 0;
c = container_of(shrink, struct dm_bufio_client, shrinker);
atomic_long_add(sc->nr_to_scan, &c->need_shrink);
@@ -2009,6 +2018,14 @@ static void cleanup_old_buffers(void)
{
unsigned long max_age_hz = get_max_age_hz();
struct dm_bufio_client *c;
bool bypass = false;
trace_android_vh_cleanup_old_buffers_bypass(
dm_bufio_current_allocated,
&max_age_hz,
&bypass);
if (bypass)
return;
mutex_lock(&dm_bufio_clients_lock);

View File

@@ -72,6 +72,14 @@ DECLARE_HOOK(android_vh_drain_all_pages_bypass,
int migratetype, unsigned long did_some_progress,
bool *bypass),
TP_ARGS(gfp_mask, order, alloc_flags, migratetype, did_some_progress, bypass));
DECLARE_HOOK(android_vh_dm_bufio_shrink_scan_bypass,
TP_PROTO(unsigned long dm_bufio_current_allocated, bool *bypass),
TP_ARGS(dm_bufio_current_allocated, bypass));
DECLARE_HOOK(android_vh_cleanup_old_buffers_bypass,
TP_PROTO(unsigned long dm_bufio_current_allocated,
unsigned long *max_age_hz,
bool *bypass),
TP_ARGS(dm_bufio_current_allocated, max_age_hz, bypass));
DECLARE_HOOK(android_vh_cma_drain_all_pages_bypass,
TP_PROTO(unsigned int migratetype, bool *bypass),
TP_ARGS(migratetype, bypass));