mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 20:07:46 +09:00
ANDROID: vendor hook to control blk_plug for memory reclaim
Add vendor hook to contorl blk plugging. Bug: 255471591 Bug: 238728493 Change-Id: I96b73cec14f0d2fea46a4828526e6ae5aa5c71b7 Signed-off-by: Minchan Kim <minchan@google.com>
This commit is contained in:
@@ -283,6 +283,9 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_get_from_fragment_pool);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_exclude_reserved_zone);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_include_reserved_zone);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alloc_pages_slowpath);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_do_madvise_blk_plug);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_shrink_inactive_list_blk_plug);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_reclaim_pages_plug);
|
||||
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);
|
||||
|
||||
@@ -100,6 +100,15 @@ DECLARE_HOOK(android_vh_alloc_pages_slowpath,
|
||||
DECLARE_HOOK(android_vh_cma_alloc_adjust,
|
||||
TP_PROTO(struct zone *zone, bool *is_cma_alloc),
|
||||
TP_ARGS(zone, is_cma_alloc));
|
||||
DECLARE_HOOK(android_vh_do_madvise_blk_plug,
|
||||
TP_PROTO(int behavior, bool *do_plug),
|
||||
TP_ARGS(behavior, do_plug));
|
||||
DECLARE_HOOK(android_vh_shrink_inactive_list_blk_plug,
|
||||
TP_PROTO(bool *do_plug),
|
||||
TP_ARGS(do_plug));
|
||||
DECLARE_HOOK(android_vh_reclaim_pages_plug,
|
||||
TP_PROTO(bool *do_plug),
|
||||
TP_ARGS(do_plug));
|
||||
DECLARE_HOOK(android_vh_zap_pte_range_tlb_start,
|
||||
TP_PROTO(void *unused),
|
||||
TP_ARGS(unused));
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <linux/swapops.h>
|
||||
#include <linux/shmem_fs.h>
|
||||
#include <linux/mmu_notifier.h>
|
||||
#include <trace/hooks/mm.h>
|
||||
|
||||
#include <asm/tlb.h>
|
||||
|
||||
@@ -1266,6 +1267,7 @@ int do_madvise(struct mm_struct *mm, unsigned long start, size_t len_in, int beh
|
||||
int write;
|
||||
size_t len;
|
||||
struct blk_plug plug;
|
||||
bool do_plug = true;
|
||||
|
||||
start = untagged_addr(start);
|
||||
|
||||
@@ -1300,10 +1302,13 @@ int do_madvise(struct mm_struct *mm, unsigned long start, size_t len_in, int beh
|
||||
mmap_read_lock(mm);
|
||||
}
|
||||
|
||||
blk_start_plug(&plug);
|
||||
trace_android_vh_do_madvise_blk_plug(behavior, &do_plug);
|
||||
if (do_plug)
|
||||
blk_start_plug(&plug);
|
||||
error = madvise_walk_vmas(mm, start, end, behavior,
|
||||
madvise_vma_behavior);
|
||||
blk_finish_plug(&plug);
|
||||
if (do_plug)
|
||||
blk_finish_plug(&plug);
|
||||
if (write)
|
||||
mmap_write_unlock(mm);
|
||||
else
|
||||
|
||||
18
mm/vmscan.c
18
mm/vmscan.c
@@ -70,6 +70,9 @@
|
||||
#undef CREATE_TRACE_POINTS
|
||||
#include <trace/hooks/vmscan.h>
|
||||
|
||||
#undef CREATE_TRACE_POINTS
|
||||
#include <trace/hooks/mm.h>
|
||||
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(mm_vmscan_direct_reclaim_begin);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(mm_vmscan_direct_reclaim_end);
|
||||
|
||||
@@ -2005,6 +2008,8 @@ shrink_inactive_list(unsigned long nr_to_scan, struct lruvec *lruvec,
|
||||
enum vm_event_item item;
|
||||
struct pglist_data *pgdat = lruvec_pgdat(lruvec);
|
||||
bool stalled = false;
|
||||
struct blk_plug plug;
|
||||
bool do_plug = false;
|
||||
|
||||
while (unlikely(too_many_isolated(pgdat, file, sc))) {
|
||||
if (stalled)
|
||||
@@ -2038,11 +2043,16 @@ shrink_inactive_list(unsigned long nr_to_scan, struct lruvec *lruvec,
|
||||
if (nr_taken == 0)
|
||||
return 0;
|
||||
|
||||
trace_android_vh_shrink_inactive_list_blk_plug(&do_plug);
|
||||
if (do_plug)
|
||||
blk_start_plug(&plug);
|
||||
nr_reclaimed = shrink_page_list(&page_list, pgdat, sc, &stat, false);
|
||||
|
||||
spin_lock_irq(&pgdat->lru_lock);
|
||||
|
||||
move_pages_to_lru(lruvec, &page_list);
|
||||
if (do_plug)
|
||||
blk_finish_plug(&plug);
|
||||
|
||||
__mod_node_page_state(pgdat, NR_ISOLATED_ANON + file, -nr_taken);
|
||||
lru_note_cost(lruvec, file, stat.nr_pageout);
|
||||
@@ -2188,6 +2198,8 @@ unsigned long reclaim_pages(struct list_head *page_list)
|
||||
LIST_HEAD(node_page_list);
|
||||
struct reclaim_stat dummy_stat;
|
||||
struct page *page;
|
||||
struct blk_plug plug;
|
||||
bool do_plug = false;
|
||||
struct scan_control sc = {
|
||||
.gfp_mask = GFP_KERNEL,
|
||||
.priority = DEF_PRIORITY,
|
||||
@@ -2196,6 +2208,10 @@ unsigned long reclaim_pages(struct list_head *page_list)
|
||||
.may_swap = 1,
|
||||
};
|
||||
|
||||
trace_android_vh_reclaim_pages_plug(&do_plug);
|
||||
if (do_plug)
|
||||
blk_start_plug(&plug);
|
||||
|
||||
while (!list_empty(page_list)) {
|
||||
page = lru_to_page(page_list);
|
||||
if (nid == NUMA_NO_NODE) {
|
||||
@@ -2231,6 +2247,8 @@ unsigned long reclaim_pages(struct list_head *page_list)
|
||||
putback_lru_page(page);
|
||||
}
|
||||
}
|
||||
if (do_plug)
|
||||
blk_finish_plug(&plug);
|
||||
|
||||
return nr_reclaimed;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user