08804e002352bc33e5ed00663bf03f4764dbd688
[openwrt/staging/rmilecki.git] /
1 From 1b5e4c317d80f4826eceb3781702d18d06b14394 Mon Sep 17 00:00:00 2001
2 From: "T.J. Alumbaugh" <talumbau@google.com>
3 Date: Wed, 18 Jan 2023 00:18:21 +0000
4 Subject: [PATCH 12/19] UPSTREAM: mm: multi-gen LRU: section for working set
5 protection
6
7 Patch series "mm: multi-gen LRU: improve".
8
9 This patch series improves a few MGLRU functions, collects related
10 functions, and adds additional documentation.
11
12 This patch (of 7):
13
14 Add a section for working set protection in the code and the design doc.
15 The admin doc already contains its usage.
16
17 Link: https://lkml.kernel.org/r/20230118001827.1040870-1-talumbau@google.com
18 Link: https://lkml.kernel.org/r/20230118001827.1040870-2-talumbau@google.com
19 Change-Id: I65599075fd42951db7739a2ab7cee78516e157b3
20 Signed-off-by: T.J. Alumbaugh <talumbau@google.com>
21 Cc: Yu Zhao <yuzhao@google.com>
22 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
23 (cherry picked from commit 7b8144e63d84716f16a1b929e0c7e03ae5c4d5c1)
24 Bug: 274865848
25 Signed-off-by: T.J. Mercier <tjmercier@google.com>
26 ---
27 Documentation/mm/multigen_lru.rst | 15 +++++++++++++++
28 mm/vmscan.c | 4 ++++
29 2 files changed, 19 insertions(+)
30
31 diff --git a/Documentation/mm/multigen_lru.rst b/Documentation/mm/multigen_lru.rst
32 index d8f721f98868a..6e1483e70fdca 100644
33 --- a/Documentation/mm/multigen_lru.rst
34 +++ b/Documentation/mm/multigen_lru.rst
35 @@ -141,6 +141,21 @@ loop has detected outlying refaults from the tier this page is in. To
36 this end, the feedback loop uses the first tier as the baseline, for
37 the reason stated earlier.
38
39 +Working set protection
40 +----------------------
41 +Each generation is timestamped at birth. If ``lru_gen_min_ttl`` is
42 +set, an ``lruvec`` is protected from the eviction when its oldest
43 +generation was born within ``lru_gen_min_ttl`` milliseconds. In other
44 +words, it prevents the working set of ``lru_gen_min_ttl`` milliseconds
45 +from getting evicted. The OOM killer is triggered if this working set
46 +cannot be kept in memory.
47 +
48 +This time-based approach has the following advantages:
49 +
50 +1. It is easier to configure because it is agnostic to applications
51 + and memory sizes.
52 +2. It is more reliable because it is directly wired to the OOM killer.
53 +
54 Summary
55 -------
56 The multi-gen LRU can be disassembled into the following parts:
57 diff --git a/mm/vmscan.c b/mm/vmscan.c
58 index 596fed6ae0439..ab0b8d3b9d88f 100644
59 --- a/mm/vmscan.c
60 +++ b/mm/vmscan.c
61 @@ -4459,6 +4459,10 @@ static bool try_to_inc_max_seq(struct lruvec *lruvec, unsigned long max_seq,
62 return true;
63 }
64
65 +/******************************************************************************
66 + * working set protection
67 + ******************************************************************************/
68 +
69 static bool lruvec_is_sizable(struct lruvec *lruvec, struct scan_control *sc)
70 {
71 int gen, type, zone;
72 --
73 2.40.1
74