DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] usertools: fix cpu_layout script for multithreads of more than 2
@ 2017-04-28 10:34 Gowrishankar
  2017-04-28 11:58 ` Thomas Monjalon
  0 siblings, 1 reply; 4+ messages in thread
From: Gowrishankar @ 2017-04-28 10:34 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, Gowrishankar Muthukrishnan

From: Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>

Current usertools/cpu_layout.py is broken to handle multithreads of count more
than 2 as in IBM powerpc P8 servers. Below patch addressed this issue. Also,
added minor exception catch on failing to open unavailable sys file in case of
multithread=off configuration in server.

Patch has been verified not to break existing topology configurations
and also not changing anything in current output.

Signed-off-by: Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>
---
 usertools/cpu_layout.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/usertools/cpu_layout.py b/usertools/cpu_layout.py
index 5735891..99152a2 100755
--- a/usertools/cpu_layout.py
+++ b/usertools/cpu_layout.py
@@ -46,6 +46,8 @@
 for cpu in xrange(max_cpus + 1):
     try:
         fd = open("{}/cpu{}/topology/core_id".format(base_path, cpu))
+    except IOError:
+        continue
     except:
         break
     core = int(fd.read())
@@ -70,7 +72,10 @@
 print("")
 
 max_processor_len = len(str(len(cores) * len(sockets) * 2 - 1))
-max_core_map_len = max_processor_len * 2 + len('[, ]') + len('Socket ')
+max_thread_count = len(core_map.values()[0])
+max_core_map_len = (max_processor_len * max_thread_count)  \
+                      + len(", ") * (max_thread_count - 1) \
+                      + len('[]') + len('Socket ')
 max_core_id_len = len(str(max(cores)))
 
 output = " ".ljust(max_core_id_len + len('Core '))
@@ -87,5 +92,8 @@
 for c in cores:
     output = "Core %s" % str(c).ljust(max_core_id_len)
     for s in sockets:
-        output += " " + str(core_map[(s, c)]).ljust(max_core_map_len)
+        if core_map.has_key((s,c)):
+            output += " " + str(core_map[(s, c)]).ljust(max_core_map_len)
+        else:
+            output += " " * (max_core_map_len + 1)
     print(output)
-- 
1.9.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] usertools: fix cpu_layout script for multithreads of more than 2
  2017-04-28 10:34 [dpdk-dev] [PATCH] usertools: fix cpu_layout script for multithreads of more than 2 Gowrishankar
@ 2017-04-28 11:58 ` Thomas Monjalon
  2017-04-28 12:25   ` Andriy Berestovskyy
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Monjalon @ 2017-04-28 11:58 UTC (permalink / raw)
  To: Andriy Berestovskyy; +Cc: dev, Gowrishankar

Andriy, please would you like to review this patch?

28/04/2017 12:34, Gowrishankar:
> From: Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>
> 
> Current usertools/cpu_layout.py is broken to handle multithreads of count more
> than 2 as in IBM powerpc P8 servers. Below patch addressed this issue. Also,
> added minor exception catch on failing to open unavailable sys file in case of
> multithread=off configuration in server.
> 
> Patch has been verified not to break existing topology configurations
> and also not changing anything in current output.
> 
> Signed-off-by: Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>
> ---
>  usertools/cpu_layout.py | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/usertools/cpu_layout.py b/usertools/cpu_layout.py
> index 5735891..99152a2 100755
> --- a/usertools/cpu_layout.py
> +++ b/usertools/cpu_layout.py
> @@ -46,6 +46,8 @@
>  for cpu in xrange(max_cpus + 1):
>      try:
>          fd = open("{}/cpu{}/topology/core_id".format(base_path, cpu))
> +    except IOError:
> +        continue
>      except:
>          break
>      core = int(fd.read())
> @@ -70,7 +72,10 @@
>  print("")
>  
>  max_processor_len = len(str(len(cores) * len(sockets) * 2 - 1))
> -max_core_map_len = max_processor_len * 2 + len('[, ]') + len('Socket ')
> +max_thread_count = len(core_map.values()[0])
> +max_core_map_len = (max_processor_len * max_thread_count)  \
> +                      + len(", ") * (max_thread_count - 1) \
> +                      + len('[]') + len('Socket ')
>  max_core_id_len = len(str(max(cores)))
>  
>  output = " ".ljust(max_core_id_len + len('Core '))
> @@ -87,5 +92,8 @@
>  for c in cores:
>      output = "Core %s" % str(c).ljust(max_core_id_len)
>      for s in sockets:
> -        output += " " + str(core_map[(s, c)]).ljust(max_core_map_len)
> +        if core_map.has_key((s,c)):
> +            output += " " + str(core_map[(s, c)]).ljust(max_core_map_len)
> +        else:
> +            output += " " * (max_core_map_len + 1)
>      print(output)
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] usertools: fix cpu_layout script for multithreads of more than 2
  2017-04-28 11:58 ` Thomas Monjalon
