Advertisement
Guest User

Untitled

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