Commit d7f1afd0 authored by T.J. Alumbaugh's avatar T.J. Alumbaugh Committed by Andrew Morton

mm: multi-gen LRU: cleanup lru_gen_test_recent()

Avoid passing memcg* and pglist_data* to lru_gen_test_recent()
since we only use the lruvec anyway.

Link: https://lkml.kernel.org/r/20230522112058.2965866-4-talumbau@google.comSigned-off-by: default avatarT.J. Alumbaugh <talumbau@google.com>
Reviewed-by: default avatarYuanchu Xie <yuanchu@google.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Yu Zhao <yuzhao@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent bd02df41
...@@ -257,59 +257,46 @@ static void *lru_gen_eviction(struct folio *folio) ...@@ -257,59 +257,46 @@ static void *lru_gen_eviction(struct folio *folio)
/* /*
* Tests if the shadow entry is for a folio that was recently evicted. * Tests if the shadow entry is for a folio that was recently evicted.
* Fills in @memcgid, @pglist_data, @token, @workingset with the values * Fills in @lruvec, @token, @workingset with the values unpacked from shadow.
* unpacked from shadow.
*/ */
static bool lru_gen_test_recent(void *shadow, bool file, int *memcgid, static bool lru_gen_test_recent(void *shadow, bool file, struct lruvec **lruvec,
struct pglist_data **pgdat, unsigned long *token, bool *workingset) unsigned long *token, bool *workingset)
{ {
struct mem_cgroup *eviction_memcg; int memcg_id;
struct lruvec *lruvec;
struct lru_gen_folio *lrugen;
unsigned long min_seq; unsigned long min_seq;
struct mem_cgroup *memcg;
struct pglist_data *pgdat;
unpack_shadow(shadow, memcgid, pgdat, token, workingset); unpack_shadow(shadow, &memcg_id, &pgdat, token, workingset);
eviction_memcg = mem_cgroup_from_id(*memcgid);
lruvec = mem_cgroup_lruvec(eviction_memcg, *pgdat); memcg = mem_cgroup_from_id(memcg_id);
lrugen = &lruvec->lrugen; *lruvec = mem_cgroup_lruvec(memcg, pgdat);
min_seq = READ_ONCE(lrugen->min_seq[file]); min_seq = READ_ONCE((*lruvec)->lrugen.min_seq[file]);
return (*token >> LRU_REFS_WIDTH) == (min_seq & (EVICTION_MASK >> LRU_REFS_WIDTH)); return (*token >> LRU_REFS_WIDTH) == (min_seq & (EVICTION_MASK >> LRU_REFS_WIDTH));
} }
static void lru_gen_refault(struct folio *folio, void *shadow) static void lru_gen_refault(struct folio *folio, void *shadow)
{ {
int hist, tier, refs; int hist, tier, refs;
int memcg_id;
bool workingset; bool workingset;
unsigned long token; unsigned long token;
unsigned long min_seq;
struct lruvec *lruvec; struct lruvec *lruvec;
struct lru_gen_folio *lrugen; struct lru_gen_folio *lrugen;
struct mem_cgroup *memcg;
struct pglist_data *pgdat;
int type = folio_is_file_lru(folio); int type = folio_is_file_lru(folio);
int delta = folio_nr_pages(folio); int delta = folio_nr_pages(folio);
rcu_read_lock(); rcu_read_lock();
if (!lru_gen_test_recent(shadow, type, &memcg_id, &pgdat, &token, if (!lru_gen_test_recent(shadow, type, &lruvec, &token, &workingset))
&workingset))
goto unlock;
memcg = folio_memcg_rcu(folio);
if (memcg_id != mem_cgroup_id(memcg))
goto unlock; goto unlock;
if (pgdat != folio_pgdat(folio)) if (lruvec != folio_lruvec(folio))
goto unlock; goto unlock;
lruvec = mem_cgroup_lruvec(memcg, pgdat);
lrugen = &lruvec->lrugen; lrugen = &lruvec->lrugen;
min_seq = READ_ONCE(lrugen->min_seq[type]);
hist = lru_hist_from_seq(min_seq); hist = lru_hist_from_seq(READ_ONCE(lrugen->min_seq[type]));
/* see the comment in folio_lru_refs() */ /* see the comment in folio_lru_refs() */
refs = (token & (BIT(LRU_REFS_WIDTH) - 1)) + workingset; refs = (token & (BIT(LRU_REFS_WIDTH) - 1)) + workingset;
tier = lru_tier_from_refs(refs); tier = lru_tier_from_refs(refs);
...@@ -339,8 +326,8 @@ static void *lru_gen_eviction(struct folio *folio) ...@@ -339,8 +326,8 @@ static void *lru_gen_eviction(struct folio *folio)
return NULL; return NULL;
} }
static bool lru_gen_test_recent(void *shadow, bool file, int *memcgid, static bool lru_gen_test_recent(void *shadow, bool file, struct lruvec **lruvec,
struct pglist_data **pgdat, unsigned long *token, bool *workingset) unsigned long *token, bool *workingset)
{ {
return false; return false;
} }
...@@ -435,8 +422,7 @@ bool workingset_test_recent(void *shadow, bool file, bool *workingset) ...@@ -435,8 +422,7 @@ bool workingset_test_recent(void *shadow, bool file, bool *workingset)
unsigned long eviction; unsigned long eviction;
if (lru_gen_enabled()) if (lru_gen_enabled())
return lru_gen_test_recent(shadow, file, &memcgid, &pgdat, &eviction, return lru_gen_test_recent(shadow, file, &eviction_lruvec, &eviction, workingset);
workingset);
unpack_shadow(shadow, &memcgid, &pgdat, &eviction, workingset); unpack_shadow(shadow, &memcgid, &pgdat, &eviction, workingset);
eviction <<= bucket_order; eviction <<= bucket_order;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment