Re: [PATCH RFC v2] Opportunistic memory reclaim

From: Chris Down
Date: Mon Oct 05 2020 - 10:46:21 EST


Andrea Righi writes:
senpai is focused at estimating the ideal memory requirements without
affecting performance. And this covers the use case about reducing
memory footprint.

In my specific use-case (hibernation) I would let the system use as much
memory as possible if it's doing any activity (reclaiming memory only
when the kernel decides that it needs to reclaim memory) and apply a
more aggressive memory reclaiming policy when the system is mostly idle.

From this description, I don't see any reason why it needs to be implemented in kernel space. All of that information is available to userspace, and all of the knobs are there.

As it is I'm afraid of the "only when the system is mostly idle" comment, because it's usually after such periods that applications need to do large retrievals, and now they're going to be in slowpath (eg. periodic jobs).

Such tradeoffs for a specific situation might be fine in userspace as a distribution maintainer, but codifying them in the kernel seems premature to me, especially for a knob which we will have to maintain forever onwards.

I could probably implement this behavior adjusting memory.high
dynamically, like senpai, but I'm worried about potential sudden large
allocations that may require to respond faster at increasing
memory.high. I think the user-space triggered memory reclaim approach is
a safer solution from this perspective.

Have you seen Shakeel's recent "per-memcg reclaim interface" patches? I suspect they may help you there.