Re: [PATCH v2] Revert "mm: skip CMA pages when they are not available"

From: 刘海龙(LaoLiu)
Date: Fri Mar 15 2024 - 06:44:08 EST


On 2024/3/15 16:46, Barry Song wrote:
> On Fri, Mar 15, 2024 at 9:18 PM <liuhailong@xxxxxxxx> wrote:
>>
>> From: "Hailong.Liu" <liuhailong@xxxxxxxx>
>>
>> This reverts
>> commit b7108d66318a ("Multi-gen LRU: skip CMA pages when they are not eligible")
>> commit 5da226dbfce3 ("mm: skip CMA pages when they are not available")
>
> Reverting these changes seems inappropriate since the original patches
> did improve most cases.
> While doing direct reclamation without MOVABLE flags, scanning cma
> folio doesn't help at all.
>

Absolutely, but without this patch it give chance to reclaim cma pages to freelist,
other tasks without this flag would work normally without holding too much time
on lru lock and lru size decrease。 it also trigger memory psi event to allow
admin do something to release memory.

>>
>> skip_cma may cause system not responding. if cma pages is large in lru_list
>> and system is in lowmemory, many tasks would direct reclaim and waste
>> cpu time to isolate_lru_pages and return.
>>
>> Test this patch on android-5.15 8G device
>> reproducer:
>> - cma_declare_contiguous 3G pages
>> - set /proc/sys/vm/swappiness 0 to enable direct_reclaim reclaim file
>> only.
>> - run a memleak process in userspace
>
>
> I assume that scanning cma folio provides additional opportunities to reclaim
> anonymous memory, even though it is ineffective for allocating NON-MOVABLE
> folios. Consequently, we alleviate pressure for future allocations of anonymous
> folios. Moreover, setting swappiness=0 is a rare scenario. Instead of entirely
> removing the mechanism, could we detect such corner cases and handle them
> differently.
>
> Otherwise, I don't see any chance of this being acknowledged.

It happens in internal aging test. open camera and record 8K video which use
more than 2Gib dmabuf pages. without this patch the devices would kill camera process,
but the system hang with it.

In fact, in my opinion the issue of this patch increase the scanning lru time
and reclaim nothing. Do you have a better solution ?

Brs,
Hailong.