ANDROID: vendor hook to control bh_lru and lru_cache_disable

Add vendor hook for bh_lru and lru_cache_disable

Bug: 238728493
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: I81bfad317cf6e8633186ebb3238644306d7a102d
This commit is contained in:
Minchan Kim
2022-10-20 16:03:35 -07:00
parent f45d10e83b
commit 74e2ea264c
5 changed files with 42 additions and 2 deletions

View File

@@ -61,6 +61,7 @@
#include <trace/hooks/iommu.h>
#include <trace/hooks/thermal.h>
#include <trace/hooks/ufshcd.h>
#include <trace/hooks/buffer.h>
#ifdef __GENKSYMS__
#include <trace/hooks/cgroup.h>
#endif
@@ -285,6 +286,8 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alloc_pages_slowpath);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_zap_pte_range_tlb_start);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_zap_pte_range_tlb_force_flush);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_zap_pte_range_tlb_end);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_bh_lru_install);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_skip_lru_disable);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cma_alloc_adjust);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_show_mem);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_print_slabinfo_header);

View File

@@ -51,6 +51,8 @@
#include "internal.h"
#include <trace/hooks/buffer.h>
static int fsync_buffers_list(spinlock_t *lock, struct list_head *list);
static int submit_bh_wbc(int op, int op_flags, struct buffer_head *bh,
enum rw_hint hint, struct writeback_control *wbc);
@@ -1262,6 +1264,7 @@ static void bh_lru_install(struct buffer_head *bh)
struct buffer_head *evictee = bh;
struct bh_lru *b;
int i;
bool skip = false;
check_irqs_on();
/*
@@ -1273,6 +1276,10 @@ static void bh_lru_install(struct buffer_head *bh)
if (lru_cache_disabled())
return;
trace_android_vh_bh_lru_install(bh->b_page, &skip);
if (skip)
return;
bh_lru_lock();
b = this_cpu_ptr(&bh_lrus);

View File

@@ -0,0 +1,22 @@
/* SPDX-License-Identifier: GPL-2.0 */
#undef TRACE_SYSTEM
#define TRACE_SYSTEM buffer
#define TRACE_INCLUDE_PATH trace/hooks
#if !defined(_TRACE_HOOK_BUFFER_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_HOOK_BUFFER_H
#include <linux/types.h>
#include <trace/hooks/vendor_hooks.h>
DECLARE_HOOK(android_vh_bh_lru_install,
TP_PROTO(struct page *page, bool *flush),
TP_ARGS(page, flush));
/* macro versions of hooks are no longer required */
#endif /* _TRACE_HOOK_BUFFER_H */
/* This part must be outside protection */
#include <trace/define_trace.h>

View File

@@ -109,6 +109,9 @@ DECLARE_HOOK(android_vh_zap_pte_range_tlb_force_flush,
DECLARE_HOOK(android_vh_zap_pte_range_tlb_end,
TP_PROTO(void *unused),
TP_ARGS(unused));
DECLARE_HOOK(android_vh_skip_lru_disable,
TP_PROTO(bool *skip),
TP_ARGS(skip));
DECLARE_HOOK(android_vh_print_slabinfo_header,
TP_PROTO(struct seq_file *m),
TP_ARGS(m));

View File

@@ -8826,6 +8826,8 @@ static int __alloc_contig_migrate_range(struct compact_control *cc,
unsigned int tries = 0;
unsigned int max_tries = 5;
int ret = 0;
bool skip = false;
struct page *page;
struct migration_target_control mtc = {
.nid = zone_to_nid(cc->zone),
@@ -8835,7 +8837,9 @@ static int __alloc_contig_migrate_range(struct compact_control *cc,
if (cc->alloc_contig && cc->mode == MIGRATE_ASYNC)
max_tries = 1;
lru_cache_disable();
trace_android_vh_skip_lru_disable(&skip);
if (!skip)
lru_cache_disable();
while (pfn < end || !list_empty(&cc->migratepages)) {
if (fatal_signal_pending(current)) {
@@ -8870,7 +8874,8 @@ static int __alloc_contig_migrate_range(struct compact_control *cc,
info->nr_migrated += cc->nr_migratepages;
}
lru_cache_enable();
if (!skip)
lru_cache_enable();
if (ret < 0) {
if (ret == -EBUSY) {
alloc_contig_dump_pages(&cc->migratepages);