1819804 Members
3162 Online
109607 Solutions
New Discussion юеВ

Kernel memory page size

 
SOLVED
Go to solution
Ralph Grothe
Honored Contributor

Kernel memory page size

I know this has been already many times asked and answered.
Unfortunately I at the moment cannot query the knowledge base, that's why I post this once again, sorry.

kmtune reports 4 KB page size.
The unistd.h header file has a deviating (to my understanding) preprocessor macro definition.
How come?

# uname -srv;getconf KERNEL_BITS
HP-UX B.11.00 U
64

# grep _SC_PAGE_SIZE /usr/include/sys/unistd.h
# define _SC_PAGE_SIZE 3001 /* PAGE_SIZE: Software page size */
# define _SC_PAGESIZE _SC_PAGE_SIZE

# kmtune -lq vps_pagesize
Parameter: vps_pagesize
Value: 4
Default: 4
Minimum: -
Module: -
Madness, thy name is system administration
11 REPLIES 11
Laurent Menase
Honored Contributor

Re: Kernel memory page size

Hi Ralph,

_SC_PAGE_SIZE is used to call sysconf to
get the current pagesize.

## more m.c
#include
main()
{
printf ("PAGESIZE= %ld\n",sysconf(_SC_PAGE_SIZE));
}
cc m.c -o m
./usr/ccs/bin/ld: (Warning) At least one PA 2.0 object file (m.o) was detected. The linked output may not run on a PA 1.x system.
# ./m
PAGESIZE= 4096
Laurent Menase
Honored Contributor

Re: Kernel memory page size

Hi Ralph,

_SC_PAGE_SIZE is used to call sysconf to
get the current pagesize.

## more m.c
#include
main()
{
printf ("PAGESIZE= %ld\n",sysconf(_SC_PAGE_SIZE));
}
cc m.c -o m
./usr/ccs/bin/ld: (Warning) At least one PA 2.0 object file (m.o) was detected. The linked output may not run on a PA 1.x system.
# ./m
PAGESIZE= 4096
# getconf PAGE_SIZE
4096
Ralph Grothe
Honored Contributor

Re: Kernel memory page size

Laurent,

yes, I should have found out myself by looking at the manpages of sysconf() syscall and the getconf utility.
However, now I've come accross yet another oddity, i.e. the _SC_CLK_TCK
I also compiled your little C snippet

$ cat psize.c
#include
int main(void) {
printf("Pagesize=%u\n", sysconf(_SC_PAGE_SIZE));
printf("Clockticks=%u\n", sysconf(_SC_CLK_TCK));
return(0);
}

$ ./psize
Pagesize=4096
Clockticks=100

However when I query the kernel I get another clock speed displayed

$ echo itick_per_usec/D|su root -c "adb /stand/vmunix /dev/kmem"
Password:
Error from elf64_getehdr(application core file)
Not an Elf file: No Elf header
itick_per_usec:
itick_per_usec: 440

Any explanation?

To my relieve I can even use Perl for those queries.

$ perl -MPOSIX -e 'printf"Clockticks=%u\n",POSIX::sysconf(POSIX::_SC_CLK_TCK)'
Clockticks=100
Madness, thy name is system administration
Laurent Menase
Honored Contributor
Solution

Re: Kernel memory page size

> $ ./psize
> Pagesize=4096
> Clockticks=100
This means 100 ticks/sec


However when I query the kernel I get another clock speed displayed

> $ echo itick_per_usec/D| adb /stand/vmunix /dev/kmem
> itick_per_usec:
> itick_per_usec: 440

> Any explanation?
iticks_per_usec is the number of cpu cycles per microsec.
This means you have a 440Mhz cpu.
iticks are relative to itimer - register CR16 of the cpu-

To my relieve I can even use Perl for those queries.

$ perl -MPOSIX -e 'printf"Clockticks=%u\n",POSIX::sysconf(POSIX::_SC_CLK_TCK)'
Clockticks=100
Don Morris_1
Honored Contributor

Re: Kernel memory page size

Besides the _SC_PAGE_SIZE stuff (answered above) -- you're also misinterpreting the vps_pagesize tunable. That does not control the base page size of the system (which is what _SC_PAGE_SIZE reports). The underlying base page size is entirely a combination of what the architecture supports and the kernel is written to use.

What vps_pagesize controls is (with vps_ceiling) the hint to the kernel of what virtual page size (aka large page) to give to users by default. If you use chatr on the binary to specify a page size, it is ignored.. otherwise the kernel makes a "best guess" based on the system configuration and the object size being created. That guess is then checked to be between (inclusively) vps_pagesize [minimum] and vps_ceiling [maximum] and adjusted appropriately.

So if you want your applications to get 16k large pages as much as possible by default -- you'd adjust vps_pagesize to 16. If you know that you'll be setting up large but sparse virtual ranges you might want to lower vps_ceiling to make sure the kernel doesn't give you 64k (or 16k or whatnot) pages when you touch that one byte.

There are man pages for both tunables on docs.hp.com (look under 11.11 -- that information should be relevant for 11.0).
For later releases, the man pages are on the system.
Ted Buis
Honored Contributor

Re: Kernel memory page size

You do NOT want to alter the kernel page size. You can play with performance optimized page sizes for applications, particularily if you create them yourself.
Mom 6
Ralph Grothe
Honored Contributor

Re: Kernel memory page size

Ted,

rest assured, not remotely.

I was just curious to learn more about HP-UX Kernel innards.
I've even come accross an excellent book from HP (whose title I cannot recall) about the nitty gritty of kernel structs, memory management etc.
Unfortunately, there's always too little time to read (and hopefully remember) these more in-depth coverages on HP-UX
(Besides we're also blessed (or cursed) with other HW platforms and server OS's such as AIX, Solaris, Linux, OpenBSD etc., of which there is also so much to get known)
Madness, thy name is system administration
Ted Buis
Honored Contributor

Re: Kernel memory page size

The best book I have seen is "hp-ux 11i internals" by Chris Cooper and Chris Moore. I also like the book by Robert Sauers on "hp-ux 11i tuning and performance" which is now the second edition. I really think that the kernel page size should be expanded, but I will wait patiently for the hp kernel experts to do that work.
Mom 6
Ralph Grothe
Honored Contributor

Re: Kernel memory page size

Ted,

that was the title I had a chance to browse through in our local technical bookstore.
But because of lack of time (the content at least looked quite demanding) I couldn't decide on buying a copy.
Madness, thy name is system administration
Ted Buis
Honored Contributor

Re: Kernel memory page size

Ralph,

To be honest, much of it is beyond my real level of interest and ability to absorb. However, I have gained some insights that I didn't have before, and when I finish it I expect to have a few more. It has a good discussion on the paging system, including psuedo-swap. According to the book, vps_pagesize is the parameter that sets the base page size and defaults to 4Kbytes. It seems that the vps_cieling and vps_chatr_cieling are more reasonable to change. "The page size is determined by a 5-bit field in the htbl/pdir entry. The current implemented sizes range from 1 to 256K page frames (each progressively larger size is 4X the previous small size)."
Mom 6
Muthukumar_5
Honored Contributor

Re: Kernel memory page size

We can get it with dmesg too as,

dmesg | grep -iE 'Memory|Physical'

It will give informations about Physical page size and memory there.

It is updated there too.
Easy to suggest when don't know about the problem!