This module provides functions that are related to IRQ mangling.
The function pin_dev_irqs in the module can be used to pin IRQs assigned
to a device to a specific CPU.
It takes three arguments, HostAPI object, InterfaceAPI object and cpu number.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
---
lnst/RecipeCommon/IRQ.py | 33 +++++++++++++++++++++++++++++++++
lnst/RecipeCommon/__init__.py | 0
setup.py | 3 ++-
3 files changed, 35 insertions(+), 1 deletion(-)
create mode 100644 lnst/RecipeCommon/IRQ.py
create mode 100644 lnst/RecipeCommon/__init__.py
diff --git a/lnst/RecipeCommon/IRQ.py b/lnst/RecipeCommon/IRQ.py
new file mode 100644
index 0000000..441bbc8
--- /dev/null
+++ b/lnst/RecipeCommon/IRQ.py
@@ -0,0 +1,33 @@
+"""
+This module defines the functions for IRQ tuning that can be imported
+directly into LNST Python tasks.
+
+Copyright 2015 Red Hat, Inc.
+Licensed under the GNU General Public License, version 2 as
+published by the Free Software Foundation; see COPYING for details.
+"""
+
+__author__ = """
+jtluka(a)redhat.com (Jan Tluka)
+"""
+
+
+'''
+Pins all device IRQs to specified cpu on machine.
+
+machine: HostAPI object
+device: InterfaceAPI object
+cpu: integer
+'''
+def pin_dev_irqs(machine, device, cpu):
+ pi = machine.run("grep %s /proc/interrupts | cut -f1 -d: | sed 's/
//'"
+ % device.get_devname(), save_output=True)
+ res = pi.get_result()
+ intrs = res["res_data"]["stdout"]
+ for intr in intrs.split('\n'):
+ try:
+ int(intr)
+ except:
+ continue
+ machine.config("/proc/irq/%s/smp_affinity_list" % intr.strip(), cpu)
+
diff --git a/lnst/RecipeCommon/__init__.py b/lnst/RecipeCommon/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/setup.py b/setup.py
index 43925dd..628ac1f 100755
--- a/setup.py
+++ b/setup.py
@@ -101,7 +101,8 @@ For detailed description of the architecture of LNST please refer to
project website <
https://fedorahosted.org/lnst>.
"""
-PACKAGES = ["lnst", "lnst.Common", "lnst.Controller",
"lnst.Slave"]
+PACKAGES = ["lnst", "lnst.Common", "lnst.Controller",
"lnst.Slave",
+ "lnst.RecipeCommon" ]
SCRIPTS = ["lnst-ctl", "lnst-slave", "lnst-pool-wizard"]
RECIPE_FILES = []
--
2.4.3