From: Yong Liu <yong.liu@intel.com>
To: dts@dpdk.org
Subject: [dts] [PATCH V2] Optimize kill_all function
Date: Thu, 13 Aug 2015 11:16:30 +0800 [thread overview]
Message-ID: <1439435790-18581-1-git-send-email-yong.liu@intel.com> (raw)
From: Marvin Liu <yong.liu@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@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
reply other threads:[~2015-08-13 3:16 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1439435790-18581-1-git-send-email-yong.liu@intel.com \
--to=yong.liu@intel.com \
--cc=dts@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).