All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Kacur <jkacur@redhat.com>
To: Punit Agrawal <punitagrawal@gmail.com>
Cc: punit1.agrawal@toshiba.co.jp, linux-rt-users@vger.kernel.org
Subject: Re: [PATCH 2/5] rteval: cyclictest.py: Update logic to get core description
Date: Thu, 9 Sep 2021 08:41:42 -0400 (EDT)	[thread overview]
Message-ID: <633d388d-13d9-6155-e4da-ca135c0df44@redhat.com> (raw)
In-Reply-To: <20210901080816.721731-3-punitagrawal@gmail.com>



On Wed, 1 Sep 2021, Punit Agrawal wrote:

> From: Punit Agrawal <punit1.agrawal@toshiba.co.jp>
> 
> Certain architectures such as arm and arm64 don't have a "model name"
> in /proc/cpuinfo but provide other identifying information such as
> implementer, architecture, variant, part, revision, etc..
> 
> Add a function 'get_cpumodel()' that takes the per-core dictionary
> constructed from /proc/cpuinfo and uses the available data to
> construct the CPU description. Update the users of "model name" to use
> the newly added function.
> 
> Signed-off-by: Punit Agrawal <punit1.agrawal@toshiba.co.jp>
> ---
>  rteval/misc.py                           | 23 ++++++++++++++++++++++-
>  rteval/modules/measurement/cyclictest.py |  8 +++++---
>  2 files changed, 27 insertions(+), 4 deletions(-)
> 
> diff --git a/rteval/misc.py b/rteval/misc.py
> index 0dd361ff19fd..537041b53d61 100644
> --- a/rteval/misc.py
> +++ b/rteval/misc.py
> @@ -79,6 +79,27 @@ def cpuinfo():
>          info[core][key] = val
>      return info
>  
> +# Pass the per-core dictionary that is part of the dictionary returned
> +# by cpuinfo()
> +def get_cpumodel(core_info):
> +    desc = core_info.get('model name', '')
> +    if not desc:
> +        # On Arm (both 32 and 64 bit), 'CPU Implementer' is always
> +        # present. Return 'unknown' otherwise
> +        if 'CPU implementer' not in core_info:
> +            desc = 'unknown'
> +        else:
> +            implementor = core_info.get('CPU implementer', '')
> +            architecture = core_info.get('CPU architecture', '')
> +            variant = core_info.get('CPU variant', '')
> +            part = core_info.get('CPU part', '')
> +            revision = core_info.get('CPU revision', '')
> +
> +            desc = 'Implementor: %s Architecture: %s Variant: %s Part: %s Revision: %s' \
> +                % (implementor, architecture, variant, part, revision)
> +
> +    return desc
> +
>  if __name__ == "__main__":
>  
>      info = cpuinfo()
> @@ -86,4 +107,4 @@ if __name__ == "__main__":
>      for i in idx:
>          print("%s: %s" % (i, info[i]))
>  
> -    print("0: %s" % (info['0']['model name']))
> +    print("0: %s" % (get_cpumodel(info['0'])))
> diff --git a/rteval/modules/measurement/cyclictest.py b/rteval/modules/measurement/cyclictest.py
> index b1755d4f4421..11cb45e711dd 100644
> --- a/rteval/modules/measurement/cyclictest.py
> +++ b/rteval/modules/measurement/cyclictest.py
> @@ -34,7 +34,7 @@ import math
>  import libxml2
>  from rteval.Log import Log
>  from rteval.modules import rtevalModulePrototype
> -from rteval.misc import expand_cpulist, online_cpus, cpuinfo
> +from rteval.misc import expand_cpulist, online_cpus, cpuinfo, get_cpumodel
>  
>  class RunData:
>      '''class to keep instance data from a cyclictest run'''
> @@ -226,13 +226,15 @@ class Cyclictest(rtevalModulePrototype):
>          for core in self.__cpus:
>              self.__cyclicdata[core] = RunData(core, 'core', self.__priority,
>                                                logfnc=self._log)
> -            self.__cyclicdata[core].description = info[core]['model name']
> +            self.__cyclicdata[core].description = get_cpumodel(info[core])
> +            if self.__cyclicdata[core].description == 'unknown':
> +                self._log(Log.INFO, "Unknown model for core %d" % core)
>  
>          # Create a RunData object for the overall system
>          self.__cyclicdata['system'] = RunData('system',
>                                                'system', self.__priority,
>                                                logfnc=self._log)
> -        self.__cyclicdata['system'].description = ("(%d cores) " % self.__numcores) + info['0']['model name']
> +        self.__cyclicdata['system'].description = ("(%d cores) " % self.__numcores) + get_cpumodel(info['0'])
>  
>          if self.__sparse:
>              self._log(Log.DEBUG, "system using %d cpu cores" % self.__numcores)
> -- 
> 2.32.0
> 
> 

I like the idea of constructing the 'model name' from other fields in 
/proc/cpuinfo available for arm.

There are a number of problems with the implementation.
This should be written in such away that the local changes in misc.py
work seamlessly without changes to the code that calls it. The code should 
also add the 'model name' to every core.
Finally, a lesser detail, but there is no need when using get to set a 
default of "" when the default is already None. Just make the code work 
with None.

I have rewritten this from scratch, attributing the idea to you, I hope 
that is okay. I will send the patch to the list shortly.

John


  reply	other threads:[~2021-09-09 12:47 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-01  8:08 [PATCH 0/5] Enable rteval on Arm based systems Punit Agrawal
2021-09-01  8:08 ` [PATCH 1/5] rteval: systopology.py: Add support for systems that don't have Numa Punit Agrawal
2021-09-09 12:34   ` John Kacur
2021-09-13  2:28     ` Punit Agrawal
2021-09-01  8:08 ` [PATCH 2/5] rteval: cyclictest.py: Update logic to get core description Punit Agrawal
2021-09-09 12:41   ` John Kacur [this message]
2021-09-01  8:08 ` [PATCH 3/5] rteval: kernel.py: Add support for kthreads running with deadline policy Punit Agrawal
2021-09-09 12:47   ` John Kacur
2021-09-15  8:45     ` Punit Agrawal
2021-09-15 12:17       ` John Kacur
2021-09-16 11:34         ` Punit Agrawal
2021-09-01  8:08 ` [PATCH 4/5] rteval: hackbench.py: Enable running on a system with low memory Punit Agrawal
2021-09-09 12:46   ` John Kacur
2021-09-13  7:18     ` Punit Agrawal
2021-09-13 12:52       ` John Kacur
2021-09-14 18:32   ` John Kacur
2021-09-15  1:54     ` Punit Agrawal
2021-09-01  8:08 ` [PATCH 5/5] rteval: kcompile.py: Gracefully handle missing affinity information Punit Agrawal
2021-09-09 19:23   ` John Kacur

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=633d388d-13d9-6155-e4da-ca135c0df44@redhat.com \
    --to=jkacur@redhat.com \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=punit1.agrawal@toshiba.co.jp \
    --cc=punitagrawal@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.