Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752972Ab1EIP6U (ORCPT ); Mon, 9 May 2011 11:58:20 -0400 Received: from smtp1.linux-foundation.org ([140.211.169.13]:40022 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752319Ab1EIP6T (ORCPT ); Mon, 9 May 2011 11:58:19 -0400 MIME-Version: 1.0 In-Reply-To: References: From: Linus Torvalds Date: Mon, 9 May 2011 08:57:56 -0700 Message-ID: Subject: Re: [PATCH] Don't mlock guardpage if the stack is growing up To: Mikulas Patocka Cc: Hugh Dickins , linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org, Michel Lespinasse , Oleg Nesterov Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2230 Lines: 62 On Mon, May 9, 2011 at 4:12 AM, Mikulas Patocka wrote: > > See ./lib/mm/memlock.c in LVM2. It reads /proc/self/maps, parses the file > and locks each map with mlock, except for glibc locale file. Hmm. One thing that strikes me is this problem also implies that the /proc/self/maps file is wrong for the GROWSUP case, isn't it? So I think we should not just apply your lock fix, but then *also* apply something like this: diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 2e7addfd9803..080980880c7f 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -214,7 +214,7 @@ static void show_map_vma(struct seq_file *m, struct vm_area_struct *vma) int flags = vma->vm_flags; unsigned long ino = 0; unsigned long long pgoff = 0; - unsigned long start; + unsigned long start, end; dev_t dev = 0; int len; @@ -227,13 +227,16 @@ static void show_map_vma(struct seq_file *m, struct vm_area_struct *vma) /* We don't show the stack guard page in /proc/maps */ start = vma->vm_start; - if (vma->vm_flags & VM_GROWSDOWN) - if (!vma_stack_continue(vma->vm_prev, vma->vm_start)) - start += PAGE_SIZE; + if (stack_guard_page_growsdown(vma, start)) + start += PAGE_SIZE; + end = vma->vm_end; + if (stack_guard_page_growsup(vma, end)) + end -= PAGE_SIZE; + seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n", start, - vma->vm_end, + end, flags & VM_READ ? 'r' : '-', flags & VM_WRITE ? 'w' : '-', flags & VM_EXEC ? 'x' : '-', NOTE! The above actually assumes that your "stack_guard_page_growsup()" has been changed to actually take the "next page" value, which I think makes more sense (ie it's the "end of stack", the same way "stack_guard_page_growsdown()" address is). Hmm? I don't have any growsup machine to test with, can you do that? Linus -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/