All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH rt-tests] queuelat: fix get_cpuinfo_mhz.sh script on SMP systems
@ 2018-06-20 13:21 Marcelo Tosatti
  2018-06-22 20:00 ` Gratian Crisan
  0 siblings, 1 reply; 3+ messages in thread
From: Marcelo Tosatti @ 2018-06-20 13:21 UTC (permalink / raw)
  To: John Kacur; +Cc: linux-rt-users


get_cpuinfo_mhz.sh fails on SMP systems because 
/proc/cpuinfo returns multiple "cpu MHz" containing
lines.

Get only the first one.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

diff --git a/src/queuelat/get_cpuinfo_mhz.sh b/src/queuelat/get_cpuinfo_mhz.sh
index fb5158f..46f94c4 100755
--- a/src/queuelat/get_cpuinfo_mhz.sh
+++ b/src/queuelat/get_cpuinfo_mhz.sh
@@ -1,5 +1,5 @@
 #!/bin/bash
 
-mhz=`cat /proc/cpuinfo  | grep "cpu MHz" | uniq | cut -f 3 -d " "`
+mhz=`cat /proc/cpuinfo  | grep "cpu MHz" | uniq | cut -f 3 -d " " | head -1`
 echo $mhz
 

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

* Re: [PATCH rt-tests] queuelat: fix get_cpuinfo_mhz.sh script on SMP systems
  2018-06-20 13:21 [PATCH rt-tests] queuelat: fix get_cpuinfo_mhz.sh script on SMP systems Marcelo Tosatti
@ 2018-06-22 20:00 ` Gratian Crisan
  2018-06-23 13:24   ` Carsten Emde
  0 siblings, 1 reply; 3+ messages in thread
From: Gratian Crisan @ 2018-06-22 20:00 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: John Kacur, linux-rt-users


Marcelo Tosatti writes:

> get_cpuinfo_mhz.sh fails on SMP systems because 
> /proc/cpuinfo returns multiple "cpu MHz" containing
> lines.
>
> Get only the first one.
>
> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
>
> diff --git a/src/queuelat/get_cpuinfo_mhz.sh b/src/queuelat/get_cpuinfo_mhz.sh
> index fb5158f..46f94c4 100755
> --- a/src/queuelat/get_cpuinfo_mhz.sh
> +++ b/src/queuelat/get_cpuinfo_mhz.sh
> @@ -1,5 +1,5 @@
>  #!/bin/bash
>  
> -mhz=`cat /proc/cpuinfo  | grep "cpu MHz" | uniq | cut -f 3 -d " "`
> +mhz=`cat /proc/cpuinfo  | grep "cpu MHz" | uniq | cut -f 3 -d " " | head -1`

Not sure how much it matters here but you can make this more compact by
using the '-m' grep option to stop the search after one match, something
like:

mhz = `cat /proc/cpuinfo  | grep -m 1 "cpu MHz" | cut -f 3 -d " "`

-Gratian

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

* Re: [PATCH rt-tests] queuelat: fix get_cpuinfo_mhz.sh script on SMP systems
  2018-06-22 20:00 ` Gratian Crisan
@ 2018-06-23 13:24   ` Carsten Emde
  0 siblings, 0 replies; 3+ messages in thread
From: Carsten Emde @ 2018-06-23 13:24 UTC (permalink / raw)
  To: Gratian Crisan; +Cc: Marcelo Tosatti, John Kacur, linux-rt-users

On 06/22/2018 10:00 PM, Gratian Crisan wrote:
> Marcelo Tosatti writes:
>> get_cpuinfo_mhz.sh fails on SMP systems because 
>> /proc/cpuinfo returns multiple "cpu MHz" containing
>> lines.
>>
>> Get only the first one.
>>
>> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
>>
>> diff --git a/src/queuelat/get_cpuinfo_mhz.sh b/src/queuelat/get_cpuinfo_mhz.sh
>> index fb5158f..46f94c4 100755
>> --- a/src/queuelat/get_cpuinfo_mhz.sh
>> +++ b/src/queuelat/get_cpuinfo_mhz.sh
>> @@ -1,5 +1,5 @@
>>  #!/bin/bash
>>  
>> -mhz=`cat /proc/cpuinfo  | grep "cpu MHz" | uniq | cut -f 3 -d " "`
>> +mhz=`cat /proc/cpuinfo  | grep "cpu MHz" | uniq | cut -f 3 -d " " | head -1`
> 
> Not sure how much it matters here but you can make this more compact by
> using the '-m' grep option to stop the search after one match, something
> like:
> 
> mhz = `cat /proc/cpuinfo  | grep -m 1 "cpu MHz" | cut -f 3 -d " "`
Want to make it even shorter? Then skip the cat command and grep /proc/cpuinfo directly:
-mhz = `cat /proc/cpuinfo  | grep -m 1 "cpu MHz" | cut -f 3 -d " "
+mhz = `grep -m 1 "cpu MHz" /proc/cpuinfo | cut -f 3 -d " "`

	-Carsten

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

end of thread, other threads:[~2018-06-23 13:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-20 13:21 [PATCH rt-tests] queuelat: fix get_cpuinfo_mhz.sh script on SMP systems Marcelo Tosatti
2018-06-22 20:00 ` Gratian Crisan
2018-06-23 13:24   ` Carsten Emde

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.