Skip to content

Commit 6df1b22

Browse files
yuzhaogoogleakpm00
authored andcommitted
mm: multi-gen LRU: rename lrugen->lists[] to lrugen->folios[]
lru_gen_folio will be chained into per-node lists by the coming lrugen->list. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Yu Zhao <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Michael Larabel <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Mike Rapoport <[email protected]> Cc: Roman Gushchin <[email protected]> Cc: Suren Baghdasaryan <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 391655f commit 6df1b22

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

Documentation/mm/multigen_lru.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@ variables are monotonically increasing.
8989

9090
Generation numbers are truncated into ``order_base_2(MAX_NR_GENS+1)``
9191
bits in order to fit into the gen counter in ``folio->flags``. Each
92-
truncated generation number is an index to ``lrugen->lists[]``. The
92+
truncated generation number is an index to ``lrugen->folios[]``. The
9393
sliding window technique is used to track at least ``MIN_NR_GENS`` and
9494
at most ``MAX_NR_GENS`` generations. The gen counter stores a value
9595
within ``[1, MAX_NR_GENS]`` while a page is on one of
96-
``lrugen->lists[]``; otherwise it stores zero.
96+
``lrugen->folios[]``; otherwise it stores zero.
9797

9898
Each generation is divided into multiple tiers. A page accessed ``N``
9999
times through file descriptors is in tier ``order_base_2(N)``. Unlike
100-
generations, tiers do not have dedicated ``lrugen->lists[]``. In
100+
generations, tiers do not have dedicated ``lrugen->folios[]``. In
101101
contrast to moving across generations, which requires the LRU lock,
102102
moving across tiers only involves atomic operations on
103103
``folio->flags`` and therefore has a negligible cost. A feedback loop
@@ -127,7 +127,7 @@ page mapped by this PTE to ``(max_seq%MAX_NR_GENS)+1``.
127127
Eviction
128128
--------
129129
The eviction consumes old generations. Given an ``lruvec``, it
130-
increments ``min_seq`` when ``lrugen->lists[]`` indexed by
130+
increments ``min_seq`` when ``lrugen->folios[]`` indexed by
131131
``min_seq%MAX_NR_GENS`` becomes empty. To select a type and a tier to
132132
evict from, it first compares ``min_seq[]`` to select the older type.
133133
If both types are equally old, it selects the one whose first tier has

include/linux/mm_inline.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,9 @@ static inline bool lru_gen_add_folio(struct lruvec *lruvec, struct folio *folio,
256256
lru_gen_update_size(lruvec, folio, -1, gen);
257257
/* for folio_rotate_reclaimable() */
258258
if (reclaiming)
259-
list_add_tail(&folio->lru, &lrugen->lists[gen][type][zone]);
259+
list_add_tail(&folio->lru, &lrugen->folios[gen][type][zone]);
260260
else
261-
list_add(&folio->lru, &lrugen->lists[gen][type][zone]);
261+
list_add(&folio->lru, &lrugen->folios[gen][type][zone]);
262262

263263
return true;
264264
}

