Re: [PATCH v5 3/4] mm: support large folios swapin as a whole for zRAM-like swapfile

From: Matthew Wilcox
Date: Mon Jul 29 2024 - 11:13:56 EST


On Tue, Jul 30, 2024 at 01:11:31AM +1200, Barry Song wrote:
> for this zRAM case, it is a new allocated large folio, only
> while all conditions are met, we will allocate and map
> the whole folio. you can check can_swapin_thp() and
> thp_swap_suitable_orders().

YOU ARE DOING THIS WRONGLY!

All of you anonymous memory people are utterly fixated on TLBs AND THIS
IS WRONG. Yes, TLB performance is important, particularly with crappy
ARM designs, which I know a lot of you are paid to work on. But you
seem to think this is the only consideration, and you're making bad
design choices as a result. It's overly complicated, and you're leaving
performance on the table.

Look back at the results Ryan showed in the early days of working on
large anonymous folios. Half of the performance win on his system came
from using larger TLBs. But the other half came from _reduced software
overhead_. The LRU lock is a huge problem, and using large folios cuts
the length of the LRU list, hence LRU lock hold time.

Your _own_ data on how hard it is to get hold of a large folio due to
fragmentation should be enough to convince you that the more large folios
in the system, the better the whole system runs. We should not decline to
allocate large folios just because they can't be mapped with a single TLB!