8268388: Update large pages information in Java manpage

Reviewed-by: tschatzl, lkorinth, stuefe
This commit is contained in:
Stefan Johansson 2021-06-10 05:32:56 +00:00
parent 2623b0bf39
commit ece3ae3cc4

View File

@ -1403,22 +1403,23 @@ comma.
.RE .RE
.TP .TP
.B \f[CB]\-XX:LargePageSizeInBytes=\f[R]\f[I]size\f[R] .B \f[CB]\-XX:LargePageSizeInBytes=\f[R]\f[I]size\f[R]
Sets the maximum size (in bytes) for large pages used for the Java heap. Sets the maximum large page size (in bytes) used by the JVM.
The \f[I]size\f[R] argument must be a power of 2 (2, 4, 8, 16, and so The \f[I]size\f[R] argument must be a valid page size supported by the
on). environment to have any effect.
Append the letter \f[CB]k\f[R] or \f[CB]K\f[R] to indicate kilobytes, Append the letter \f[CB]k\f[R] or \f[CB]K\f[R] to indicate kilobytes,
\f[CB]m\f[R] or \f[CB]M\f[R] to indicate megabytes, or \f[CB]g\f[R] or \f[CB]m\f[R] or \f[CB]M\f[R] to indicate megabytes, or \f[CB]g\f[R] or
\f[CB]G\f[R] to indicate gigabytes. \f[CB]G\f[R] to indicate gigabytes.
By default, the size is set to 0, meaning that the JVM chooses the size By default, the size is set to 0, meaning that the JVM will use the
for large pages automatically. default large page size for the environment as the maximum size for
large pages.
See \f[B]Large Pages\f[R]. See \f[B]Large Pages\f[R].
.RS .RS
.PP .PP
The following example describes how to set the large page size to 4 The following example describes how to set the large page size to 1
megabytes (MB): gigabyte (GB):
.RS .RS
.PP .PP
\f[CB]\-XX:LargePageSizeInBytes=4m\f[R] \f[CB]\-XX:LargePageSizeInBytes=1g\f[R]
.RE .RE
.RE .RE
.TP .TP
@ -5120,9 +5121,8 @@ larger memory range.
This results in less pressure on a TLB, and memory\-intensive This results in less pressure on a TLB, and memory\-intensive
applications may have better performance. applications may have better performance.
.PP .PP
However, large pages page memory can negatively affect system However, using large pages can negatively affect system performance.
performance. For example, when a large amount of memory is pinned by an application,
For example, when a large mount of memory is pinned by an application,
it may create a shortage of regular memory and cause excessive paging in it may create a shortage of regular memory and cause excessive paging in
other applications and slow down the entire system. other applications and slow down the entire system.
Also, a system that has been up for a long time could produce excessive Also, a system that has been up for a long time could produce excessive
@ -5133,74 +5133,84 @@ When this happens, either the OS or JVM reverts to using regular pages.
Linux and Windows support large pages. Linux and Windows support large pages.
.SS Large Pages Support for Linux .SS Large Pages Support for Linux
.PP .PP
The 2.6 kernel supports large pages. Linux supports large pages since version 2.6.
Some vendors have backported the code to their 2.4\-based releases. To check if your environment supports large pages, try the following:
To check if your system can support large page memory, try the
following:
.IP .IP
.nf .nf
\f[CB] \f[CB]
#\ cat\ /proc/meminfo\ |\ grep\ Huge #\ cat\ /proc/meminfo\ |\ grep\ Huge
HugePages_Total:\ 0 HugePages_Total:\ 0
HugePages_Free:\ 0 HugePages_Free:\ 0
\&...
Hugepagesize:\ 2048\ kB Hugepagesize:\ 2048\ kB
\f[R] \f[R]
.fi .fi
.PP .PP
If the output shows the three "Huge" variables, then your system can If the output contains items prefixed with "Huge", then your system
support large page memory but it needs to be configured. supports large pages.
If the command prints nothing, then your system doesn\[aq]t support The values may vary depending on environment.
large pages. The \f[CB]Hugepagesize\f[R] field shows the default large page size in
To configure the system to use large page memory, login as your environment, and the other fields show details for large pages of
\f[CB]root\f[R], and then follow these steps: this size.
.IP "1." 3 Newer kernels have support for multiple large page sizes.
If you\[aq]re using the option \f[CB]\-XX:+UseSHM\f[R] (instead of To list the supported page sizes, run this:
\f[CB]\-XX:+UseHugeTLBFS\f[R]), then increase the \f[CB]SHMMAX\f[R] value. .IP
It must be larger than the Java heap size. .nf
On a system with 4 GB of physical RAM (or less), the following makes all \f[CB]
the memory sharable: #\ ls\ /sys/kernel/mm/hugepages/
.RS 4 hugepages\-1048576kB\ \ hugepages\-2048kB
\f[R]
.fi
.PP
The above environment supports 2 MB and 1 GB large pages, but they need
to be configured so that the JVM can use them.
When using large pages and not enabling transparent huge pages (option
\f[CB]\-XX:+UseTransparentHugePages\f[R]), the number of large pages must
be pre\-allocated.
For example, to enable 8 GB of memory to be backed by 2 MB large pages,
login as \f[CB]root\f[R] and run:
.RS .RS
.PP .PP
\f[CB]#\ echo\ 4294967295\ >\ /proc/sys/kernel/shmmax\f[R] \f[CB]#\ echo\ 4096\ >\ /sys/kernel/mm/hugepages/hugepages\-2048kB/nr_hugepages\f[R]
.RE .RE
.RE .PP
.IP "2." 3 It is always recommended to check the value of \f[CB]nr_hugepages\f[R]
If you\[aq]re using the option \f[CB]\-XX:+UseSHM\f[R] or after the request to make sure the kernel was able to allocate the
\f[CB]\-XX:+UseHugeTLBFS\f[R], then specify the number of large pages. requested number of large pages.
In the following example, 3 GB of a 4 GB system are reserved for large .PP
pages (assuming a large page size of 2048kB, then 3 GB = 3 * 1024 MB = When using the option \f[CB]\-XX:+UseSHM\f[R] to enable large pages you
3072 MB = 3072 * 1024 kB = 3145728 kB and 3145728 kB / 2048 kB = 1536): also need to make sure the \f[CB]SHMMAX\f[R] parameter is configured to
.RS 4 allow large enough shared memory segments to be allocated.
To allow a maximum shared segment of 8 GB, login as \f[CB]root\f[R] and
run:
.RS .RS
.PP .PP
\f[CB]#\ echo\ 1536\ >\ /proc/sys/vm/nr_hugepages\f[R] \f[CB]#\ echo\ 8589934592\ >\ /proc/sys/kernel/shmmax\f[R]
.RE .RE
.PP
In some environments this is not needed since the default value is large
enough, but it is important to make sure the value is large enough to
fit the amount of memory intended to be backed by large pages.
.RS .RS
.PP .PP
\f[B]Note:\f[R] The values contained in \f[CB]/proc\f[R] resets after you \f[B]Note:\f[R] The values contained in \f[CB]/proc\f[R] and \f[CB]/sys\f[R]
reboot your system, so may want to set them in an initialization script reset after you reboot your system, so may want to set them in an
(for example, \f[CB]rc.local\f[R] or \f[CB]sysctl.conf\f[R]). initialization script (for example, \f[CB]rc.local\f[R] or
\f[CB]sysctl.conf\f[R]).
.RE .RE
.RE .PP
.IP \[bu] 2 If you configure the OS kernel parameters to enable use of large pages,
If you configure (or resize) the OS kernel parameters the Java processes may allocate large pages for the Java heap as well as
\f[CB]/proc/sys/kernel/shmmax\f[R] or \f[CB]/proc/sys/vm/nr_hugepages\f[R], other internal areas, for example:
Java processes may allocate large pages for areas in addition to the
Java heap.
These steps can allocate large pages for the following areas:
.RS 2
.IP \[bu] 2
Java heap
.IP \[bu] 2 .IP \[bu] 2
Code cache Code cache
.IP \[bu] 2 .IP \[bu] 2
The marking bitmap data structure for the parallel GC Marking bitmaps
.PP .PP
Consequently, if you configure the \f[CB]nr_hugepages\f[R] parameter to Consequently, if you configure the \f[CB]nr_hugepages\f[R] parameter to
the size of the Java heap, then the JVM can fail in allocating the code the size of the Java heap, then the JVM can still fail to allocate the
cache areas on large pages because these areas are quite large in size. heap using large pages because other areas such as the code cache might
.RE already have used some of the configured large pages.
.SS Large Pages Support for Windows .SS Large Pages Support for Windows
.PP .PP
To use large pages support on Windows, the administrator must first To use large pages support on Windows, the administrator must first