Commit 83b6ba5
mm/mglru: scan and count the exact number of folios
Make the scan helpers return the exact number of folios being scanned
or isolated. Since the reclaim loop now has a natural scan budget that
controls the scan progress, returning the scan number and consume the
budget should make the scan more accurate and easier to follow.
The number of scanned folios for each iteration is always positive and
larger than 0, unless the reclaim must stop for a forced aging, so
there is no more need for any special handling when there is no
progress made:
- `return isolated || !remaining ? scanned : 0` in scan_folios: both
the function and the call now just return the exact scan count,
combined with the scan budget introduced in the previous commit to
avoid livelock or under scan.
- `scanned += try_to_inc_min_seq` in evict_folios: adding a bool as a
scan count was kind of confusing and no longer needed to, as scan
number should never be zero as long as there are still evictable
gens. We may encounter a empty old gen that return 0 scan count,
to avoid that, do a try_to_inc_min_seq before isolation which
have slight to none overhead in most cases.
- `evictable_min_seq + MIN_NR_GENS > max_seq` guard in evict_folios:
the per-type get_nr_gens == MIN_NR_GENS check in scan_folios
naturally returns 0 when only two gens remain and breaks the loop.
Also change try_to_inc_min_seq to return void, as its return value is
no longer used by any caller. Move the call before isolate_folios so
that any empty gens created by external folio freeing are flushed, and
add another call after isolate_folios to also flush empty gens that
isolation itself may create.
The scan still stops if there are only two gens left as the scan number
will be zero, this behavior is same as before. This force gen protection
may get removed or softened later to improve the reclaim a bit more.
Signed-off-by: Kairui Song <kasong@tencent.com>
Reviewed-by: Axel Rasmussen <axelrasmussen@google.com>1 parent cab143a commit 83b6ba5
1 file changed
Lines changed: 30 additions & 30 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3896 | 3896 | | |
3897 | 3897 | | |
3898 | 3898 | | |
3899 | | - | |
| 3899 | + | |
3900 | 3900 | | |
3901 | 3901 | | |
3902 | | - | |
3903 | 3902 | | |
3904 | 3903 | | |
3905 | 3904 | | |
| |||
3925 | 3924 | | |
3926 | 3925 | | |
3927 | 3926 | | |
3928 | | - | |
3929 | | - | |
| 3927 | + | |
3930 | 3928 | | |
3931 | 3929 | | |
3932 | | - | |
| 3930 | + | |
3933 | 3931 | | |
3934 | 3932 | | |
3935 | 3933 | | |
| |||
3947 | 3945 | | |
3948 | 3946 | | |
3949 | 3947 | | |
3950 | | - | |
3951 | 3948 | | |
3952 | | - | |
3953 | | - | |
3954 | 3949 | | |
3955 | 3950 | | |
3956 | 3951 | | |
| |||
4545 | 4540 | | |
4546 | 4541 | | |
4547 | 4542 | | |
4548 | | - | |
| 4543 | + | |
4549 | 4544 | | |
4550 | 4545 | | |
4551 | 4546 | | |
| |||
4620 | 4615 | | |
4621 | 4616 | | |
4622 | 4617 | | |
4623 | | - | |
4624 | | - | |
4625 | | - | |
4626 | | - | |
4627 | | - | |
| 4618 | + | |
| 4619 | + | |
| 4620 | + | |
4628 | 4621 | | |
4629 | 4622 | | |
4630 | 4623 | | |
| |||
4668 | 4661 | | |
4669 | 4662 | | |
4670 | 4663 | | |
4671 | | - | |
| 4664 | + | |
| 4665 | + | |
4672 | 4666 | | |
4673 | 4667 | | |
| 4668 | + | |
4674 | 4669 | | |
4675 | 4670 | | |
4676 | 4671 | | |
4677 | | - | |
| 4672 | + | |
4678 | 4673 | | |
4679 | 4674 | | |
4680 | | - | |
| 4675 | + | |
| 4676 | + | |
4681 | 4677 | | |
4682 | | - | |
4683 | | - | |
4684 | | - | |
| 4678 | + | |
| 4679 | + | |
| 4680 | + | |
| 4681 | + | |
| 4682 | + | |
| 4683 | + | |
4685 | 4684 | | |
4686 | 4685 | | |
4687 | 4686 | | |
4688 | 4687 | | |
4689 | | - | |
| 4688 | + | |
4690 | 4689 | | |
4691 | 4690 | | |
4692 | 4691 | | |
4693 | 4692 | | |
4694 | 4693 | | |
4695 | | - | |
4696 | | - | |
4697 | | - | |
4698 | 4694 | | |
4699 | 4695 | | |
4700 | 4696 | | |
4701 | 4697 | | |
4702 | 4698 | | |
4703 | 4699 | | |
4704 | 4700 | | |
| 4701 | + | |
| 4702 | + | |
4705 | 4703 | | |
4706 | | - | |
4707 | 4704 | | |
4708 | 4705 | | |
4709 | 4706 | | |
4710 | 4707 | | |
4711 | 4708 | | |
4712 | | - | |
| 4709 | + | |
| 4710 | + | |
4713 | 4711 | | |
4714 | | - | |
| 4712 | + | |
| 4713 | + | |
4715 | 4714 | | |
4716 | | - | |
4717 | | - | |
| 4715 | + | |
| 4716 | + | |
| 4717 | + | |
4718 | 4718 | | |
4719 | 4719 | | |
4720 | 4720 | | |
| |||
4725 | 4725 | | |
4726 | 4726 | | |
4727 | 4727 | | |
4728 | | - | |
| 4728 | + | |
4729 | 4729 | | |
4730 | 4730 | | |
4731 | 4731 | | |
| |||
0 commit comments