Skip to content

Commit

Permalink
mm/vmscan: vm.workingset_protection: Update to linux6.6-le9uo-1.6
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandre Frade <kernel@xanmod.org>
  • Loading branch information
xanmod committed Apr 13, 2024
1 parent ef286ab commit b922073
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 23 deletions.
2 changes: 1 addition & 1 deletion mm/mm_init.c
Expand Up @@ -2760,7 +2760,7 @@ static void __init mem_init_print_info(void)
, K(totalhigh_pages())
#endif
);
printk(KERN_INFO "le9 Unofficial (le9uo) working set protection 1.5 by Masahito Suzuki (forked from hakavlad's original le9 patch)");
printk(KERN_INFO "le9 Unofficial (le9uo) working set protection 1.6 by Masahito Suzuki (forked from hakavlad's original le9 patch)");
}

/*
Expand Down
33 changes: 11 additions & 22 deletions mm/vmscan.c
Expand Up @@ -4635,23 +4635,6 @@ static bool lruvec_is_reclaimable(struct lruvec *lruvec, struct scan_control *sc
/* to protect the working set of the last N jiffies */
static unsigned long lru_gen_min_ttl __read_mostly;

static void do_invoke_oom(struct scan_control *sc, bool try_memcg) {
struct oom_control oc = {
.gfp_mask = sc->gfp_mask,
.order = sc->order,
};

if (try_memcg && mem_cgroup_oom_synchronize(true))
return;

if (!mutex_trylock(&oom_lock))
return;
out_of_memory(&oc);
mutex_unlock(&oom_lock);
}
#define invoke_oom(sc) do_invoke_oom(sc, true)
#define invoke_oom_nomemcg(sc) do_invoke_oom(sc, false)

static void lru_gen_age_node(struct pglist_data *pgdat, struct scan_control *sc)
{
struct mem_cgroup *memcg;
Expand Down Expand Up @@ -4680,7 +4663,15 @@ static void lru_gen_age_node(struct pglist_data *pgdat, struct scan_control *sc)
* younger than min_ttl. However, another possibility is all memcgs are
* either too small or below min.
*/
invoke_oom_nomemcg(sc);
if (mutex_trylock(&oom_lock)) {
struct oom_control oc = {
.gfp_mask = sc->gfp_mask,
};

out_of_memory(&oc);

mutex_unlock(&oom_lock);
}
}

int vm_workingset_protection_update_handler(struct ctl_table *table, int write,
Expand Down Expand Up @@ -5278,7 +5269,7 @@ static int isolate_folios(struct lruvec *lruvec, struct scan_control *sc, int sw
*/
if (!swappiness)
type = LRU_GEN_FILE;
else if (sc->clean_below_min || sc->clean_below_low)
else if (sc->clean_below_low || sc->clean_below_min)
type = LRU_GEN_ANON;
else if (min_seq[LRU_GEN_ANON] < min_seq[LRU_GEN_FILE])
type = LRU_GEN_ANON;
Expand All @@ -5289,7 +5280,7 @@ static int isolate_folios(struct lruvec *lruvec, struct scan_control *sc, int sw
else
type = get_type_to_scan(lruvec, swappiness, &tier);

for (i = 0; i < ANON_AND_FILE; i++) {
for (i = !swappiness; i < ANON_AND_FILE; i++) {
if (tier < 0)
tier = get_tier_idx(lruvec, type);

Expand Down Expand Up @@ -6802,8 +6793,6 @@ static void shrink_node(pg_data_t *pgdat, struct scan_control *sc)
*/
if (reclaimable)
pgdat->kswapd_failures = 0;
else if (sc->clean_below_min && !sc->priority)
invoke_oom(sc);
}

/*
Expand Down

0 comments on commit b922073

Please sign in to comment.