7940380c5cee76936eb51177e86ba2164943165d
[openwrt/staging/blogic.git] /
1 From afd37e73db04c7e6b47411120ac5f6a7eca51fec Mon Sep 17 00:00:00 2001
2 From: Yu Zhao <yuzhao@google.com>
3 Date: Wed, 21 Dec 2022 21:19:00 -0700
4 Subject: [PATCH 22/29] mm: multi-gen LRU: rename lrugen->lists[] to
5 lrugen->folios[]
6
7 lru_gen_folio will be chained into per-node lists by the coming
8 lrugen->list.
9
10 Link: https://lkml.kernel.org/r/20221222041905.2431096-3-yuzhao@google.com
11 Signed-off-by: Yu Zhao <yuzhao@google.com>
12 Cc: Johannes Weiner <hannes@cmpxchg.org>
13 Cc: Jonathan Corbet <corbet@lwn.net>
14 Cc: Michael Larabel <Michael@MichaelLarabel.com>
15 Cc: Michal Hocko <mhocko@kernel.org>
16 Cc: Mike Rapoport <rppt@kernel.org>
17 Cc: Roman Gushchin <roman.gushchin@linux.dev>
18 Cc: Suren Baghdasaryan <surenb@google.com>
19 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
20 ---
21 include/linux/mm_inline.h | 4 ++--
22 include/linux/mmzone.h | 8 ++++----
23 mm/vmscan.c | 20 ++++++++++----------
24 3 files changed, 16 insertions(+), 16 deletions(-)
25
26 --- a/include/linux/mm_inline.h
27 +++ b/include/linux/mm_inline.h
28 @@ -256,9 +256,9 @@ static inline bool lru_gen_add_folio(str
29 lru_gen_update_size(lruvec, folio, -1, gen);
30 /* for folio_rotate_reclaimable() */
31 if (reclaiming)
32 - list_add_tail(&folio->lru, &lrugen->lists[gen][type][zone]);
33 + list_add_tail(&folio->lru, &lrugen->folios[gen][type][zone]);
34 else
35 - list_add(&folio->lru, &lrugen->lists[gen][type][zone]);
36 + list_add(&folio->lru, &lrugen->folios[gen][type][zone]);
37
38 return true;
39 }
40 --- a/include/linux/mmzone.h
41 +++ b/include/linux/mmzone.h
42 @@ -312,7 +312,7 @@ enum lruvec_flags {
43 * They form a sliding window of a variable size [MIN_NR_GENS, MAX_NR_GENS]. An
44 * offset within MAX_NR_GENS, i.e., gen, indexes the LRU list of the
45 * corresponding generation. The gen counter in folio->flags stores gen+1 while
46 - * a page is on one of lrugen->lists[]. Otherwise it stores 0.
47 + * a page is on one of lrugen->folios[]. Otherwise it stores 0.
48 *
49 * A page is added to the youngest generation on faulting. The aging needs to
50 * check the accessed bit at least twice before handing this page over to the
51 @@ -324,8 +324,8 @@ enum lruvec_flags {
52 * rest of generations, if they exist, are considered inactive. See
53 * lru_gen_is_active().
54 *
55 - * PG_active is always cleared while a page is on one of lrugen->lists[] so that
56 - * the aging needs not to worry about it. And it's set again when a page
57 + * PG_active is always cleared while a page is on one of lrugen->folios[] so
58 + * that the aging needs not to worry about it. And it's set again when a page
59 * considered active is isolated for non-reclaiming purposes, e.g., migration.
60 * See lru_gen_add_folio() and lru_gen_del_folio().
61 *
62 @@ -412,7 +412,7 @@ struct lru_gen_folio {
63 /* the birth time of each generation in jiffies */
64 unsigned long timestamps[MAX_NR_GENS];
65 /* the multi-gen LRU lists, lazily sorted on eviction */
66 - struct list_head lists[MAX_NR_GENS][ANON_AND_FILE][MAX_NR_ZONES];
67 + struct list_head folios[MAX_NR_GENS][ANON_AND_FILE][MAX_NR_ZONES];
68 /* the multi-gen LRU sizes, eventually consistent */
69 long nr_pages[MAX_NR_GENS][ANON_AND_FILE][MAX_NR_ZONES];
70 /* the exponential moving average of refaulted */
71 --- a/mm/vmscan.c
72 +++ b/mm/vmscan.c
73 @@ -4261,7 +4261,7 @@ static bool inc_min_seq(struct lruvec *l
74
75 /* prevent cold/hot inversion if force_scan is true */
76 for (zone = 0; zone < MAX_NR_ZONES; zone++) {
77 - struct list_head *head = &lrugen->lists[old_gen][type][zone];
78 + struct list_head *head = &lrugen->folios[old_gen][type][zone];
79
80 while (!list_empty(head)) {
81 struct folio *folio = lru_to_folio(head);
82 @@ -4272,7 +4272,7 @@ static bool inc_min_seq(struct lruvec *l
83 VM_WARN_ON_ONCE_FOLIO(folio_zonenum(folio) != zone, folio);
84
85 new_gen = folio_inc_gen(lruvec, folio, false);
86 - list_move_tail(&folio->lru, &lrugen->lists[new_gen][type][zone]);
87 + list_move_tail(&folio->lru, &lrugen->folios[new_gen][type][zone]);
88
89 if (!--remaining)
90 return false;
91 @@ -4300,7 +4300,7 @@ static bool try_to_inc_min_seq(struct lr
92 gen = lru_gen_from_seq(min_seq[type]);
93
94 for (zone = 0; zone < MAX_NR_ZONES; zone++) {
95 - if (!list_empty(&lrugen->lists[gen][type][zone]))
96 + if (!list_empty(&lrugen->folios[gen][type][zone]))
97 goto next;
98 }
99
100 @@ -4765,7 +4765,7 @@ static bool sort_folio(struct lruvec *lr
101
102 /* promoted */
103 if (gen != lru_gen_from_seq(lrugen->min_seq[type])) {
104 - list_move(&folio->lru, &lrugen->lists[gen][type][zone]);
105 + list_move(&folio->lru, &lrugen->folios[gen][type][zone]);
106 return true;
107 }
108
109 @@ -4774,7 +4774,7 @@ static bool sort_folio(struct lruvec *lr
110 int hist = lru_hist_from_seq(lrugen->min_seq[type]);
111
112 gen = folio_inc_gen(lruvec, folio, false);
113 - list_move_tail(&folio->lru, &lrugen->lists[gen][type][zone]);
114 + list_move_tail(&folio->lru, &lrugen->folios[gen][type][zone]);
115
116 WRITE_ONCE(lrugen->protected[hist][type][tier - 1],
117 lrugen->protected[hist][type][tier - 1] + delta);
118 @@ -4786,7 +4786,7 @@ static bool sort_folio(struct lruvec *lr
119 if (folio_test_locked(folio) || folio_test_writeback(folio) ||
120 (type == LRU_GEN_FILE && folio_test_dirty(folio))) {
121 gen = folio_inc_gen(lruvec, folio, true);
122 - list_move(&folio->lru, &lrugen->lists[gen][type][zone]);
123 + list_move(&folio->lru, &lrugen->folios[gen][type][zone]);
124 return true;
125 }
126
127 @@ -4853,7 +4853,7 @@ static int scan_folios(struct lruvec *lr
128 for (zone = sc->reclaim_idx; zone >= 0; zone--) {
129 LIST_HEAD(moved);
130 int skipped = 0;
131 - struct list_head *head = &lrugen->lists[gen][type][zone];
132 + struct list_head *head = &lrugen->folios[gen][type][zone];
133
134 while (!list_empty(head)) {
135 struct folio *folio = lru_to_folio(head);
136 @@ -5253,7 +5253,7 @@ static bool __maybe_unused state_is_vali
137 int gen, type, zone;
138
139 for_each_gen_type_zone(gen, type, zone) {
140 - if (!list_empty(&lrugen->lists[gen][type][zone]))
141 + if (!list_empty(&lrugen->folios[gen][type][zone]))
142 return false;
143 }
144 }
145 @@ -5298,7 +5298,7 @@ static bool drain_evictable(struct lruve
146 int remaining = MAX_LRU_BATCH;
147
148 for_each_gen_type_zone(gen, type, zone) {
149 - struct list_head *head = &lruvec->lrugen.lists[gen][type][zone];
150 + struct list_head *head = &lruvec->lrugen.folios[gen][type][zone];
151
152 while (!list_empty(head)) {
153 bool success;
154 @@ -5835,7 +5835,7 @@ void lru_gen_init_lruvec(struct lruvec *
155 lrugen->timestamps[i] = jiffies;
156
157 for_each_gen_type_zone(gen, type, zone)
158 - INIT_LIST_HEAD(&lrugen->lists[gen][type][zone]);
159 + INIT_LIST_HEAD(&lrugen->folios[gen][type][zone]);
160
161 lruvec->mm_state.seq = MIN_NR_GENS;
162 init_waitqueue_head(&lruvec->mm_state.wait);