Re: [PATCH] Don't mlock guardpage if the stack is growing up

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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;
}

[Index of Archives]     [Linux Kernel]     [Sparc Linux]     [DCCP]     [Linux ARM]     [Yosemite News]     [Linux SCSI]     [Linux x86_64]     [Linux for Ham Radio]

  Powered by Linux