Re: [PATCH blktests 2/2] Add a test that triggers blk_mq_update_nr_hw_queues()

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

 



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.

+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.

Bart.



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux