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> Signed-off-by: Richard Chang <richardycc@google.com> (cherry picked from commit a17e132ec4f290621666311e73f43202706d2743)
This commit is contained in:
committed by
Richard Chang
parent
ba005d6032
commit
7df45e50a5
@@ -285,3 +285,6 @@ 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_do_madvise_blk_plug);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_shrink_inactive_list_blk_plug);
|
||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_reclaim_pages_plug);
|
||||
|
||||
@@ -92,6 +92,15 @@ DECLARE_HOOK(android_vh_zap_pte_range_tlb_end,
|
||||
DECLARE_HOOK(android_vh_skip_lru_disable,
|
||||
TP_PROTO(bool *skip),
|
||||
TP_ARGS(skip));
|
||||
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));
|
||||
struct mem_cgroup;
|
||||
DECLARE_HOOK(android_vh_mem_cgroup_alloc,
|
||||
TP_PROTO(struct mem_cgroup *memcg),
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -1328,6 +1329,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);
|
||||
|
||||
@@ -1362,10 +1364,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
|
||||
|
||||
20
mm/vmscan.c
20
mm/vmscan.c
@@ -69,6 +69,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);
|
||||
|
||||
@@ -2215,6 +2218,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)
|
||||
@@ -2248,6 +2253,9 @@ 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(&lruvec->lru_lock);
|
||||
@@ -2261,6 +2269,9 @@ shrink_inactive_list(unsigned long nr_to_scan, struct lruvec *lruvec,
|
||||
__count_vm_events(PGSTEAL_ANON + file, nr_reclaimed);
|
||||
spin_unlock_irq(&lruvec->lru_lock);
|
||||
|
||||
if (do_plug)
|
||||
blk_finish_plug(&plug);
|
||||
|
||||
lru_note_cost(lruvec, file, stat.nr_pageout);
|
||||
mem_cgroup_uncharge_list(&page_list);
|
||||
free_unref_page_list(&page_list);
|
||||
@@ -2418,6 +2429,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;
|
||||
unsigned int noreclaim_flag;
|
||||
struct scan_control sc = {
|
||||
.gfp_mask = GFP_KERNEL,
|
||||
@@ -2429,6 +2442,10 @@ unsigned long reclaim_pages(struct list_head *page_list)
|
||||
|
||||
noreclaim_flag = memalloc_noreclaim_save();
|
||||
|
||||
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) {
|
||||
@@ -2467,6 +2484,9 @@ unsigned long reclaim_pages(struct list_head *page_list)
|
||||
|
||||
memalloc_noreclaim_restore(noreclaim_flag);
|
||||
|
||||
if (do_plug)
|
||||
blk_finish_plug(&plug);
|
||||
|
||||
return nr_reclaimed;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user