All of lore.kernel.org
 help / color / mirror / Atom feed
From: Omar Sandoval <osandov@osandov.com>
To: Bart Van Assche <bvanassche@acm.org>
Cc: Omar Sandoval <osandov@fb.com>,
	linux-block@vger.kernel.org,
	Johannes Thumshirn <jthumshirn@suse.de>
Subject: Re: [PATCH blktests 2/2] Add a test that triggers blk_mq_update_nr_hw_queues()
Date: Thu, 24 Oct 2019 10:58:48 -0700	[thread overview]
Message-ID: <20191024175848.GD137052@vader> (raw)
In-Reply-To: <03e57c18-83b0-2b53-48b9-84d56b216553@acm.org>

On Thu, Oct 24, 2019 at 10:55:06AM -0700, Bart Van Assche wrote:
> On 10/24/19 10:42 AM, Omar Sandoval wrote:
> > On Mon, Oct 21, 2019 at 03:57:19PM -0700, Bart Van Assche wrote:
> > > +# Configure one null_blk instance.
> > > +configure_null_blk() {
> > > +	(
> > > +		cd /sys/kernel/config/nullb || return $?
> > > +		(
> > > +			mkdir -p nullb0 &&
> > > +				cd nullb0 &&
> > > +				echo 0 > completion_nsec &&
> > > +				echo 512 > blocksize &&
> > > +				echo 16 > size &&
> > > +				echo 1 > memory_backed &&
> > > +				echo 1 > power
> > > +		)
> > > +	) &&
> > > +	ls -l /dev/nullb* &>>"$FULL"
> > 
> > What's the point of these nested subshells? Can't this just be:
> > 
> > configure_null_blk() {
> > 	cd /sys/kernel/config/nullb &&
> > 	mkdir -p nullb0 &&
> > 	cd nullb0 &&
> > 	echo 0 > completion_nsec &&
> > 	echo 512 > blocksize &&
> > 	echo 16 > size &&
> > 	echo 1 > memory_backed &&
> > 	echo 1 > power &&
> > 	ls -l /dev/nullb* &>>"$FULL"
> > }
> 
> The above code is not equivalent to the original code because it does not
> restore the original working directory.
> 
> When using 'cd' inside a subshell, the working directory that was effective
> before the 'cd' command is restored automatically when exiting from the
> subshell. I prefer using 'cd' in a subshell instead of using pushd / popd
> because with the former approach the old working directory is restored no
> matter how the exit from the subshell happens.

Ah, right, I didn't pay enough attention to the cd. In that case, I'd
prefer not doing the cd at all. Something like:

configure_null_blk() {
	local nullb0="/sys/kernel/config/nullb/nullb0"
	mkdir -p "$nullb0" &&
	echo 0 > "$nullb0/completion_nsec" &&
	echo 512 > "$nullb0/blocksize" &&
	echo 16 > "$nullb0/size" &&
	echo 1 > "$nullb0/memory_backed" &&
	echo 1 > "$nullb0/power" &&
	ls -l /dev/nullb* &>>"$FULL"
}

> > > +modify_nr_hw_queues() {
> > > +	local deadline num_cpus
> > > +
> > > +	deadline=$(($(_uptime_s) + TIMEOUT))
> > > +	num_cpus=$(find /sys/devices/system/cpu -maxdepth 1 -name 'cpu[0-9]*' |
> > > +			   wc -l)
> > 
> > Please just use nproc. Or even better, can you just read the original
> > value of /sys/kernel/config/nullb/nullb0/submit_queues? Or does that
> > start at 1?
> 
> I will have a closer look and see which alternative works best.

Thanks!

      reply	other threads:[~2019-10-24 17:58 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-21 22:57 [PATCH blktests 0/2] Add a test that triggers blk_mq_update_nr_hw_queues() Bart Van Assche
2019-10-21 22:57 ` [PATCH blktests 1/2] Move and rename uptime_s() Bart Van Assche
2019-10-22 17:55   ` Chaitanya Kulkarni
2019-10-24 17:27   ` Omar Sandoval
2019-10-24 17:41     ` Bart Van Assche
2019-10-24 17:44       ` Omar Sandoval
2019-10-21 22:57 ` [PATCH blktests 2/2] Add a test that triggers blk_mq_update_nr_hw_queues() Bart Van Assche
2019-10-22 17:59   ` Chaitanya Kulkarni
2019-10-24 17:42   ` Omar Sandoval
2019-10-24 17:55     ` Bart Van Assche
2019-10-24 17:58       ` Omar Sandoval [this message]

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=20191024175848.GD137052@vader \
    --to=osandov@osandov.com \
    --cc=bvanassche@acm.org \
    --cc=jthumshirn@suse.de \
    --cc=linux-block@vger.kernel.org \
    --cc=osandov@fb.com \
    /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.