From f566f060875f58dba3d8b9e08b51ab5646ef0492 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Fri, 20 Aug 2010 16:39:25 -0700 Subject: [PATCH] --- yaml --- r: 209696 b: refs/heads/master c: 7798330ac8114c731cfab83e634c6ecedaa233d7 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/mm/mlock.c | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/[refs] b/[refs] index fb2acf2034bb..fc3cf9691b02 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 297c5eee372478fc32fec5fe8eed711eedb13f3d +refs/heads/master: 7798330ac8114c731cfab83e634c6ecedaa233d7 diff --git a/trunk/mm/mlock.c b/trunk/mm/mlock.c index 49e5e4cb8232..cbae7c5b9568 100644 --- a/trunk/mm/mlock.c +++ b/trunk/mm/mlock.c @@ -135,6 +135,19 @@ void munlock_vma_page(struct page *page) } } +/* Is the vma a continuation of the stack vma above it? */ +static inline int vma_stack_continue(struct vm_area_struct *vma, unsigned long addr) +{ + return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN); +} + +static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr) +{ + return (vma->vm_flags & VM_GROWSDOWN) && + (vma->vm_start == addr) && + !vma_stack_continue(vma->vm_prev, addr); +} + /** * __mlock_vma_pages_range() - mlock a range of pages in the vma. * @vma: target vma @@ -168,11 +181,9 @@ static long __mlock_vma_pages_range(struct vm_area_struct *vma, gup_flags |= FOLL_WRITE; /* We don't try to access the guard page of a stack vma */ - if (vma->vm_flags & VM_GROWSDOWN) { - if (start == vma->vm_start) { - start += PAGE_SIZE; - nr_pages--; - } + if (stack_guard_page(vma, start)) { + addr += PAGE_SIZE; + nr_pages--; } while (nr_pages > 0) {