include/linux/mmzone.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ enum lruvec_flags {
312312
* They form a sliding window of a variable size [MIN_NR_GENS, MAX_NR_GENS]. An
313313
* offset within MAX_NR_GENS, i.e., gen, indexes the LRU list of the
314314
* corresponding generation. The gen counter in folio->flags stores gen+1 while
315-
* a page is on one of lrugen->lists[]. Otherwise it stores 0.
315+
* a page is on one of lrugen->folios[]. Otherwise it stores 0.
316316
*
317317
* A page is added to the youngest generation on faulting. The aging needs to
318318
* check the accessed bit at least twice before handing this page over to the
@@ -324,8 +324,8 @@ enum lruvec_flags {
324324
* rest of generations, if they exist, are considered inactive. See
325325
* lru_gen_is_active().
326326
*
327-
* PG_active is always cleared while a page is on one of lrugen->lists[] so that
328-
* the aging needs not to worry about it. And it's set again when a page
327+
* PG_active is always cleared while a page is on one of lrugen->folios[] so
328+
* that the aging needs not to worry about it. And it's set again when a page
329329
* considered active is isolated for non-reclaiming purposes, e.g., migration.
330330
* See lru_gen_add_folio() and lru_gen_del_folio().
331331
*
@@ -412,7 +412,7 @@ struct lru_gen_folio {
412412
/* the birth time of each generation in jiffies */
413413
unsigned long timestamps[MAX_NR_GENS];
414414
/* the multi-gen LRU lists, lazily sorted on eviction */
415-
struct list_head lists[MAX_NR_GENS][ANON_AND_FILE][MAX_NR_ZONES];
415+
struct list_head folios[MAX_NR_GENS][ANON_AND_FILE][MAX_NR_ZONES];
416416
/* the multi-gen LRU sizes, eventually consistent */
417417
long nr_pages[MAX_NR_GENS][ANON_AND_FILE][MAX_NR_ZONES];
418418
/* the exponential moving average of refaulted */

mm/vmscan.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4271,7 +4271,7 @@ static bool inc_min_seq(struct lruvec *lruvec, int type, bool can_swap)
42714271

42724272
/* prevent cold/hot inversion if force_scan is true */
42734273
for (zone = 0; zone < MAX_NR_ZONES; zone++) {
4274-
struct list_head *head = &lrugen->lists[old_gen][type][zone];
4274+
struct list_head *head = &lrugen->folios[old_gen][type][zone];
42754275

42764276
while (!list_empty(head)) {
42774277
struct folio *folio = lru_to_folio(head);
@@ -4282,7 +4282,7 @@ static bool inc_min_seq(struct lruvec *lruvec, int type, bool can_swap)
42824282
VM_WARN_ON_ONCE_FOLIO(folio_zonenum(folio) != zone, folio);
42834283

42844284
new_gen = folio_inc_gen(lruvec, folio, false);
4285-
list_move_tail(&folio->lru, &lrugen->lists[new_gen][type][zone]);
4285+
list_move_tail(&folio->lru, &lrugen->folios[new_gen][type][zone]);
42864286

42874287
if (!--remaining)
42884288
return false;
@@ -4310,7 +4310,7 @@ static bool try_to_inc_min_seq(struct lruvec *lruvec, bool can_swap)
43104310
gen = lru_gen_from_seq(min_seq[type]);
43114311

43124312
for (zone = 0; zone < MAX_NR_ZONES; zone++) {
4313-
if (!list_empty(&lrugen->lists[gen][type][zone]))
4313+
if (!list_empty(&lrugen->folios[gen][type][zone]))
43144314
goto next;
43154315
}
43164316

@@ -4775,7 +4775,7 @@ static bool sort_folio(struct lruvec *lruvec, struct folio *folio, int tier_idx)
47754775

47764776
/* promoted */
47774777
if (gen != lru_gen_from_seq(lrugen->min_seq[type])) {
4778-
list_move(&folio->lru, &lrugen->lists[gen][type][zone]);
4778+
list_move(&folio->lru, &lrugen->folios[gen][type][zone]);
47794779
return true;
47804780
}
47814781

@@ -4784,7 +4784,7 @@ static bool sort_folio(struct lruvec *lruvec, struct folio *folio, int tier_idx)
47844784
int hist = lru_hist_from_seq(lrugen->min_seq[type]);
47854785

47864786
gen = folio_inc_gen(lruvec, folio, false);
4787-
list_move_tail(&folio->lru, &lrugen->lists[gen][type][zone]);
4787+
list_move_tail(&folio->lru, &lrugen->folios[gen][type][zone]);
47884788

47894789
WRITE_ONCE(lrugen->protected[hist][type][tier - 1],
47904790
lrugen->protected[hist][type][tier - 1] + delta);
@@ -4796,7 +4796,7 @@ static bool sort_folio(struct lruvec *lruvec, struct folio *folio, int tier_idx)
47964796
if (folio_test_locked(folio) || folio_test_writeback(folio) ||
47974797
(type == LRU_GEN_FILE && folio_test_dirty(folio))) {
47984798
gen = folio_inc_gen(lruvec, folio, true);
4799-
list_move(&folio->lru, &lrugen->lists[gen][type][zone]);
4799+
list_move(&folio->lru, &lrugen->folios[gen][type][zone]);
48004800
return true;
48014801
}
48024802

@@ -4863,7 +4863,7 @@ static int scan_folios(struct lruvec *lruvec, struct scan_control *sc,
48634863
for (zone = sc->reclaim_idx; zone >= 0; zone--) {
48644864
LIST_HEAD(moved);
48654865
int skipped = 0;
4866-
struct list_head *head = &lrugen->lists[gen][type][zone];
4866+
struct list_head *head = &lrugen->folios[gen][type][zone];
48674867

48684868
while (!list_empty(head)) {
48694869
struct folio *folio = lru_to_folio(head);
@@ -5264,7 +5264,7 @@ static bool __maybe_unused state_is_valid(struct lruvec *lruvec)
52645264
int gen, type, zone;
52655265

52665266
for_each_gen_type_zone(gen, type, zone) {
5267-
if (!list_empty(&lrugen->lists[gen][type][zone]))
5267+
if (!list_empty(&lrugen->folios[gen][type][zone]))
52685268
return false;
52695269
}
52705270
}
@@ -5309,7 +5309,7 @@ static bool drain_evictable(struct lruvec *lruvec)
53095309
int remaining = MAX_LRU_BATCH;
53105310

53115311
for_each_gen_type_zone(gen, type, zone) {
5312-
struct list_head *head = &lruvec->lrugen.lists[gen][type][zone];
5312+
struct list_head *head = &lruvec->lrugen.folios[gen][type][zone];
53135313

53145314
while (!list_empty(head)) {
53155315
bool success;
@@ -5843,7 +5843,7 @@ void lru_gen_init_lruvec(struct lruvec *lruvec)
58435843
lrugen->timestamps[i] = jiffies;
58445844

58455845
for_each_gen_type_zone(gen, type, zone)
5846-
INIT_LIST_HEAD(&lrugen->lists[gen][type][zone]);
5846+
INIT_LIST_HEAD(&lrugen->folios[gen][type][zone]);
58475847

58485848
lruvec->mm_state.seq = MIN_NR_GENS;
58495849
init_waitqueue_head(&lruvec->mm_state.wait);

0 commit comments

Comments
 (0)