lkml.org 
[lkml]   [2012]   [Nov]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC 3/3] man-pages: Add man page for vmpressure_fd(2)
On Mon, 19 Nov 2012, Anton Vorontsov wrote:

> We try to make userland freeing resources when the system becomes low on
> memory. Once we're short on memory, sometimes it's better to discard
> (free) data, rather than let the kernel to drain file caches or even start
> swapping.
>

To add another usecase: its possible to modify our version of malloc (or
any malloc) so that memory that is free()'d can be released back to the
kernel only when necessary, i.e. when keeping the extra memory around
starts to have a detremental effect on the system, memcg, or cpuset. When
there is an abundance of memory available such that allocations need not
defragment or reclaim memory to be allocated, it can improve performance
to keep a memory arena from which to allocate from immediately without
calling the kernel.

Our version of malloc frees memory back to the kernel with
madvise(MADV_DONTNEED) which ends up zaping the mapped ptes. With
pressure events, we only need to do this when faced with memory pressure;
to keep our rss low, we require that thp's max_ptes_none tunable be set to
0; we don't want our applications to use any additional memory. This
requires splitting a hugepage anytime memory is free()'d back to the
kernel.

I'd like to use this as a hook into malloc() for applications that do not
have strict memory footprint requirements to be able to increase
performance by keeping around a memory arena from which to allocate.


\
 
 \ /
  Last update: 2012-11-20 19:41    [W:0.370 / U:0.528 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site