Skip to content

Commit 2d6c928

Browse files
Michal Hockotorvalds
authored andcommitted
mm: make vm_brk killable
Now that all the callers handle vm_brk failure we can change it wait for mmap_sem killable to help oom_reaper to not get blocked just because vm_brk gets blocked behind mmap_sem readers. Signed-off-by: Michal Hocko <mhocko@suse.com> Acked-by: Vlastimil Babka <vbabka@suse.cz> Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Andrea Arcangeli <aarcange@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent ecc2bc8 commit 2d6c928

2 files changed

Lines changed: 4 additions & 7 deletions

File tree

include/linux/mm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2011,7 +2011,7 @@ static inline void mm_populate(unsigned long addr, unsigned long len) {}
20112011
#endif
20122012

20132013
/* These take the mm semaphore themselves */
2014-
extern unsigned long vm_brk(unsigned long, unsigned long);
2014+
extern unsigned long __must_check vm_brk(unsigned long, unsigned long);
20152015
extern int vm_munmap(unsigned long, size_t);
20162016
extern unsigned long __must_check vm_mmap(struct file *, unsigned long,
20172017
unsigned long, unsigned long,

mm/mmap.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2712,12 +2712,9 @@ unsigned long vm_brk(unsigned long addr, unsigned long len)
27122712
unsigned long ret;
27132713
bool populate;
27142714

2715-
/*
2716-
* XXX not all users are chcecking the return value, convert
2717-
* to down_write_killable after they are able to cope with
2718-
* error
2719-
*/
2720-
down_write(&mm->mmap_sem);
2715+
if (down_write_killable(&mm->mmap_sem))
2716+
return -EINTR;
2717+
27212718
ret = do_brk(addr, len);
27222719
populate = ((mm->def_flags & VM_LOCKED) != 0);
27232720
up_write(&mm->mmap_sem);

0 commit comments

Comments
 (0)