Re: [PATCH v7 04/12] mm: multigenerational LRU: groundwork
From: Yu Zhao <hidden>
Date: 2022-03-11 23:45:21
Also in:
linux-arm-kernel, linux-mm, lkml
On Fri, Mar 11, 2022 at 3:16 AM Barry Song [off-list ref] wrote:
On Tue, Feb 15, 2022 at 10:43 PM Yu Zhao [off-list ref] wrote:quoted
On Thu, Feb 10, 2022 at 03:41:57PM -0500, Johannes Weiner wrote: Thanks for reviewing.quoted
quoted
+static inline bool lru_gen_is_active(struct lruvec *lruvec, int gen) +{ + unsigned long max_seq = lruvec->lrugen.max_seq; + + VM_BUG_ON(gen >= MAX_NR_GENS); + + /* see the comment on MIN_NR_GENS */ + return gen == lru_gen_from_seq(max_seq) || gen == lru_gen_from_seq(max_seq - 1); +}I'm still reading the series, so correct me if I'm wrong: the "active" set is split into two generations for the sole purpose of the second-chance policy for fresh faults, right?To be precise, the active/inactive notion on top of generations is just for ABI compatibility, e.g., the counters in /proc/vmstat. Otherwise, this function wouldn't be needed.Hi Yu, I am still quite confused as i am seeing both active/inactive and lru_gen. eg: root@ubuntu:~# cat /proc/vmstat | grep active nr_zone_inactive_anon 22797 nr_zone_active_anon 578405 nr_zone_inactive_file 0 nr_zone_active_file 4156 nr_inactive_anon 22800 nr_active_anon 578574 nr_inactive_file 0 nr_active_file 4215
Yes, this is expected. We have to maintain the ABI, i.e., the *_active/inactive_* counters.
and:
root@ubuntu:~# cat /sys//kernel/debug/lru_gen
...
memcg 36 /user.slice/user-0.slice/user@0.service
node 0
20 18820 22 0
21 7452 0 0
22 7448 0 0
memcg 33 /user.slice/user-0.slice/user@0.service/app.slice
node 0
0 2171452 0 0
1 2171452 0 0
2 2171452 0 0
3 2171452 0 0
memcg 37 /user.slice/user-0.slice/session-1.scope
node 0
42 51804 102127 0
43 18840 275622 0
44 16104 216805 1
Does it mean one page could be in both one of the generations and one
of the active/inactive lists?In terms of the data structure, evictable pages are either on lruvec->lists or lrugen->lists.
Do we have some mapping relationship between active/inactive lists with generations?
For the counters, yes -- pages in max_seq and max_seq-1 are counted as active, and the rest are inactive.
We used to put a faulted file page in inactive, if we access it a second time, it can be promoted to active. then in recent years, we have also applied this to anon pages while kernel adds workingset protection for anon pages. so basically both anon and file pages go into the inactive list for the 1st time, if we access it for the second time, they go to the active list. if we don't access it any more, they are likely to be reclaimed as they are inactive. we do have some special fastpath for code section, executable file pages are kept on active list as long as they are accessed.
Yes.
so all of the above concerns are actually not that correct?
They are valid concerns but I don't know any popular workloads that care about them.