[PATCH 3/3] nvme: add test for controller rescan under I/O load
Martin Wilck
mwilck at suse.com
Fri Aug 23 07:49:49 PDT 2024
On Fri, 2024-08-23 at 15:48 +0530, Nilay Shroff wrote:
>
> On 8/23/24 01:08, Martin Wilck wrote:
> >
> > + finish=$(($(date +%s) + TIMEOUT))
> > + while [[ $(date +%s) -le $finish ]]; do
> > + # sleep interval between 0.1 and 5s
> > + usleep "$(((RANDOM%50 + 1)*100000))"
> > + echo 1 >"$1/rescan_controller"
> > + done
> > +}
> I think here usleep may not be available by default on all systems.
> For instance, on fedora/rhel I don't have usleep installed in the
> defualt configuration and so I have to first install it. So you may
> want to add "usleep" as per-requisite for this test. Moreover, after
> I installed usleep on fedora and ran the above test I see this
> warning:
>
> warning: usleep is deprecated, and will be removed in near future!
>
> Due to above warning the test fails. So is it possible to replace
> usleep with sleep?
The README states that blktests requires GNU coreutils, so yes, that
would be feasible - in principle.
The problem is that bash can't do floating point math, and I want to
be able to sleep for fractions of a second. So I'd need to do something
like this:
usleep() {
sleep "$(awk "BEGIN { print $1 / 1.e6; }" </dev/null)"
}
But the fork-and-exec to "awk" is slow. millisecond sleep times can't
be realized this way. Anyway, I realize that calling "usleep" also
carries a lot of overhead, and thus "usleep 1000" doesn't do what one
would naïvely expect, either.
The only way I can see to make this work as originally intended is to
implement is as an awk script. The README says that GNU awk is
required, so sleep() with floating point argument is available.
Thanks
Martin
More information about the Linux-nvme
mailing list