e.ksh 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/bash
  2. #
  3. # hugepages_settings.sh
  4. #
  5. # Linux bash script to compute values for the
  6. # recommended HugePages/HugeTLB configuration
  7. #
  8. # Note: This script does calculation for all shared memory
  9. # segments available when the script is run, no matter it
  10. # is an Oracle RDBMS shared memory segment or not.
  11. # Check for the kernel version
  12. KERN=`uname -r | awk -F. '{ printf("%d.%d\n",$1,$2); }'`
  13. # Find out the HugePage size
  14. HPG_SZ=`grep Hugepagesize /proc/meminfo | awk {'print $2'}`
  15. # Start from 1 pages to be on the safe side and guarantee 1 free HugePage
  16. NUM_PG=1
  17. # Cumulative number of pages required to handle the running shared memory segments
  18. for SEG_BYTES in `ipcs -m | awk {'print $5'} | grep "[0-9][0-9]*"`
  19. do
  20. MIN_PG=`echo "$SEG_BYTES/($HPG_SZ*1024)" | bc -q`
  21. if [ $MIN_PG -gt 0 ]; then
  22. NUM_PG=`echo "$NUM_PG+$MIN_PG+1" | bc -q`
  23. fi
  24. done
  25. # Finish with results
  26. case $KERN in
  27. '2.4') HUGETLB_POOL=`echo "$NUM_PG*$HPG_SZ/1024" | bc -q`;
  28. echo "Recommended setting: vm.hugetlb_pool = $HUGETLB_POOL" ;;
  29. '2.6' | '3.8' | * ) echo "Recommended setting: vm.nr_hugepages = $NUM_PG" ;;
  30. *) echo "Unrecognized kernel version $KERN. Exiting." ;;
  31. esac
  32. # End