RIL-267 Adding cpu governor and kernel module opts (#101)
* RIL-267 Adding cpu governor and kernel module opts
* RIL-267 Adding cpu governor and kernel module opts
* RIL-267 Adding cpu governor and kernel module opts
diff --git a/README.rst b/README.rst
index a0a415a..e6d251b 100644
--- a/README.rst
+++ b/README.rst
@@ -317,6 +317,21 @@
- tp_smapi
- 8021q
+Configure or blacklist kernel modules with additional options to `/etc/modprobe.d` following example
+will add `/etc/modprobe.d/nf_conntrack.conf` file with line `options nf_conntrack hashsize=262144`:
+
+.. code-block:: yaml
+
+ linux:
+ system:
+ kernel:
+ module:
+ nf_conntrack:
+ option:
+ hashsize: 262144
+
+
+
Install specific kernel version and ensure all other kernel packages are
not present. Also install extra modules and headers for this kernel:
@@ -346,7 +361,7 @@
CPU
~~~
-Disable ondemand cpu mode service:
+Enable cpufreq governor for every cpu:
.. code-block:: yaml
diff --git a/linux/files/governor.conf.jinja b/linux/files/governor.conf.jinja
new file mode 100644
index 0000000..026a478
--- /dev/null
+++ b/linux/files/governor.conf.jinja
@@ -0,0 +1,3 @@
+{% for cpu_core in range(salt['grains.get']('num_cpus', 1)) %}
+devices/system/cpu/cpu{{ cpu_core }}/cpufreq/scaling_governor = {{ governor }}
+{% endfor %}
diff --git a/linux/files/modprobe.conf.jinja b/linux/files/modprobe.conf.jinja
new file mode 100644
index 0000000..2314bdb
--- /dev/null
+++ b/linux/files/modprobe.conf.jinja
@@ -0,0 +1,9 @@
+{% if module_content.get('blacklist', false) -%}
+blacklist {{ module_name }}
+{%- else -%}
+
+{%- for option, value in module_content.get('option', {}) | dictsort -%}
+options {{ module_name }} {{ option }}={{ value }}
+{%- endfor %}
+
+{%- endif %}
diff --git a/linux/system/cpu.sls b/linux/system/cpu.sls
index 658457d..c2821a1 100644
--- a/linux/system/cpu.sls
+++ b/linux/system/cpu.sls
@@ -1,9 +1,40 @@
{%- from "linux/map.jinja" import system with context %}
{%- if system.cpu.governor is defined %}
+linux_sysfs_package:
+ pkg.installed:
+ - pkgs:
+ - sysfsutils
+ - refresh: true
+
+/etc/sysfs.d:
+ file.directory:
+ - require:
+ - pkg: linux_sysfs_package
+
ondemand_service_disable:
service.dead:
- - name: ondemand
- - enable: false
+ - name: ondemand
+ - enable: false
-{%- endif %}
\ No newline at end of file
+/etc/sysfs.d/governor.conf:
+ file.managed:
+ - source: salt://linux/files/governor.conf.jinja
+ - template: jinja
+ - user: root
+ - group: root
+ - mode: 0644
+ - defaults:
+ governor: {{ system.cpu.governor }}
+
+{% for cpu_core in range(salt['grains.get']('num_cpus', 1)) %}
+
+governor_write_sysfs_cpu_core_{{ cpu_core }}:
+ module.run:
+ - name: sysfs.write
+ - key: devices/system/cpu/cpu{{ cpu_core }}/cpufreq/scaling_governor
+ - value: {{ system.cpu.governor }}
+
+{%- endfor %}
+
+{%- endif %}
diff --git a/linux/system/kernel.sls b/linux/system/kernel.sls
index 3c7619e..e3e6bd1 100644
--- a/linux/system/kernel.sls
+++ b/linux/system/kernel.sls
@@ -53,6 +53,21 @@
{%- endfor %}
+{%- for module_name, module_content in system.kernel.get('module', {}).iteritems() %}
+
+/etc/modprobe.d/{{ module_name }}.conf:
+ file.managed:
+ - user: root
+ - group: root
+ - mode: 0644
+ - template: jinja
+ - source: salt://linux/files/modprobe.conf.jinja
+ - defaults:
+ module_content: {{ module_content }}
+ module_name: {{ module_name }}
+
+{%- endfor %}
+
{%- for sysctl_name, sysctl_value in system.kernel.get('sysctl', {}).iteritems() %}
linux_kernel_{{ sysctl_name }}: