Commit 30d77b7
mm/mglru: fix ineffective protection calculation
mem_cgroup_calculate_protection() is not stateless and should only be used
as part of a top-down tree traversal. shrink_one() traverses the per-node
memcg LRU instead of the root_mem_cgroup tree, and therefore it should not
call mem_cgroup_calculate_protection().
The existing misuse in shrink_one() can cause ineffective protection of
sub-trees that are grandchildren of root_mem_cgroup. Fix it by reusing
lru_gen_age_node(), which already traverses the root_mem_cgroup tree, to
calculate the protection.
Previously lru_gen_age_node() opportunistically skips the first pass,
i.e., when scan_control->priority is DEF_PRIORITY. On the second pass,
lruvec_is_sizable() uses appropriate scan_control->priority, set by
set_initial_priority() from lru_gen_shrink_node(), to decide whether a
memcg is too small to reclaim from.
Now lru_gen_age_node() unconditionally traverses the root_mem_cgroup tree.
So it should call set_initial_priority() upfront, to make sure
lruvec_is_sizable() uses appropriate scan_control->priority on the first
pass. Otherwise, lruvec_is_reclaimable() can return false negatives and
result in premature OOM kills when min_ttl_ms is used.
Link: https://lkml.kernel.org/r/[email protected]
Fixes: e4dde56 ("mm: multi-gen LRU: per-node lru_gen_folio lists")
Signed-off-by: Yu Zhao <[email protected]>
Reported-by: T.J. Mercier <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>1 parent b749cb0 commit 30d77b7
1 file changed
+38
-44
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3915 | 3915 | | |
3916 | 3916 | | |
3917 | 3917 | | |
| 3918 | + | |
| 3919 | + | |
| 3920 | + | |
| 3921 | + | |
| 3922 | + | |
| 3923 | + | |
| 3924 | + | |
| 3925 | + | |
| 3926 | + | |
| 3927 | + | |
| 3928 | + | |
| 3929 | + | |
| 3930 | + | |
| 3931 | + | |
| 3932 | + | |
| 3933 | + | |
| 3934 | + | |
| 3935 | + | |
| 3936 | + | |
| 3937 | + | |
| 3938 | + | |
| 3939 | + | |
| 3940 | + | |
| 3941 | + | |
| 3942 | + | |
| 3943 | + | |
3918 | 3944 | | |
3919 | 3945 | | |
3920 | 3946 | | |
| |||
3948 | 3974 | | |
3949 | 3975 | | |
3950 | 3976 | | |
3951 | | - | |
3952 | | - | |
3953 | | - | |
3954 | | - | |
3955 | | - | |
| 3977 | + | |
3956 | 3978 | | |
3957 | 3979 | | |
3958 | 3980 | | |
3959 | 3981 | | |
3960 | 3982 | | |
3961 | | - | |
| 3983 | + | |
| 3984 | + | |
| 3985 | + | |
3962 | 3986 | | |
3963 | | - | |
| 3987 | + | |
3964 | 3988 | | |
3965 | 3989 | | |
3966 | 3990 | | |
| |||
3970 | 3994 | | |
3971 | 3995 | | |
3972 | 3996 | | |
| 3997 | + | |
3973 | 3998 | | |
3974 | 3999 | | |
3975 | 4000 | | |
3976 | | - | |
3977 | | - | |
3978 | | - | |
| 4001 | + | |
3979 | 4002 | | |
3980 | 4003 | | |
3981 | 4004 | | |
3982 | 4005 | | |
3983 | 4006 | | |
3984 | | - | |
3985 | | - | |
3986 | | - | |
3987 | | - | |
| 4007 | + | |
3988 | 4008 | | |
3989 | | - | |
| 4009 | + | |
| 4010 | + | |
3990 | 4011 | | |
3991 | 4012 | | |
3992 | 4013 | | |
3993 | 4014 | | |
3994 | 4015 | | |
3995 | 4016 | | |
3996 | 4017 | | |
3997 | | - | |
| 4018 | + | |
3998 | 4019 | | |
3999 | 4020 | | |
4000 | 4021 | | |
| |||
4786 | 4807 | | |
4787 | 4808 | | |
4788 | 4809 | | |
4789 | | - | |
4790 | | - | |
| 4810 | + | |
4791 | 4811 | | |
4792 | 4812 | | |
4793 | 4813 | | |
| |||
4911 | 4931 | | |
4912 | 4932 | | |
4913 | 4933 | | |
4914 | | - | |
4915 | | - | |
4916 | | - | |
4917 | | - | |
4918 | | - | |
4919 | | - | |
4920 | | - | |
4921 | | - | |
4922 | | - | |
4923 | | - | |
4924 | | - | |
4925 | | - | |
4926 | | - | |
4927 | | - | |
4928 | | - | |
4929 | | - | |
4930 | | - | |
4931 | | - | |
4932 | | - | |
4933 | | - | |
4934 | | - | |
4935 | | - | |
4936 | | - | |
4937 | | - | |
4938 | | - | |
4939 | | - | |
4940 | 4934 | | |
4941 | 4935 | | |
4942 | 4936 | | |
| |||
0 commit comments