@ 2017-04-28 12:25   ` Andriy Berestovskyy
  2017-04-30 13:29     ` Thomas Monjalon
  0 siblings, 1 reply; 4+ messages in thread
From: Andriy Berestovskyy @ 2017-04-28 12:25 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev, Gowrishankar

Works fine on ThunderX and does not brake Intel either.

Reviewed-by: Andriy Berestovskyy <andriy.berestovskyy@caviumnetworks.com>
Tested-by: Andriy Berestovskyy <andriy.berestovskyy@caviumnetworks.com>

Andriy

On 28.04.2017 13:58, Thomas Monjalon wrote:
> Andriy, please would you like to review this patch?
>
> 28/04/2017 12:34, Gowrishankar:
>> From: Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>
>>
>> Current usertools/cpu_layout.py is broken to handle multithreads of count more
>> than 2 as in IBM powerpc P8 servers. Below patch addressed this issue. Also,
>> added minor exception catch on failing to open unavailable sys file in case of
>> multithread=off configuration in server.
>>
>> Patch has been verified not to break existing topology configurations
>> and also not changing anything in current output.
>>
>> Signed-off-by: Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>
>> ---
>>  usertools/cpu_layout.py | 12 ++++++++++--
>>  1 file changed, 10 insertions(+), 2 deletions(-)
>>
>> diff --git a/usertools/cpu_layout.py b/usertools/cpu_layout.py
>> index 5735891..99152a2 100755
>> --- a/usertools/cpu_layout.py
>> +++ b/usertools/cpu_layout.py
>> @@ -46,6 +46,8 @@
>>  for cpu in xrange(max_cpus + 1):
>>      try:
>>          fd = open("{}/cpu{}/topology/core_id".format(base_path, cpu))
>> +    except IOError:
>> +        continue
>>      except:
>>          break
>>      core = int(fd.read())
>> @@ -70,7 +72,10 @@
>>  print("")
>>
>>  max_processor_len = len(str(len(cores) * len(sockets) * 2 - 1))
>> -max_core_map_len = max_processor_len * 2 + len('[, ]') + len('Socket ')
>> +max_thread_count = len(core_map.values()[0])
>> +max_core_map_len = (max_processor_len * max_thread_count)  \
>> +                      + len(", ") * (max_thread_count - 1) \
>> +                      + len('[]') + len('Socket ')
>>  max_core_id_len = len(str(max(cores)))
>>
>>  output = " ".ljust(max_core_id_len + len('Core '))
>> @@ -87,5 +92,8 @@
>>  for c in cores:
>>      output = "Core %s" % str(c).ljust(max_core_id_len)
>>      for s in sockets:
>> -        output += " " + str(core_map[(s, c)]).ljust(max_core_map_len)
>> +        if core_map.has_key((s,c)):
>> +            output += " " + str(core_map[(s, c)]).ljust(max_core_map_len)
>> +        else:
>> +            output += " " * (max_core_map_len + 1)
>>      print(output)
>>
>
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] usertools: fix cpu_layout script for multithreads of more than 2
  2017-04-28 12:25   ` Andriy Berestovskyy
@ 2017-04-30 13:29     ` Thomas Monjalon
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Monjalon @ 2017-04-30 13:29 UTC (permalink / raw)
  To: Gowrishankar; +Cc: dev, Andriy Berestovskyy

28/04/2017 14:25, Andriy Berestovskyy:
> Works fine on ThunderX and does not brake Intel either.
> 
> Reviewed-by: Andriy Berestovskyy <andriy.berestovskyy@caviumnetworks.com>
> Tested-by: Andriy Berestovskyy <andriy.berestovskyy@caviumnetworks.com>
> 
> Andriy
> 
> On 28.04.2017 13:58, Thomas Monjalon wrote:
> > Andriy, please would you like to review this patch?
> >
> > 28/04/2017 12:34, Gowrishankar:
> >> From: Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>
> >>
> >> Current usertools/cpu_layout.py is broken to handle multithreads of count more
> >> than 2 as in IBM powerpc P8 servers. Below patch addressed this issue. Also,
> >> added minor exception catch on failing to open unavailable sys file in case of
> >> multithread=off configuration in server.
> >>
> >> Patch has been verified not to break existing topology configurations
> >> and also not changing anything in current output.
> >>
> >> Signed-off-by: Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>

Applied, thanks

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-04-30 13:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-28 10:34 [dpdk-dev] [PATCH] usertools: fix cpu_layout script for multithreads of more than 2 Gowrishankar
2017-04-28 11:58 ` Thomas Monjalon
2017-04-28 12:25   ` Andriy Berestovskyy
2017-04-30 13:29     ` Thomas Monjalon

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).