* [LTP] [PATCH 1/2] Optimise grep action in power_management.
@ 2015-10-15 1:21 Yuan Sun
2015-10-15 1:21 ` [LTP] [PATCH 2/2] Optimise grep action in cpuset_syscall_test Yuan Sun
2015-10-27 16:35 ` [LTP] [PATCH 1/2] Optimise grep action in power_management Cyril Hrubis
0 siblings, 2 replies; 7+ messages in thread
From: Yuan Sun @ 2015-10-15 1:21 UTC (permalink / raw)
To: ltp
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
Signed-off-by: Yuan Sun <sunyuan3@huawei.com>
---
testcases/kernel/power_management/pm_include.sh | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/testcases/kernel/power_management/pm_include.sh b/testcases/kernel/power_management/pm_include.sh
index 366c914..807a5a8 100755
--- a/testcases/kernel/power_management/pm_include.sh
+++ b/testcases/kernel/power_management/pm_include.sh
@@ -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 $?
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [LTP] [PATCH 2/2] Optimise grep action in cpuset_syscall_test
2015-10-15 1:21 [LTP] [PATCH 1/2] Optimise grep action in power_management Yuan Sun
@ 2015-10-15 1:21 ` Yuan Sun
2015-11-06 9:01 ` Jan Stancek
2015-10-27 16:35 ` [LTP] [PATCH 1/2] Optimise grep action in power_management Cyril Hrubis
1 sibling, 1 reply; 7+ messages in thread
From: Yuan Sun @ 2015-10-15 1:21 UTC (permalink / raw)
To: ltp
Signed-off-by: Yuan Sun <sunyuan3@huawei.com>
---
.../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.sh b/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_testset.sh
index 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.sh
@@ -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
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [LTP] [PATCH 1/2] Optimise grep action in power_management.
2015-10-15 1:21 [LTP] [PATCH 1/2] Optimise grep action in power_management Yuan Sun
2015-10-15 1:21 ` [LTP] [PATCH 2/2] Optimise grep action in cpuset_syscall_test Yuan Sun
@ 2015-10-27 16:35 ` Cyril Hrubis
1 sibling, 0 replies; 7+ messages in thread
From: Cyril Hrubis @ 2015-10-27 16:35 UTC (permalink / raw)
To: ltp
Hi!
> 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.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 7+ messages in thread
* [LTP] [PATCH 2/2] Optimise grep action in cpuset_syscall_test
2015-10-15 1:21 ` [LTP] [PATCH 2/2] Optimise grep action in cpuset_syscall_test Yuan Sun
@ 2015-11-06 9:01 ` Jan Stancek
2015-11-16 16:37 ` Cyril Hrubis
0 siblings, 1 reply; 7+ messages in thread
From: Jan Stancek @ 2015-11-06 9:01 UTC (permalink / raw)
To: ltp
----- Original Message -----
> From: "Yuan Sun" <sunyuan3@huawei.com>
> To: jstancek@redhat.com
> Cc: ltp@lists.linux.it
> Sent: Thursday, 15 October, 2015 3:21:29 AM
> Subject: [PATCH 2/2] Optimise grep action in cpuset_syscall_test
>
> Signed-off-by: Yuan Sun <sunyuan3@huawei.com>
> ---
> .../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.sh
> b/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_testset.sh
> index 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.sh
> @@ -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)
Shouldn't this last one be:
+ task_policy=$(grep -e " *stack *anon" $TEST_PROCNUMA | \
+ awk '{print $2}')
Regards,
Jan
>
> test "$allowed_list" = "$task_policy"
> if [ $? -ne 0 ]; then
> --
> 1.9.1
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [LTP] [PATCH 2/2] Optimise grep action in cpuset_syscall_test
2015-11-06 9:01 ` Jan Stancek
@ 2015-11-16 16:37 ` Cyril Hrubis
2015-11-16 16:50 ` Jan Stancek
0 siblings, 1 reply; 7+ messages in thread
From: Cyril Hrubis @ 2015-11-16 16:37 UTC (permalink / raw)
To: ltp
Hi!
> > + 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}')
>
Looks like an obvious typo to me. Can you please push fix?
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 7+ messages in thread
* [LTP] [PATCH 2/2] Optimise grep action in cpuset_syscall_test
2015-11-16 16:37 ` Cyril Hrubis
@ 2015-11-16 16:50 ` Jan Stancek
2015-11-16 17:10 ` Cyril Hrubis
0 siblings, 1 reply; 7+ messages in thread
From: Jan Stancek @ 2015-11-16 16:50 UTC (permalink / raw)
To: ltp
----- Original Message -----
> From: "Cyril Hrubis" <chrubis@suse.cz>
> To: "Jan Stancek" <jstancek@redhat.com>
> Cc: "Yuan Sun" <sunyuan3@huawei.com>, ltp@lists.linux.it
> Sent: Monday, 16 November, 2015 5:37:44 PM
> Subject: Re: [LTP] [PATCH 2/2] Optimise grep action in cpuset_syscall_test
>
> Hi!
> > > + 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}')
> >
>
> 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 <sunyuan3@huawei.com>
Date: Mon Nov 9 16:05:34 2015 +0800
cpuset_syscall_test: simplify grep actions
Regards,
Jan
>
> --
> Cyril Hrubis
> chrubis@suse.cz
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [LTP] [PATCH 2/2] Optimise grep action in cpuset_syscall_test
2015-11-16 16:50 ` Jan Stancek
@ 2015-11-16 17:10 ` Cyril Hrubis
0 siblings, 0 replies; 7+ messages in thread
From: Cyril Hrubis @ 2015-11-16 17:10 UTC (permalink / raw)
To: ltp
Hi!
> > > Shouldn't this last one be:
> > > + 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 <sunyuan3@huawei.com>
> 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.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-11-16 17:10 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-15 1:21 [LTP] [PATCH 1/2] Optimise grep action in power_management Yuan Sun
2015-10-15 1:21 ` [LTP] [PATCH 2/2] Optimise grep action in cpuset_syscall_test Yuan Sun
2015-11-06 9:01 ` Jan Stancek
2015-11-16 16:37 ` Cyril Hrubis
2015-11-16 16:50 ` Jan Stancek
2015-11-16 17:10 ` Cyril Hrubis
2015-10-27 16:35 ` [LTP] [PATCH 1/2] Optimise grep action in power_management Cyril Hrubis
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.