Skip to content

Instantly share code, notes, and snippets.

/hugetlbfs_pg.md Secret

Created January 23, 2018 19:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/c8106ba77d50f87a57cbd875bbe84fbb to your computer and use it in GitHub Desktop.
Save anonymous/c8106ba77d50f87a57cbd875bbe84fbb to your computer and use it in GitHub Desktop.
Huge pages postgres in Enforcing
[postgres/dbadm_r/SystemLow-SystemHigh@mls:~]$ grep ^VmPeak /proc/`head -1 $PGDATA/postmaster.pid`/status
VmPeak:	  232612 kB

[root/sysadm_r/SystemLow-SystemHigh@mls:~]# grep ^Hugepagesize /proc/meminfo
Hugepagesize:       2048 kB

[root/sysadm_r/SystemLow-SystemHigh@mls:~]# echo $(( 232612 / 2048 ))
113

[root/sysadm_r/SystemLow-SystemHigh@mls:~]# sysctl -w vm.nr_hugepages=200
vm.nr_hugepages = 200

[postgres/dbadm_r/SystemLow-SystemHigh@mls:~]$ grep ^shared_buffers /var/lib/pgsql/10/data/postgresql.conf
shared_buffers = 4MB			# min 128kB

[postgres/dbadm_r/SystemLow-SystemHigh@mls:~]$ grep ^huge_pages /var/lib/pgsql/10/data/postgresql.conf
huge_pages = on

[root/sysadm_r/SystemLow-SystemHigh@mls:~]# getenforce
Enforcing

[root/sysadm_r/SystemLow-SystemHigh@mls:~]# grep Huge /proc/meminfo
AnonHugePages:     12288 kB
HugePages_Total:     200
HugePages_Free:      196
HugePages_Rsvd:        2
HugePages_Surp:        0
Hugepagesize:       2048 kB
@mpalmi
Copy link

mpalmi commented Jan 23, 2018

The following indicates that open has been removed from my system:

[root/sysadm_r/SystemLow-SystemHigh@mls:~]# sesearch -A -s postgresql_t -t hugetlbfs_t -c file
Found 1 semantic av rules:
   allow postgresql_t hugetlbfs_t : file { ioctl read write getattr } ; 

@mpalmi
Copy link

mpalmi commented Jan 23, 2018

For reference, I followed these instructions: https://www.postgresql.org/docs/10/static/kernel-resources.html#LINUX-HUGE-PAGES for the configuration above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment