[dts] [PATCH V2] Optimize kill_all function
Yong Liu
yong.liu at intel.com
Thu Aug 13 05:16:30 CEST 2015
From: Marvin Liu <yong.liu at intel.com>
Before call system kill, strip all dpdk process pids. After kill all, check
there's no dpdk process alive and clean host session buffer.
Signed-off-by: Marvin Liu <yong.liu at intel.com>
diff --git a/framework/crb.py b/framework/crb.py
index dd18207..c10f791 100644
--- a/framework/crb.py
+++ b/framework/crb.py
@@ -331,25 +331,27 @@ class Crb(object):
"""
Kill all dpdk applications on CRB.
"""
- cmd = "for i in `lsof /var/run/.rte_config /var/run/dpdk_config \
- | awk '/config/ {print $2}'` ; do kill -9 $i; done"
- self.alt_session.session.send_expect(cmd, "# ", 10)
- proce_cmd = "lsof /var/run/.rte_config /var/run/dpdk_config | awk '{print $2}'"
- hugepage_cmd = "lsof /var/run/.rte_hugepage_info | awk {print $2}"
- out = self.alt_session.session.send_expect(proce_cmd, "# ",10)
- if "PID" in out:
- self.logger.warning("There are some dpdk process not killed")
- self.logger.warning("**************************************")
- self.logger.warning(out)
- self.logger.warning("**************************************")
-
- out = self.alt_session.session.send_expect(hugepage_cmd, "# ",10)
- if "PID" in out:
+ pids = []
+ pid_reg = r'p(\d+)'
+ cmd = 'lsof -Fp /var/run/.rte_config'
+ out = self.alt_session.session.send_expect(cmd, "# ", 10)
+ if len(out):
+ lines = out.split('\r\n')
+ for line in lines:
+ m = re.match(pid_reg, line)
+ if m:
+ pids.append(m.group(1))
+ for pid in pids:
+ self.alt_session.session.send_expect('kill -9 %s' % pid, '# ')
+ self.get_session_output(timeout=2)
+
+ cmd = 'lsof -Fp /var/run/.rte_hugepage_info'
+ out = self.alt_session.session.send_expect(cmd, "# ", 10)
+ if len(out):
self.logger.warning("There are some dpdk process not free hugepage")
self.logger.warning("**************************************")
self.logger.warning(out)
self.logger.warning("**************************************")
- time.sleep(.7)
def close(self):
"""
--
1.9.3
More information about the dts
mailing list