From: Bart Van Assche <bvanassche@acm.org>
To: Douglas Gilbert <dgilbert@interlog.com>, linux-scsi@vger.kernel.org
Cc: martin.petersen@oracle.com, hare@suse.de
Subject: Re: [PATCH v2] scsi_debug: randomize command duration option + %p
Date: Mon, 30 Sep 2019 08:46:59 -0700 [thread overview]
Message-ID: <743e705b-1314-c8cb-1a75-acc5029ee890@acm.org> (raw)
In-Reply-To: <20190927140425.18958-1-dgilbert@interlog.com>
On 9/27/19 7:04 AM, Douglas Gilbert wrote:
> Add an option to use the given command delay (in nanoseconds)
> as the upper limit for command durations. A pseudo random
> number generator chooses each duration from the range:
> [0..delay_in_ns)
>
> Main benefit: allows testing with out-of-order responses.
Please clarify which code you want to test. I think out-of-order
response handling in the SCSI core and block layer core is already being
triggered by many storage workloads.
> @@ -4354,9 +4357,21 @@ static int schedule_resp(struct scsi_cmnd *cmnd, struct sdebug_dev_info *devip,
> ktime_t kt;
>
> if (delta_jiff > 0) {
> - kt = ns_to_ktime((u64)delta_jiff * (NSEC_PER_SEC / HZ));
> - } else
> - kt = ndelay;
> + u64 ns = (u64)delta_jiff * (NSEC_PER_SEC / HZ);
Has it been considered to use jiffies_to_nsecs() instead of open-coding
that function?
> + if (sdebug_random && ns < U32_MAX) {
> + ns = prandom_u32_max((u32)ns);
> + } else if (sdebug_random) {
> + ns >>= 10; /* divide by 1024 */
> + if (ns < U32_MAX) /* an hour and a bit */
> + ns = prandom_u32_max((u32)ns);
> + ns <<= 10;
> + }
> + kt = ns_to_ktime(ns);
Is it really necessary to use nanosecond resolution? Can the above code
be simplified by using microseconds as time unit instead of nanoseconds?
> +MODULE_PARM_DESC(random, "1-> command duration chosen from [0..delay_in_ns) (def=0)");
Would this description become more clear if it would be changed into
something like the following: "If set, uniformly randomize command
duration between 0 and delay_in_ns" ?
> +static ssize_t random_show(struct device_driver *ddp, char *buf)
> +{
> + return scnprintf(buf, PAGE_SIZE, "%d\n", sdebug_random ? 1 : 0);
> +}
Since sdebug_random is either 0 or 1, is the "? 1 : 0" part necessary?
> +static ssize_t random_store(struct device_driver *ddp, const char *buf,
> + size_t count)
> +{
> + int n;
> +
> + if (count > 0 && 1 == sscanf(buf, "%d", &n) && n >= 0) {
> + sdebug_random = (n > 0);
> + return count;
> + }
> + return -EINVAL;
> +}
Has this patch been verified with checkpatch? I'm asking since
checkpatch should complain about "1 == sscanf(...)". See also commit
c5595fa2f1ce ("checkpatch: add constant comparison on left side test").
> @@ -5338,7 +5373,7 @@ static int __init scsi_debug_init(void)
> dif_size = sdebug_store_sectors * sizeof(struct t10_pi_tuple);
> dif_storep = vmalloc(dif_size);
>
> - pr_err("dif_storep %u bytes @ %p\n", dif_size, dif_storep);
> + pr_err("dif_storep %u bytes @ %pK\n", dif_size, dif_storep);
>
> if (dif_storep == NULL) {
> pr_err("out of mem. (DIX)\n");
Is it useful to print the kernel pointer 'dif_storep'?
Thanks,
Bart.
next prev parent reply other threads:[~2019-09-30 15:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-27 14:04 [PATCH v2] scsi_debug: randomize command duration option + %p Douglas Gilbert
2019-09-30 15:46 ` Bart Van Assche [this message]
2019-10-01 2:42 ` Douglas Gilbert
2019-10-01 4:28 ` Martin K. Petersen
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=743e705b-1314-c8cb-1a75-acc5029ee890@acm.org \
--to=bvanassche@acm.org \
--cc=dgilbert@interlog.com \
--cc=hare@suse.de \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).