Hugepages support
Grub hugepages configuration and mount point action.
Change-Id: I49b26871c325b95a7d3f264892a9e997b58765bc
Epic: PROD-8959
diff --git a/README.rst b/README.rst
index 026e2a2..348f950 100644
--- a/README.rst
+++ b/README.rst
@@ -217,6 +217,30 @@
cpu:
governor: performance
+Huge Pages
+~~~~~~~~~~~~
+
+Huge Pages give a performance boost to applications that intensively deal
+with memory allocation/deallocation by decreasing memory fragmentation.
+
+.. code-block:: yaml
+
+ linux:
+ system:
+ kernel:
+ hugepages:
+ small:
+ size: 2M
+ count: 107520
+ mount_point: /mnt/hugepages_2MB
+ mount: false/true # default false
+ large:
+ default: true # default automatically mounted
+ size: 1G
+ count: 210
+ mount_point: /mnt/hugepages_1GB
+
+Note: not recommended to use both pagesizes in concurrently.
Repositories
diff --git a/linux/files/grub_hugepages b/linux/files/grub_hugepages
new file mode 100644
index 0000000..509cc11
--- /dev/null
+++ b/linux/files/grub_hugepages
@@ -0,0 +1,2 @@
+{%- from "linux/map.jinja" import system with context %}
+GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT {%- for hugepages_type, hugepages in system.kernel.hugepages.iteritems() %}{%- if hugepages.get('default', False) %} default_hugepagesz={{ hugepages.size }} {%- endif %} hugepagesz={{ hugepages.size }} hugepages={{ hugepages.count }} {%- endfor %}"
diff --git a/linux/system/hugepages.sls b/linux/system/hugepages.sls
new file mode 100644
index 0000000..6e55449
--- /dev/null
+++ b/linux/system/hugepages.sls
@@ -0,0 +1,26 @@
+{%- from "linux/map.jinja" import system with context %}
+
+{%- if "pse" in grains.cpu_flags or "pdpe1gb" in grains.cpu_flags %}
+
+/etc/default/grub.d/90-hugepages.cfg:
+ file.managed:
+ - source: salt://linux/files/grub_hugepages
+ - template: jinja
+
+{%- for hugepages_type, hugepages in system.kernel.hugepages.iteritems() %}
+
+{%- if hugepages.get('mount', False) or hugepages.get('default', False) %}
+
+hugepages_mount_{{ hugepages_type }}:
+ mount.mounted:
+ - name: {{ hugepages.mount_point }}
+ - device: Hugetlbfs-kvm
+ - fstype: hugetlbfs
+ - mkmnt: true
+ - opts: mode=775,pagesize={{ hugepages.size }}
+
+{%- endif %}
+
+{%- endfor %}
+
+{%- endif %}
diff --git a/linux/system/init.sls b/linux/system/init.sls
index fabc37e..02dade0 100644
--- a/linux/system/init.sls
+++ b/linux/system/init.sls
@@ -11,6 +11,9 @@
{%- endif %}
{%- if system.kernel is defined %}
- linux.system.kernel
+{%- if system.kernel.hugepages is defined %}
+- linux.system.hugepages
+{%- endif %}
{%- endif %}
{%- if system.cpu is defined %}
- linux.system.cpu
@@ -65,4 +68,4 @@
{%- endif %}
{%- if system.config is defined %}
- linux.system.config
-{%- endif %}
+{%- endif %}
\ No newline at end of file
diff --git a/tests/pillar/system.sls b/tests/pillar/system.sls
index 9831d9f..152766d 100644
--- a/tests/pillar/system.sls
+++ b/tests/pillar/system.sls
@@ -19,6 +19,13 @@
term: xterm
prompt:
default: "test01.local$"
+ kernel:
+ hugepages:
+ large:
+ default: true
+ size: 1G
+ count: 210
+ mount_point: /mnt/hugepages_1GB
motd:
- warning: |
#!/bin/sh