diff mbox series

[3/3] rteval: misc.py: Sort the list of cpus returned by online_cpus()

Message ID 20210902092452.726905-4-punitagrawal@gmail.com
State New
Headers show
Series [1/3] rteval: cyclictest.py Enable logging cyclictest output | expand

Commit Message

Punit Agrawal Sept. 2, 2021, 9:24 a.m. UTC
From: Punit Agrawal <punit1.agrawal@toshiba.co.jp>

online_cpus() returns a list of online cpus in arbitrary order. e.g.,
on a hexacore system it returns -

    ['5', '3', '1', '4', '2', '0']

Generally this wouldn't be a problem but the cyclictest.py module
matches the unsorted list with the latencies output by "cyclictest"
which are ordered by core number. This leads to incorrect reporting of
per-core latencies in the final report generated by rteval. The issue
was noticed when comparing the rteval report with cyclictest logs
(enabled by a recent change).

Fix the inconsistency in core numbering by sorting the list of cpus
returned by online_cpus(). As the cpus are represented as a string,
sort with the integer key to avoid issues on systems with large number
of cores.

Signed-off-by: Punit Agrawal <punitagrawal@gmail.com>
---
 rteval/misc.py | 1 +
 1 file changed, 1 insertion(+)

Comments

John Kacur Sept. 12, 2021, 3:39 p.m. UTC | #1
On Thu, 2 Sep 2021, Punit Agrawal wrote:

> From: Punit Agrawal <punit1.agrawal@toshiba.co.jp>

> 

> online_cpus() returns a list of online cpus in arbitrary order. e.g.,

> on a hexacore system it returns -

> 

>     ['5', '3', '1', '4', '2', '0']

> 

> Generally this wouldn't be a problem but the cyclictest.py module

> matches the unsorted list with the latencies output by "cyclictest"

> which are ordered by core number. This leads to incorrect reporting of

> per-core latencies in the final report generated by rteval. The issue

> was noticed when comparing the rteval report with cyclictest logs

> (enabled by a recent change).

> 

> Fix the inconsistency in core numbering by sorting the list of cpus

> returned by online_cpus(). As the cpus are represented as a string,

> sort with the integer key to avoid issues on systems with large number

> of cores.

> 

> Signed-off-by: Punit Agrawal <punitagrawal@gmail.com>

> ---

>  rteval/misc.py | 1 +

>  1 file changed, 1 insertion(+)

> 

> diff --git a/rteval/misc.py b/rteval/misc.py

> index 0dd361ff19fd..ec3641e4a013 100644

> --- a/rteval/misc.py

> +++ b/rteval/misc.py

> @@ -53,6 +53,7 @@ def online_cpus():

>          for c in glob.glob('/sys/devices/system/cpu/cpu[0-9]*'):

>              num = str(c.replace('/sys/devices/system/cpu/cpu', ''))

>              online_cpus.append(num)

> +    online_cpus.sort(key=int)

>      return online_cpus

>  

>  def invert_cpulist(cpulist):

> -- 

> 2.32.0

> 

> 


Thanks for finding that. I'm wondering if it makes more sense
to sort it in cyclictest.py?

John
diff mbox series

Patch

diff --git a/rteval/misc.py b/rteval/misc.py
index 0dd361ff19fd..ec3641e4a013 100644
--- a/rteval/misc.py
+++ b/rteval/misc.py
@@ -53,6 +53,7 @@  def online_cpus():
         for c in glob.glob('/sys/devices/system/cpu/cpu[0-9]*'):
             num = str(c.replace('/sys/devices/system/cpu/cpu', ''))
             online_cpus.append(num)
+    online_cpus.sort(key=int)
     return online_cpus
 
 def invert_cpulist(cpulist):