setting up Huge Pages with UEK R3 (kernel 3.8)

I came across a little hiccup when configuring huge pages on my oracle linux 6.5 playground machine with the latest unbreakable linux kernel. Part of the documentation and also this blog post by Tim Hall have a nifty script that outputs the setting one should tweak to set the nr_hugepages parameter correctly. Unfortunately, this script fails on the most recent version of the kernel shipped with Oracle Linux:

[root@linuxbox ~]# /usr/local/bin/hugepages_setting.sh 
Unrecognized kernel version 3.8. Exiting.

Fortunately, the fix is really easy. There is a wrapper script that will fake the output of uname back to 2.6 and the method of setting the parameter with vm.nr_hugepages has stayed the same.

[root@linuxbox ~]$ yum install uname26
[root@linuxbox ~]$ uname26 /usr/local/bin/hugepages_setting.sh 
Recommended setting: vm.nr_hugepages = 516

But even better than faking your way around this would be to modify the script and to accept 3.8 as a valid kernel version like this.

#!/bin/bash
#
# hugepages_settings.sh
#
# 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
NUM_PG=1
# 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]*"`
do
   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`
   fi
done
# 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' | '3.8' ) echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
      *) echo "Unrecognized kernel version $KERN. Exiting." ;;
esac

Btw: my test returned only 1 when I first ran it. After some advice by Frits Hoogland on twitter and a little study of this blog post by Tanel Poder it became quite obvious. I forgot to unset the MEMORY_TARGET parameter in my spfile and thus the shared memory was allocated in chunks visible in /dev/shm but not through ‘ipcs -m’. I do not trust AMM anyway, set MEMORY_MANAGEMENT to 0 and went on.

3 thoughts on “setting up Huge Pages with UEK R3 (kernel 3.8)

  1. Pingback: Linux Huge Pages in Oracle VM 3 | portrix systems

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>