LUR: Revert "BACKPORT: mm: multi-gen LRU: optimize multiple memcgs"

The LRU function is not compatible with GKI,
causing GKI to fail to start, so revert.

This reverts commit 1fe9a1daa5a17c0e3cd2580827620d7acf83a3ce.

Change-Id: Ia0615a681415489bad60d6e6929e5e79d888d999
Reviewed-on: https://gerrit.mot.com/2609759
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Xiangpo Zhao <zhaoxp3@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
xiewen3 2023-05-16 22:44:48 +08:00 • committed by Xiaojun Ji
commit c33afa41e2

View file

@ -107,12 +107,6 @@ struct scan_control {
/* One of the zones is ready for compaction */
unsigned int compaction_ready:1;
#ifdef CONFIG_LRU_GEN
/* help kswapd make better choices among multiple memcgs */
unsigned int memcgs_need_aging:1;
unsigned long last_reclaimed;
#endif
/* Allocation order */
s8 order;
@ -4028,19 +4022,6 @@ static void lru_gen_age_node(struct pglist_data *pgdat, struct scan_control *sc)
VM_WARN_ON_ONCE(!current_is_kswapd());
sc->last_reclaimed = sc->nr_reclaimed;
/*
* To reduce the chance of going into the aging path, which can be
* costly, optimistically skip it if the flag below was cleared in the
* eviction path. This improves the overall performance when multiple
* memcgs are available.
*/
if (!sc->memcgs_need_aging) {
sc->memcgs_need_aging = true;
return;
}
set_mm_walk(pgdat);
memcg = mem_cgroup_iter(NULL, NULL, NULL);
@ -4447,8 +4428,7 @@ static int isolate_pages(struct lruvec *lruvec, struct scan_control *sc, int swa
return scanned;
}
static int evict_pages(struct lruvec *lruvec, struct scan_control *sc, int swappiness,
bool *need_swapping)
static int evict_pages(struct lruvec *lruvec, struct scan_control *sc, int swappiness)
{
int type;
int scanned;
@ -4510,9 +4490,6 @@ static int evict_pages(struct lruvec *lruvec, struct scan_control *sc, int swapp
sc->nr_reclaimed += reclaimed;
if (need_swapping && type == LRU_GEN_ANON)
*need_swapping = true;
return scanned;
}
@ -4522,14 +4499,15 @@ static int evict_pages(struct lruvec *lruvec, struct scan_control *sc, int swapp
* reclaim.
*/
static unsigned long get_nr_to_scan(struct lruvec *lruvec, struct scan_control *sc,
bool can_swap, bool *need_aging)
bool can_swap)
{
bool need_aging;
unsigned long nr_to_scan;
DEFINE_MAX_SEQ(lruvec);
DEFINE_MIN_SEQ(lruvec);
*need_aging = should_run_aging(lruvec, max_seq, min_seq, sc, can_swap, &nr_to_scan);
if (!*need_aging)
need_aging = should_run_aging(lruvec, max_seq, min_seq, sc, can_swap, &nr_to_scan);
if (!need_aging)
return nr_to_scan;
/* skip the aging path at the default priority */
@ -4546,67 +4524,10 @@ done:
return min_seq[!can_swap] + MIN_NR_GENS <= max_seq ? nr_to_scan : 0;
}
static bool should_abort_scan(struct lruvec *lruvec, unsigned long seq,
struct scan_control *sc, bool need_swapping)
{
int i;
DEFINE_MAX_SEQ(lruvec);
if (!current_is_kswapd()) {
/* age each memcg at most once to ensure fairness */
if (max_seq - seq > 1)
return true;
/* over-swapping can increase allocation latency */
if (sc->nr_reclaimed >= sc->nr_to_reclaim && need_swapping)
return true;
/* give this thread a chance to exit and free its memory */
if (fatal_signal_pending(current)) {
sc->nr_reclaimed += MIN_LRU_BATCH;
return true;
}
if (!global_reclaim(sc))
return false;
} else if (sc->nr_reclaimed - sc->last_reclaimed < sc->nr_to_reclaim)
return false;
/* keep scanning at low priorities to ensure fairness */
if (sc->priority > DEF_PRIORITY - 2)
return false;
/*
* A minimum amount of work was done under global memory pressure. For
* kswapd, it may be overshooting. For direct reclaim, the allocation
* may succeed if all suitable zones are somewhat safe. In either case,
* it's better to stop now, and restart later if necessary.
*/
for (i = 0; i <= sc->reclaim_idx; i++) {
unsigned long wmark;
struct zone *zone = lruvec_pgdat(lruvec)->node_zones + i;
if (!managed_zone(zone))
continue;
wmark = current_is_kswapd() ? high_wmark_pages(zone) : low_wmark_pages(zone);
if (wmark > zone_page_state(zone, NR_FREE_PAGES))
return false;
}
sc->nr_reclaimed += MIN_LRU_BATCH;
return true;
}
static void lru_gen_shrink_lruvec(struct lruvec *lruvec, struct scan_control *sc)
{
struct blk_plug plug;
bool need_aging = false;
bool need_swapping = false;
unsigned long scanned = 0;
unsigned long reclaimed = sc->nr_reclaimed;
DEFINE_MAX_SEQ(lruvec);
lru_add_drain();
@ -4626,28 +4547,21 @@ static void lru_gen_shrink_lruvec(struct lruvec *lruvec, struct scan_control *sc
else
swappiness = 0;
nr_to_scan = get_nr_to_scan(lruvec, sc, swappiness, &need_aging);
nr_to_scan = get_nr_to_scan(lruvec, sc, swappiness);
if (!nr_to_scan)
goto done;
break;
delta = evict_pages(lruvec, sc, swappiness, &need_swapping);
delta = evict_pages(lruvec, sc, swappiness);
if (!delta)
goto done;
break;
scanned += delta;
if (scanned >= nr_to_scan)
break;
if (should_abort_scan(lruvec, max_seq, sc, need_swapping))
break;
cond_resched();
}
/* see the comment in lru_gen_age_node() */
if (sc->nr_reclaimed - reclaimed >= MIN_LRU_BATCH && !need_aging)
sc->memcgs_need_aging = false;
done:
clear_mm_walk();
blk_finish_plug(&plug);