Travis Vitek wrote:
Martin Sebor wrote:
Travis Vitek wrote:
It looks like th original code was stepping 16MB (1024 * 1024 bytes)
past bad_address. That should be well more than one page away. BTW, you
can determine the kernel page size on most *nix platforms with sysconf
(_SC_PAGESIZE).
Travis
Of course the kernel memory page size from sysconf() isn't the same as
the virtual memory page size that you are talking about. :)
It's not? I thought both sysconf(_SC_PAGESIZE) and getpagesize()
returned the size of the virtual page. I.e., whatever smallest
unit mmap() allocates.
Martin
I think I may have worded my response poorly. The page size, as returned by
sysconf(), is does not appear to be the same as the page size that is set by
chatr.
$ cat u.cpp && aCC u.cpp
#include <stdio.h>
#include <unistd.h>
int main ()
{
printf ("%ld\n", sysconf (_SC_PAGE_SIZE));
return 0;
}
$ chatr +pd 1M +pi 1M a.out > /dev/null && ./a.out
4096
$ chatr +pd 4M +pi 4M a.out > /dev/null && ./a.out
4096
A quick glance at the documentation for chatr says that +pd and +pi are only
hints for the virtual memory page size, so that may explain the difference
I'm seeing. Interestingly, you can set values for up to 4GB.
Yes, on Itanium 2 it can be up to 4GB.
I've re-read section 8.2.1 Variable Page Sizes of HP-UX 11i Tuning
and Performance to better understand how this works. Apparently,
the chatr command above just raises the ceiling for the text and
data page sizes for the executable. When the program allocates
memory (e.g., by calling mmap()) the OS will attempt to allocate
it in multiples of pages of at most that size. The smallest page
the HP-UX kernel can allocate is still 4KB, and that's the value
returned by the sysconf call.
Interesting stuff!
Martin
Travis