0

I know that I can monitor / subscribe for events in case kernel is experiencing memory pressure using the memory pressure API. However, how about the opposite case? Is it possible to tell the Linux kernel to start behaving as if there were memory pressure already?

Rationale for this kind of API: if I have external knowledge that I'm going to run some memory hungry process e.g. 5 minutes in future and I would want to slowly try to make space for it so that the kernel doesn't need to stall all programs when it finally happens. However, this should be maybe low or medium pressure only because I don't want to make existing programs slow, only avoid the sudden spike in system when the memory hungry program is started in near future. As a result, simply allocating the expected amount of memory using e.g. stress would be a poor option.

I think optimal solution might be a fictional API like

echo "medium 5G" > /proc/sys/vm/force_memory_pressure

which would keep minimum memory pressure level "medium" until the MemAvailable is at least 5 GB; that is, if true memory pressure level goes critical this wouldn't limit it but if true level was low it would be increased to medium.

Mikko Rantalainen
  • 3,899
  • 1
  • 25
  • 32

0 Answers0