summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Kacur <jkacur@redhat.com>2018-08-08 13:14:47 +0200
committerJiri Kastner <jkastner@redhat.com>2018-08-09 15:48:03 +0200
commit6eaaa8c829820e699dd9b96766b2ac3a51cc49f8 (patch)
tree9930ffa559f5c526bb6f35d35e4a9f7bc572e32f
parent60de2809d036c71472e500202d5e96849c5dd927 (diff)
downloadpython-linux-procfs-6eaaa8c829820e699dd9b96766b2ac3a51cc49f8.tar.gz
python-linux-procfs: Add some functions for affinity from tuna
Add cannot_set_affinity and cannot_set_thread_affinity from tuna Signed-off-by: John Kacur <jkacur@redhat.com> Signed-off-by: Jiri Kastner <jkastner@redhat.com>
-rwxr-xr-xprocfs/procfs.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/procfs/procfs.py b/procfs/procfs.py
index f97668c..c70fe2a 100755
--- a/procfs/procfs.py
+++ b/procfs/procfs.py
@@ -210,6 +210,22 @@ class pidstat:
return sflags
+def cannot_set_affinity(self, pid):
+ PF_NO_SETAFFINITY = 0x04000000
+ try:
+ return int(self.processes[pid]["stat"]["flags"]) & \
+ PF_NO_SETAFFINITY and True or False
+ except:
+ return True
+
+def cannot_set_thread_affinity(self, pid, tid):
+ PF_NO_SETAFFINITY = 0x04000000
+ try:
+ return int(self.processes[pid].threads[tid]["stat"]["flags"]) & \
+ PF_NO_SETAFFINITY and True or False
+ except:
+ return True
+
class pidstatus:
"""
Provides a dictionary to access the fields in the per process /proc/PID/status