From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] controllers/cpuset:check for cpuset mount status and prefix
Date: Thu, 20 Apr 2017 14:11:21 +0200 [thread overview]
Message-ID: <20170420121121.GA10246@rei.lan> (raw)
In-Reply-To: <1468479240-4975-1-git-send-email-shuang.qiu@oracle.com>
Hi!
> diff --git a/testcases/kernel/controllers/cpuset/cpuset_funcs.sh b/testcases/kernel/controllers/cpuset/cpuset_funcs.sh
> index cd7000e..72bf8e3 100755
> --- a/testcases/kernel/controllers/cpuset/cpuset_funcs.sh
> +++ b/testcases/kernel/controllers/cpuset/cpuset_funcs.sh
> @@ -35,8 +35,10 @@ fi
> N_NODES=${N_NODES#*-*}
> N_NODES=$(($N_NODES + 1))
>
> -CPUSET="/dev/cpuset"
> +CPUSET=`grep -w cpuset /proc/mounts | cut -f 2 | cut -d " " -f2`
The 'cut -f 2' does not seem to have any efect here, moreover single awk
command should do the same:
CPUSET=$(awk '/cpuset/ {print $2}' /proc/mounts)
> +[ "$CPUSET" == "" ] && CPUSET="/dev/cpuset"
> CPUSET_TMP="/tmp/cpuset_tmp"
> +[ -e "$CPUSET/cpuset.cpus" ] && PREFIX="cpuset."
Shouldn't we do this check in the setup after we mounted the cpuset (in
a case that it wasn't mounted)?
> HOTPLUG_CPU="1"
>
> @@ -121,19 +123,23 @@ check()
> # clean any group created eralier (if any)
> setup()
> {
> - if [ -e "$CPUSET" ]
> - then
> - tst_resm TWARN "$CPUSET already exist.. overwriting"
> - cleanup || tst_brkm TFAIL "Can't cleanup... Exiting"
> - fi
> -
> + try_mount=0
> mkdir -p "$CPUSET_TMP"
> - mkdir "$CPUSET"
> - mount -t cpuset cpuset "$CPUSET" 2> /dev/null
> - if [ $? -ne 0 ]; then
> - cleanup
> - tst_brkm TFAIL "Could not mount cgroup filesystem with"\
> + if [ "$CPUSET" = "/dev/cpuset" ];then
> + if [ -e "$CPUSET" ]
> + then
> + tst_resm TWARN "$CPUSET already exist.. overwriting"
> + cleanup || tst_brkm TFAIL "Can't cleanup... Exiting"
> + fi
The coding style in this part is inconsistent, ideally you should stick
to the style used in the rest of the file and consistently use:
if foo; then
...
fi
> + try_mount=1
> + mkdir "$CPUSET"
> + mount -t cpuset cpuset "$CPUSET" 2> /dev/null
> + if [ $? -ne 0 ]; then
> + cleanup
> + tst_brkm TFAIL "Could not mount cgroup filesystem with"\
> " cpuset on $CPUSET..Exiting test"
> + fi
We should set the try_mount after the mount here since otherwise we will
try to umount it in the cleanup if the mount here has failed.
Also it try_mount is not a good name for the flag. It should be rather
called moutned instead.
> fi
> }
>
> @@ -162,13 +168,14 @@ cleanup()
> fi
> done
>
> + rm -rf "$CPUSET_TMP" > /dev/null 2>&1
> + [ "$try_mount" -ne 1 ] && return
> umount "$CPUSET"
> if [ $? -ne 0 ]; then
> tst_brkm TFAIL "Couldn't umount cgroup filesystem with"\
> " cpuset on $CPUSET..Exiting test"
> fi
> rmdir "$CPUSET" > /dev/null 2>&1
> - rm -rf "$CPUSET_TMP" > /dev/null 2>&1
> }
The rest of the patchset looks obviously correct.
--
Cyril Hrubis
chrubis@suse.cz
next prev parent reply other threads:[~2017-04-20 12:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-14 6:54 [LTP] [PATCH] controllers/cpuset:check for cpuset mount status and prefix shuang.qiu
2016-07-22 13:15 ` Jan Stancek
2016-07-23 23:34 ` Shuang Qiu
2017-04-11 6:32 ` charishma
2017-04-18 10:00 ` Jan Stancek
2017-04-20 12:15 ` Cyril Hrubis
2017-04-20 12:11 ` Cyril Hrubis [this message]
2017-04-22 8:30 ` Shuang Qiu
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=20170420121121.GA10246@rei.lan \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
/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.