mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-29 10:08:59 +00:00
e3559fb445
Changelog: https://cdn.kernel.org/pub/linux/kernel/v6.x/ChangeLog-6.1.54 Removed upstreamed: generic/backport-6.1/020-v6.3-02-UPSTREAM-mm-multi-gen-LRU-rename-lrugen-lists-to-lru.patch[1] ipq806x/patches-6.1/140-v6.5-hwspinlock-qcom-add-missing-regmap-config-for-SFPB-M.patch[2] All other patches automatically rebased. 1. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v6.1.54&id=a73d04c460521e45f257d28d73df096e41ece324 2. https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v6.1.54&id=e93bc372dbc0bde133c854c03502a95617041972 Build system: x86/64 Build-tested: x86/64/AMD Cezanne Run-tested: x86/64/AMD Cezanne Signed-off-by: John Audia <therealgraysky@proton.me>
93 lines
2.7 KiB
Diff
93 lines
2.7 KiB
Diff
From 620b0ee94455e48d124414cd06d8a53f69fb6453 Mon Sep 17 00:00:00 2001
|
|
From: Yu Zhao <yuzhao@google.com>
|
|
Date: Mon, 13 Feb 2023 00:53:22 -0700
|
|
Subject: [PATCH 09/19] UPSTREAM: mm: multi-gen LRU: avoid futile retries
|
|
|
|
Recall that the per-node memcg LRU has two generations and they alternate
|
|
when the last memcg (of a given node) is moved from one to the other.
|
|
Each generation is also sharded into multiple bins to improve scalability.
|
|
A reclaimer starts with a random bin (in the old generation) and, if it
|
|
fails, it will retry, i.e., to try the rest of the bins.
|
|
|
|
If a reclaimer fails with the last memcg, it should move this memcg to the
|
|
young generation first, which causes the generations to alternate, and
|
|
then retry. Otherwise, the retries will be futile because all other bins
|
|
are empty.
|
|
|
|
Link: https://lkml.kernel.org/r/20230213075322.1416966-1-yuzhao@google.com
|
|
Fixes: e4dde56cd208 ("mm: multi-gen LRU: per-node lru_gen_folio lists")
|
|
Signed-off-by: Yu Zhao <yuzhao@google.com>
|
|
Reported-by: T.J. Mercier <tjmercier@google.com>
|
|
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
|
|
Bug: 274865848
|
|
(cherry picked from commit 9f550d78b40da21b4da515db4c37d8d7b12aa1a6)
|
|
Change-Id: Ie92535676b005ec9e7987632b742fdde8d54436f
|
|
Signed-off-by: T.J. Mercier <tjmercier@google.com>
|
|
---
|
|
mm/vmscan.c | 25 +++++++++++++++----------
|
|
1 file changed, 15 insertions(+), 10 deletions(-)
|
|
|
|
--- a/mm/vmscan.c
|
|
+++ b/mm/vmscan.c
|
|
@@ -5218,18 +5218,20 @@ static int shrink_one(struct lruvec *lru
|
|
|
|
static void shrink_many(struct pglist_data *pgdat, struct scan_control *sc)
|
|
{
|
|
+ int op;
|
|
int gen;
|
|
int bin;
|
|
int first_bin;
|
|
struct lruvec *lruvec;
|
|
struct lru_gen_folio *lrugen;
|
|
+ struct mem_cgroup *memcg;
|
|
const struct hlist_nulls_node *pos;
|
|
- int op = 0;
|
|
- struct mem_cgroup *memcg = NULL;
|
|
unsigned long nr_to_reclaim = get_nr_to_reclaim(sc);
|
|
|
|
bin = first_bin = get_random_u32_below(MEMCG_NR_BINS);
|
|
restart:
|
|
+ op = 0;
|
|
+ memcg = NULL;
|
|
gen = get_memcg_gen(READ_ONCE(pgdat->memcg_lru.seq));
|
|
|
|
rcu_read_lock();
|
|
@@ -5253,14 +5255,22 @@ restart:
|
|
|
|
op = shrink_one(lruvec, sc);
|
|
|
|
- if (sc->nr_reclaimed >= nr_to_reclaim)
|
|
- goto success;
|
|
-
|
|
rcu_read_lock();
|
|
+
|
|
+ if (sc->nr_reclaimed >= nr_to_reclaim)
|
|
+ break;
|
|
}
|
|
|
|
rcu_read_unlock();
|
|
|
|
+ if (op)
|
|
+ lru_gen_rotate_memcg(lruvec, op);
|
|
+
|
|
+ mem_cgroup_put(memcg);
|
|
+
|
|
+ if (sc->nr_reclaimed >= nr_to_reclaim)
|
|
+ return;
|
|
+
|
|
/* restart if raced with lru_gen_rotate_memcg() */
|
|
if (gen != get_nulls_value(pos))
|
|
goto restart;
|
|
@@ -5269,11 +5279,6 @@ restart:
|
|
bin = get_memcg_bin(bin + 1);
|
|
if (bin != first_bin)
|
|
goto restart;
|
|
-success:
|
|
- if (op)
|
|
- lru_gen_rotate_memcg(lruvec, op);
|
|
-
|
|
- mem_cgroup_put(memcg);
|
|
}
|
|
|
|
static void lru_gen_shrink_lruvec(struct lruvec *lruvec, struct scan_control *sc)
|