Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1682495
  • 博文数量: 311
  • 博客积分: 6853
  • 博客等级: 准将
  • 技术积分: 2838
  • 用 户 组: 普通用户
  • 注册时间: 2005-08-04 16:41











分类: Oracle

2013-03-22 17:21:46

G.2 Overview of HugePages

HugePages is a feature integrated into the Linux kernel 2.6. It is a method to have larger page size that is useful for working with very large memory. HugePages is useful for both 32-bit and 64-bit configurations. HugePage sizes vary from 2MB to 256MB, depending on the kernel version and the hardware architecture. For Oracle Databases, using HugePages reduces the operating system maintenance of page states, and increases Translation Lookaside Buffer (TLB) hit ratio.

This section includes the following topics:

G.2.1 Tuning SGA With HugePages

Without HugePages, the operating system keeps each 4KB of memory as a page, and when it is allocated to the SGA, then the lifecycle of that page (dirty, free, mapped to a process, and so on) is kept up to date by the operating system kernel.

With HugePages, the operating system page table (virtual memory to physical memory mapping) is smaller, since each page table entry is pointing to pages from 2MB to 256MB. Also, the kernel has fewer pages whose lifecyle must be monitored.


2MB size of HugePages is available with Linux x86-64, Linux x86, and IBM: Linux on System z.

The following are the advantages of using HugePages:

  • Increased performance through increased TLB hits.

  • Pages are locked in memory and are never swapped out which guarantees that shared memory like SGA remains in RAM.

  • Contiguous pages are preallocated and cannot be used for anything else but for System V shared memory (for example, SGA)

  • Less bookkeeping work for the kernel for that part of virtual memory due to larger page sizes

G.2.2 Configuring HugePages on Red Hat Enterprise Linux and Oracle Linux

Complete the following steps to configure HugePages on the computer:

  1. Edit the memlock setting in the /etc/security/limits.conf file. The memlock setting is specified in KB and set slightly lesser than the installed RAM. For example, if you have 64GB RAM installed, add the following entries to increase the max locked memory limit:

    *   soft   memlock    60397977
    *   hard   memlock    60397977

    You can also set the memlock value higher than your SGA requirements.

  2. Login as the oracle user again and run the ulimit -l command to verify the new memlock setting:

    $ ulimit -l
  3. Run the following command to display the value of Hugepagesize variable:

    $ grep Hugepagesize /proc/meminfo
  4. Complete the following procedure to create a script that computes recommended values for hugepages configuration for the current shared memory segments:


    Following is an example that may require modifications.
    1. Create a text file named

    2. Add the following content in the file:

      # Linux bash script to compute values for the
      # recommended HugePages/HugeTLB configuration
      # Note: This script does calculation for all shared memory
      # segments available when the script is run, no matter it
      # is an Oracle RDBMS shared memory segment or not.
      # Check for the kernel version
      KERN=`uname -r | awk -F. '{ printf("%d.%d\n",$1,$2); }'`
      # Find out the HugePage size
      HPG_SZ=`grep Hugepagesize /proc/meminfo | awk {'print $2'}`
      # Start from 1 pages to be on the safe side and guarantee 1 free HugePage
      # Cumulative number of pages required to handle the running shared memory segments
      for SEG_BYTES in `ipcs -m | awk {'print $5'} | grep "[0-9][0-9]*"`
         MIN_PG=`echo "$SEG_BYTES/($HPG_SZ*1024)" | bc -q`
         if [ $MIN_PG -gt 0 ]; then
            NUM_PG=`echo "$NUM_PG+$MIN_PG+1" | bc -q`
      # Finish with results
      case $KERN in
         '2.4') HUGETLB_POOL=`echo "$NUM_PG*$HPG_SZ/1024" | bc -q`;
                echo "Recommended setting: vm.hugetlb_pool = $HUGETLB_POOL" ;;
         '2.6') echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
          *) echo "Unrecognized kernel version $KERN. Exiting." ;;
      # End
    3. Run the following command to change the permission of the file:

      $ chmod +x
  5. Run the script to compute the values for hugepages configuration:

    $ ./
  6. Set the following kernel parameter:

    # sysctl -w vm.nr_hugepages=value_displayed_in_step_5 
  7. To make the value of the parameter available for every time you restart the computer, edit the /etc/sysctl.conf file and add the following entry:

  8. Restart the server.


    To check the available hugepages, run the following command:
    $ grep Huge /proc/meminfo

G.2.3 Restrictions for HugePages Configurations

Following are the limitations of using HugePages:

  • The Automatic Memory Management (AMM) and HugePages are not compatible. With AMM the entire SGA memory is allocated by creating files under/dev/shm. When Oracle Database allocates SGA that way HugePages are not reserved. You must disable AMM on Oracle Database to use HugePages.

  • If you are using VLM in a 32-bit environment, then you cannot use HugePages for the Database Buffer cache. HugePages can be used for other parts of SGA like shared_pool, large_pool, and so on. Memory allocation for VLM (buffer cache) is done using shared memory file systems (ramfs/tmpfs/shmfs). HugePages does not get reserved or used by the memory file systems.

  • HugePages are not subject to allocation or release after system startup, unless a system administrator changes the HugePages configuration by modifying the number of pages available, or the pool size. If the space required is not reserved in memory during system startup, then HugePages allocation fails.

阅读(1272) | 评论(0) | 转发(0) |

登录 注册