RE: [PATCH v3] dma-buf/heaps: system_heap: avoid too much allocation

From: Jaewon Kim
Date: Wed Apr 12 2023 - 08:35:54 EST


>On Wed 12-04-23 20:37:59, Jaewon Kim wrote:
>> Limiting dmabuf memory may be required. But I think there
>> is no nice and reasonable way so far.
>
>If that is really the way then the patch doesn't really add a big
>benefit. It doesn't really prevent OOMs (or panics due to OOM) as the
>allocator still allows to consume arbitrary amount of memory. The
>provided check is not able to tell between buggy and legit calls.
>--
>Michal Hocko
>SUSE Labs

Yes it could be. Though the buggy call is blocked by totalram_pages check,
mm may suffer memory shortage due to the huge memory consumption through
dma-buf system heap. We just hope Android LMKD or oomk kills the memory
hoggers prior to oom panic.

IMO if possible mm should be able to track the dma-buf size as stat in
mm_rss_stat for each process. Then oomk is able to know size through
get_mm_rss. Actually in mobile device environment, there is one more
this kind of allocator. That is graphics drivers. They also consumes
quite much memory and they may allocate as userspace wants.

Jaewon Kim