Re: [PATCH] Don't mlock guardpage if the stack is growing up
From: Linus Torvalds
Date: Mon May 09 2011 - 18:32:43 EST
On Mon, May 9, 2011 at 3:19 PM, James Bottomley
<James.Bottomley@xxxxxxxxxxxxxxxxxxxxx> wrote:
>
> So I can test the patch, if you tell me how. I don't use lvm2, so it
> would have to be a simple test case.
Something like the attached. Run it as root (it needs root just for
the mlockall), and see whether the stack it shows changes.
With current kernels, I think the stack expands by one page during the
mlockall (for STACK_GROWSUP), with the patch it shouldn't.
Linus
#include <stdio.h>
#include <string.h>
#include <sys/mman.h>
static void show_stack(void)
{
FILE *map;
char buf[1000];
map = fopen("/proc/self/maps", "r");
if (!map)
return;
while (fgets(buf, 1000, map)) {
if (!strstr(buf, "[stack]"))
continue;
fputs(buf, stdout);
}
fclose(map);
}
int main(void)
{
show_stack();
mlockall(MCL_CURRENT | MCL_FUTURE);
show_stack();
return 0;
}