Re: [PATCH rt-tests] queuelat: fix get_cpuinfo_mhz.sh script on SMP systems

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
>>
>> 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
--
To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux