mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 19:21:31 -04:00
mm, madvise: fail with ENOMEM when splitting vma will hit max_map_count
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/[email protected] Signed-off-by: David Rientjes <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Jerome Marchand <[email protected]> Cc: "Kirill A. Shutemov" <[email protected]> Cc: Michael Kerrisk <[email protected]> Cc: Anshuman Khandual <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
712c604dcd
commit
def5efe037
5 changed files with 56 additions and 17 deletions
|
|
@ -2499,11 +2499,11 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
|
|||
}
|
||||
|
||||
/*
|
||||
* __split_vma() bypasses sysctl_max_map_count checking. We use this on the
|
||||
* munmap path where it doesn't make sense to fail.
|
||||
* __split_vma() bypasses sysctl_max_map_count checking. We use this where it
|
||||
* has already been checked or doesn't make sense to fail.
|
||||
*/
|
||||
static int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
|
||||
unsigned long addr, int new_below)
|
||||
int __split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
|
||||
unsigned long addr, int new_below)
|
||||
{
|
||||
struct vm_area_struct *new;
|
||||
int err;
|
||||
|
|
|
|||
Loading…
Reference in a new issue