[v1] framework: fix getting single cpu information on freebsd

Message ID 20230601060125.13278-1-daxuex.gao@intel.com (mailing list archive)
State Accepted
Headers
Series [v1] framework: fix getting single cpu information on freebsd |

Checks

Context Check Description
ci/Intel-dts-format-test success Testing OK
ci/Intel-dts-pylama-test success Testing OK
ci/Intel-dts-suite-test success Testing OK

Commit Message

Gao, DaxueX June 1, 2023, 6:01 a.m. UTC
  Fix to get cpu information on freebsd,
when the machine has only one cpu,
It cannot match the number of cpus,cores,threads.
Such as:
<groups>
 <group level="1" cache-level="0">
  <cpu count="8" mask="ff,0,0,0">0, 1, 2, 3, 4, 5, 6, 7</cpu>
 </group>
</groups>

Signed-off-by: Daxue Gao <daxuex.gao@intel.com>
---
 framework/crb.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)
  

Comments

Tu, Lijuan June 7, 2023, 7:52 a.m. UTC | #1
On Thu,  1 Jun 2023 14:01:25 +0800, Daxue Gao <daxuex.gao@intel.com> wrote:
> Fix to get cpu information on freebsd,
> when the machine has only one cpu,
> It cannot match the number of cpus,cores,threads.
> Such as:
> <groups>
>  <group level="1" cache-level="0">
>   <cpu count="8" mask="ff,0,0,0">0, 1, 2, 3, 4, 5, 6, 7</cpu>
>  </group>
> </groups>
> 
> Signed-off-by: Daxue Gao <daxuex.gao@intel.com>

Acked-by: Lijuan Tu <lijuan.tu@intel.com>
Applied, thanks
  

Patch

diff --git a/framework/crb.py b/framework/crb.py
index 4ffee558..9e3b0a58 100644
--- a/framework/crb.py
+++ b/framework/crb.py
@@ -721,9 +721,21 @@  class Crb(object):
         socket_id = 0
 
         sockets = cpu_xml.findall(".//group[@level='2']")
+        if not sockets:
+            sockets = cpu_xml.findall(".//group[@level='1']")
         for socket in sockets:
             core_id = 0
             core_elements = socket.findall(".//children/group/cpu")
+            if not core_elements:
+                core_elements = socket.findall("./cpu")
+                for core in core_elements:
+                    cores = [int(x) for x in core.text.split(",")]
+                for core in cores:
+                    if self.crb["bypass core0"] and core == 0:
+                        continue
+                    self.cores.append(
+                        {"socket": socket_id, "core": core, "thread": core}
+                    )
             for core in core_elements:
                 threads = [int(x) for x in core.text.split(",")]
                 for thread in threads: