test suite reviews and discussions
 help / color / mirror / Atom feed
From: <pvukkisala@marvell.com>
To: <dts@dpdk.org>
Cc: <avijay@marvell.com>, <fmasood@marvell.com>,
	Phanendra Vukkisala <pvukkisala@marvell.com>
Subject: [dts] [PATCH] crb.py: Support getting cores list from last core
Date: Thu, 30 May 2019 16:17:18 +0530	[thread overview]
Message-ID: <1559213238-21721-1-git-send-email-pvukkisala@marvell.com> (raw)

From: Phanendra Vukkisala <pvukkisala@marvell.com>

Signed-off-by: Phanendra Vukkisala <pvukkisala@marvell.com>
---
 framework/crb.py |   37 +++++++++++++++++++++++++++++--------
 1 file changed, 29 insertions(+), 8 deletions(-)

diff --git a/framework/crb.py b/framework/crb.py
index 0a2fa80..6e5f56f 100644
--- a/framework/crb.py
+++ b/framework/crb.py
@@ -630,7 +630,7 @@ class Crb(object):
         # return thread list
         return map(str, thread_list)
 
-    def get_core_list(self, config, socket=-1):
+    def get_core_list(self, config, socket=-1, from_last = False):
         """
         Get lcore array according to the core config like "all", "1S/1C/1T".
         We can specify the physical CPU socket by the "socket" parameter.
@@ -663,7 +663,10 @@ class Crb(object):
                     if (int(n['socket']) == socket):
                         sockList = [int(n['socket'])]
 
-            sockList = list(sockList)[:nr_sockets]
+            if from_last:
+                sockList = list(sockList)[-nr_sockets:]
+            else:
+                sockList = list(sockList)[:nr_sockets]
             partial_cores = [n for n in partial_cores if int(n['socket'])
                              in sockList]
             core_list = set([int(n['core']) for n in partial_cores])
@@ -676,7 +679,10 @@ class Crb(object):
             for sock in sockList:
                 core_list = set([int(
                     n['core']) for n in partial_cores if int(n['socket']) == sock])
-                core_list = list(core_list)[:nr_cores]
+                if from_last:
+                    core_list = list(core_list)[-nr_cores:]
+                else:
+                    core_list = list(core_list)[:nr_cores]
                 temp.extend(core_list)
 
             core_list = temp
@@ -686,7 +692,10 @@ class Crb(object):
                 partial_cores = self.cores
                 sockList = set([int(n['socket']) for n in partial_cores])
 
-                sockList = list(sockList)[:nr_sockets]
+                if from_last:
+                    sockList = list(sockList)[-nr_sockets:]
+                else:
+                    sockList = list(sockList)[:nr_sockets]
                 partial_cores = [n for n in partial_cores if int(
                     n['socket']) in sockList]
 
@@ -694,7 +703,10 @@ class Crb(object):
                 for sock in sockList:
                     core_list = list([int(n['thread']) for n in partial_cores if int(
                         n['socket']) == sock])
-                    core_list = core_list[:nr_cores]
+                    if from_last:
+                        core_list = core_list[-nr_cores:]
+                    else:
+                        core_list = core_list[:nr_cores]
                     temp.extend(core_list)
 
                 core_list = temp
@@ -716,23 +728,32 @@ class Crb(object):
                 for core in coreList_aux:
                     thread_list = list([int(n['thread']) for n in partial_cores if (
                         (int(n['core']) == core) and (int(n['socket']) == sock))])
-                    thread_list = thread_list[:nr_threads]
+                    if from_last:
+                        thread_list = thread_list[-nr_threads:]
+                    else:
+                        thread_list = thread_list[:nr_threads]
                     temp.extend(thread_list)
                     thread_list = temp
                 i += 1
             return map(str, thread_list)
 
-    def get_lcore_id(self, config):
+    def get_lcore_id(self, config, inverse = False):
         """
         Get lcore id of specified core by config "C{socket.core.thread}"
         """
 
-        m = re.match("C{([01]).(\d).([01])}", config)
+        m = re.match("C{([01]).(\d+).([01])}", config)
 
         if m:
             sockid = m.group(1)
             coreid = int(m.group(2))
+            if inverse:
+                coreid += 1
+                coreid = -coreid
             threadid = int(m.group(3))
+            if inverse:
+                threadid += 1
+                threadid = -threadid
 
             perSocklCs = [_ for _ in self.cores if _['socket'] == sockid]
             coreNum = perSocklCs[coreid]['core']
-- 
1.7.9.5


             reply	other threads:[~2019-05-30 10:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-30 10:47 pvukkisala [this message]
2019-06-05  2:18 ` Tu, Lijuan

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=1559213238-21721-1-git-send-email-pvukkisala@marvell.com \
    --to=pvukkisala@marvell.com \
    --cc=avijay@marvell.com \
    --cc=dts@dpdk.org \
    --cc=fmasood@marvell.com \
    /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).