Optimise grep action in power_management.
PATCH 1/2 Optimise grep action in power_management.
root@p1:~# time (grep siblings /proc/cpuinfo > /dev/null) real 0m0.003s user 0m0.001s sys 0m0.002s root@p1:~# time (cat /proc/cpuinfo | grep siblings > /dev/null) real 0m0.004s user 0m0.002s sys 0m0.003s
--- testcases/kernel/power_management/pm_include.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
testcases/kernel/power_management/pm_include.sh +6 -6
@@ -87,8 +87,8 @@ get_supporting_govr() { } is_hyper_threaded() { - siblings=`cat /proc/cpuinfo | grep siblings | uniq | cut -f2 -d':'` - cpu_cores=`cat /proc/cpuinfo | grep "cpu cores" | uniq | cut -f2 -d':'` + siblings=`grep siblings /proc/cpuinfo | uniq | cut -f2 -d':'` + cpu_cores=`grep "cpu cores" /proc/cpuinfo | uniq | cut -f2 -d':'` [ $siblings -gt $cpu_cores ]; echo $? }
@@ -131,8 +131,8 @@ is_multi_socket() { } is_multi_core() { - siblings=`cat /proc/cpuinfo | grep siblings | uniq | cut -f2 -d':'` - cpu_cores=`cat /proc/cpuinfo | grep "cpu cores" | uniq | cut -f2 -d':'` + siblings=`grep siblings /proc/cpuinfo | uniq | cut -f2 -d':'` + cpu_cores=`grep "cpu cores" /proc/cpuinfo | uniq | cut -f2 -d':'` if [ $siblings -eq $cpu_cores ]; then [ $cpu_cores -gt 1 ]; echo $? else
@@ -142,8 +142,8 @@ is_multi_core() { } is_dual_core() { - siblings=`cat /proc/cpuinfo | grep siblings | uniq | cut -f2 -d':'` - cpu_cores=`cat /proc/cpuinfo | grep "cpu cores" | uniq \ + siblings=`grep siblings /proc/cpuinfo | uniq | cut -f2 -d':'` + cpu_cores=`grep "cpu cores" /proc/cpuinfo | uniq \ | cut -f2 -d':'` if [ $siblings -eq $cpu_cores ]; then [ $cpu_cores -eq 2 ]; echo $?
Signature · 1 line
1.9.1
PATCH 2/2 Optimise grep action in cpuset_syscall_test
--- .../cpuset/cpuset_syscall_test/cpuset_syscall_testset.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_testset.sh +6 -6
@@ -188,7 +188,7 @@ test7() do_syscall_test 0 0 --mbind=1 0 || return $? memory_addr="$(cat $TEST_OUTPUT)" memory_addr=${memory_addr##*0x} - allowed_list=$(cat $TEST_PROCNUMA | grep "$memory_addr" | \ + allowed_list=$(grep "$memory_addr" $TEST_PROCNUMA | \ awk '{print $2}') allowed_list="$(echo $allowed_list | sed -e s/bind://)" test "$allowed_list" = "0" || return 1
@@ -204,7 +204,7 @@ test8() do_syscall_test 0 0-1 --mbind=1 0 || return $? memory_addr="$(cat $TEST_OUTPUT)" memory_addr=${memory_addr##*0x} - allowed_list=$(cat $TEST_PROCNUMA | grep "$memory_addr" | \ + allowed_list=$(grep "$memory_addr" $TEST_PROCNUMA | \ awk '{print $2}') allowed_list="$(echo $allowed_list | sed -e s/bind://)" test "$allowed_list" = "0"
@@ -220,7 +220,7 @@ test9() do_syscall_test 0 0-1 --mbind=6 0 || return $? memory_addr="$(cat $TEST_OUTPUT)" memory_addr=${memory_addr##*0x} - allowed_list=$(cat $TEST_PROCNUMA | grep "$memory_addr" | \ + allowed_list=$(grep "$memory_addr" $TEST_PROCNUMA | \ awk '{print $2}') allowed_list="$(echo $allowed_list | sed -e s/bind://)" test "$allowed_list" = "1"
@@ -236,12 +236,12 @@ test10() do_syscall_test 0 0 --mbind=6 1 || return $? memory_addr="$(cat $TEST_OUTPUT)" memory_addr=${memory_addr##*0x} - allowed_list=$(cat $TEST_PROCNUMA | grep "$memory_addr" | \ + allowed_list=$(grep "$memory_addr" $TEST_PROCNUMA | \ awk '{print $2}') allowed_list="$(echo $allowed_list | sed -e s/bind://)" - task_policy=$(cat $TEST_PROCNUMA | grep -e " *stack *anon" | \ - awk '{print $2}') + task_policy=$(grep -e " *stack *anon" | \ + awk '{print $2}' $TEST_PROCNUMA) test "$allowed_list" = "$task_policy" if [ $? -ne 0 ]; then
Signature · 1 line
1.9.1
PATCH 2/2 Optimise grep action in cpuset_syscall_test
----- Original Message -----
Quoted 50 lines
From: "Yuan Sun" <[email protected]>
To: [email protected]
Cc: [email protected]
Sent: Thursday, 15 October, 2015 3:21:29 AM
Subject: [PATCH 2/2] Optimise grep action incpuset_syscall_testSigned-off-by Yuan Sun <[email protected]>--- .../cpuset/cpuset_syscall_test/cpuset_syscall_testset.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)diff --git
a/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_testset.shb/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_testset.shindex 771b642..9d3e4c8 100755
---a/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_testset.sh
+++b/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_testset.shtestcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_testset.sh +3
-3@@ -188,7 +188,7 @@ test7() do_syscall_test 0 0 --mbind=1 0 || return $? memory_addr="$(cat $TEST_OUTPUT)" memory_addr=${memory_addr##*0x} - allowed_list=$(cat $TEST_PROCNUMA | grep "$memory_addr" | \ + allowed_list=$(grep "$memory_addr" $TEST_PROCNUMA | \ awk '{print $2}') allowed_list="$(echo $allowed_list | sed -e s/bind://)" test "$allowed_list" = "0" || return 1@@ -204,7 +204,7 @@ test8() do_syscall_test 0 0-1 --mbind=1 0 || return $? memory_addr="$(cat $TEST_OUTPUT)" memory_addr=${memory_addr##*0x} - allowed_list=$(cat $TEST_PROCNUMA | grep "$memory_addr" | \ + allowed_list=$(grep "$memory_addr" $TEST_PROCNUMA | \ awk '{print $2}') allowed_list="$(echo $allowed_list | sed -e s/bind://)" test "$allowed_list" = "0"@@ -220,7 +220,7 @@ test9() do_syscall_test 0 0-1 --mbind=6 0 || return $? memory_addr="$(cat $TEST_OUTPUT)" memory_addr=${memory_addr##*0x} - allowed_list=$(cat $TEST_PROCNUMA | grep "$memory_addr" | \ + allowed_list=$(grep "$memory_addr" $TEST_PROCNUMA | \ awk '{print $2}') allowed_list="$(echo $allowed_list | sed -e s/bind://)" test "$allowed_list" = "1"@@ -236,12 +236,12 @@ test10() do_syscall_test 0 0 --mbind=6 1 || return $? memory_addr="$(cat $TEST_OUTPUT)"
testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_testset.sh test10() · line 244
Quoted 10 lines
testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_testset.sh +3
-3memory_addr=${memory_addr##*0x} - allowed_list=$(cat $TEST_PROCNUMA | grep "$memory_addr" | \ + allowed_list=$(grep "$memory_addr" $TEST_PROCNUMA | \ awk '{print $2}') allowed_list="$(echo $allowed_list | sed -e s/bind://)" - task_policy=$(cat $TEST_PROCNUMA | grep -e " *stack *anon" | \ - awk '{print $2}') + task_policy=$(grep -e " *stack *anon" | \ + awk '{print $2}' $TEST_PROCNUMA)
Shouldn't this last one be:
+ task_policy=$(grep -e " *stack *anon" $TEST_PROCNUMA | \
+ awk '{print $2}')
Regards,
Jan
Quoted 7 lines
testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_testset.sh +0
-1test "$allowed_list" = "$task_policy" if [ $? -ne 0 ]; then --1.9.1
PATCH 2/2 Optimise grep action in cpuset_syscall_test
Hi!
Review
Quoted 7 lines
testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_testset.sh test10() · line 244
Quoted 2 lines
testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_testset.sh +2
-0+ task_policy=$(grep -e " *stack *anon" | \ + awk '{print $2}' $TEST_PROCNUMA)Shouldn't this last one be:
(quoted diff) +2
-0+ task_policy=$(grep -e " *stack *anon" $TEST_PROCNUMA | \ + awk '{print $2}')
Looks like an obvious typo to me. Can you please push fix?
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 2/2 Optimise grep action in cpuset_syscall_test
----- Original Message -----
Quoted 7 lines
From: "Cyril Hrubis" <[email protected]>
To: "Jan Stancek" <[email protected]>
Cc: "Yuan Sun" <[email protected]>, [email protected]
Sent: Monday, 16 November, 2015 5:37:44 PM
Subject: Re: [LTP] [PATCH 2/2] Optimise grep action incpuset_syscall_testHi!
Quoted 9 lines
Review
Quoted 7 lines
testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_testset.sh test10() · line 244
Quoted 2 lines
testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_testset.sh +2
-0+ task_policy=$(grep -e " *stack *anon" | \ + awk '{print $2}' $TEST_PROCNUMA)Shouldn't this last one be:
(quoted diff) +2
-0+ task_policy=$(grep -e " *stack *anon" $TEST_PROCNUMA | \ + awk '{print $2}')Looks like an obvious typo to me. Can you please push fix?
This should be fixed already. Yuan sent v2, where he fixed this:
commit ca77742387f0bd4e42c39b1c70e5995be3433687
Author: Yuan Sun <[email protected]> Date: Mon Nov 9 16:05:34 2015 +0800
cpuset_syscall_test: simplify grep actions
Regards,
Jan
Quoted 5 lines
--
Cyril Hrubis
[email protected]
PATCH 2/2 Optimise grep action in cpuset_syscall_test
Hi!
Quoted 7 lines
Quoted 6 lines
Review
Quoted 4 lines
Shouldn't this last one be:
(quoted diff) +2
-0+ task_policy=$(grep -e " *stack *anon" $TEST_PROCNUMA | \ + awk '{print $2}')Looks like an obvious typo to me. Can you please push fix?
Quoted 6 lines
This should be fixed already. Yuan sent v2, where he fixed this:
commit
ca77742387f0bd4e42c39b1c70e5995be3433687Author: Yuan Sun <[email protected]> Date: Mon Nov 9 16:05:34 2015 +0800
cpuset_syscall_test: simplify grep actions
Ah, I've missed that there was v2. It's ok then.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/2 Optimise grep action in power_management.
In reply to Yuan SunHi!
Quoted 8 lines
root@p1:~# time (grep siblings /proc/cpuinfo > /dev/null) real 0m0.003s user 0m0.001s sys 0m0.002s root@p1:~# time (cat /proc/cpuinfo | grep siblings > /dev/null) real 0m0.004s user 0m0.002s sys 0m0.003s
I wouldn't say optimise in the commit message but rather simplify. Since the difference in speed is not that big.
Otherwise the patches looks good.
Signature · 2 lines
Cyril Hrubis [email protected]