• David Rientjes's avatar
    mm, madvise: fail with ENOMEM when splitting vma will hit max_map_count · def5efe0
    David Rientjes authored
    If madvise(2) advice will result in the underlying vma being split and
    the number of areas mapped by the process will exceed
    /proc/sys/vm/max_map_count as a result, return ENOMEM instead of EAGAIN.
    
    EAGAIN is returned by madvise(2) when a kernel resource, such as slab,
    is temporarily unavailable.  It indicates that userspace should retry
    the advice in the near future.  This is important for advice such as
    MADV_DONTNEED which is often used by malloc implementations to free
    memory back to the system: we really do want to free memory back when
    madvise(2) returns EAGAIN because slab allocations (for vmas, anon_vmas,
    or mempolicies) cannot be allocated.
    
    Encountering /proc/sys/vm/max_map_count is not a temporary failure,
    however, so return ENOMEM to indicate this is a more serious issue.  A
    followup patch to the man page will specify this behavior.
    
    Link: http://lkml.kernel.org/r/alpine.DEB.2.10.1701241431120.42507@chino.kir.corp.google.comSigned-off-by: default avatarDavid Rientjes <rientjes@google.com>
    Cc: Jonathan Corbet <corbet@lwn.net>
    Cc: Johannes Weiner <hannes@cmpxchg.org>
    Cc: Jerome Marchand <jmarchan@redhat.com>
    Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
    Cc: Michael Kerrisk <mtk.manpages@googlemail.com>
    Cc: Anshuman Khandual <khandual@linux.vnet.ibm.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    def5efe0
vm.txt 32.1 KB