pvsync2: Add hipri_percentage option
authorStephen Bates <sbates@raithlin.com>
Thu, 27 Jul 2017 20:02:15 +0000 (14:02 -0600)
committerJens Axboe <axboe@kernel.dk>
Thu, 27 Jul 2017 20:12:42 +0000 (14:12 -0600)
Allow the user to set the probability of a pvsync2 IO being high
priority. Add a new option for the pvsync2 engine called
--hipri_percentage will takes values in the range (0, 100) and use
that as a probability for setting RWF_HIPRI. The default for this
option is 100 so exisiting users of --hirpi are unaffected.

Changes since v3:
  Remove unwanted #ifdefs

Changes since v2:
  s/_probability/_percentage/

Changes since v1:
  Use --hipri_probability rather than impacting --hipri
  Correct the random number generator call

Signed-off-by: Stephen Bates <sbates@raithlin.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
HOWTO
engines/sync.c
fio.1

diff --git a/HOWTO b/HOWTO
index fe5c3cb193e9172275e0df47730158309fd33e5b..caf6591a41c1772edd1f71305ba52c62460ccff6 100644 (file)
--- a/HOWTO
+++ b/HOWTO
@@ -1819,6 +1819,11 @@ caveat that when used on the command line, they must come after the
        Set RWF_HIPRI on I/O, indicating to the kernel that it's of higher priority
        than normal.
 
        Set RWF_HIPRI on I/O, indicating to the kernel that it's of higher priority
        than normal.
 
+.. option:: hipri_percentage : [pvsync2]
+
+       When hipri is set this determines the probability of a pvsync2 IO being high
+       priority. The default is 100%.
+
 .. option:: cpuload=int : [cpuio]
 
        Attempt to use the specified percentage of CPU cycles. This is a mandatory
 .. option:: cpuload=int : [cpuio]
 
        Attempt to use the specified percentage of CPU cycles. This is a mandatory
index e76bbbb49e237b807c855d74dd0e40995ef7c0ad..26b98b60e2c7896e846c6b0daa2a1ad138b8b6fb 100644 (file)
@@ -14,6 +14,7 @@
 
 #include "../fio.h"
 #include "../optgroup.h"
 
 #include "../fio.h"
 #include "../optgroup.h"
+#include "../lib/rand.h"
 
 /*
  * Sync engine uses engine_data to store last offset
 
 /*
  * Sync engine uses engine_data to store last offset
@@ -30,12 +31,15 @@ struct syncio_data {
        unsigned long long last_offset;
        struct fio_file *last_file;
        enum fio_ddir last_ddir;
        unsigned long long last_offset;
        struct fio_file *last_file;
        enum fio_ddir last_ddir;
+
+       struct frand_state rand_state;
 };
 
 #ifdef FIO_HAVE_PWRITEV2
 struct psyncv2_options {
        void *pad;
        unsigned int hipri;
 };
 
 #ifdef FIO_HAVE_PWRITEV2
 struct psyncv2_options {
        void *pad;
        unsigned int hipri;
+       unsigned int hipri_percentage;
 };
 
 static struct fio_option options[] = {
 };
 
 static struct fio_option options[] = {
@@ -48,6 +52,18 @@ static struct fio_option options[] = {
                .category = FIO_OPT_C_ENGINE,
                .group  = FIO_OPT_G_INVALID,
        },
                .category = FIO_OPT_C_ENGINE,
                .group  = FIO_OPT_G_INVALID,
        },
+       {
+               .name   = "hipri_percentage",
+               .lname  = "RWF_HIPRI_PERCENTAGE",
+               .type   = FIO_OPT_INT,
+               .off1   = offsetof(struct psyncv2_options, hipri_percentage),
+               .minval = 0,
+               .maxval = 100,
+               .def    = "100",
+               .help   = "Probabilistically set RWF_HIPRI for pwritev2/preadv2",
+               .category = FIO_OPT_C_ENGINE,
+               .group  = FIO_OPT_G_INVALID,
+       },
        {
                .name   = NULL,
        },
        {
                .name   = NULL,
        },
@@ -132,7 +148,8 @@ static int fio_pvsyncio2_queue(struct thread_data *td, struct io_u *io_u)
 
        fio_ro_check(td, io_u);
 
 
        fio_ro_check(td, io_u);
 
-       if (o->hipri)
+       if (o->hipri &&
+           (rand32_between(&sd->rand_state, 1, 100) <= o->hipri_percentage))
                flags |= RWF_HIPRI;
 
        iov->iov_base = io_u->xfer_buf;
                flags |= RWF_HIPRI;
 
        iov->iov_base = io_u->xfer_buf;
@@ -363,6 +380,7 @@ static int fio_vsyncio_init(struct thread_data *td)
        sd->last_offset = -1ULL;
        sd->iovecs = malloc(td->o.iodepth * sizeof(struct iovec));
        sd->io_us = malloc(td->o.iodepth * sizeof(struct io_u *));
        sd->last_offset = -1ULL;
        sd->iovecs = malloc(td->o.iodepth * sizeof(struct iovec));
        sd->io_us = malloc(td->o.iodepth * sizeof(struct io_u *));
+       init_rand(&sd->rand_state, 0);
 
        td->io_ops_data = sd;
        return 0;
 
        td->io_ops_data = sd;
        return 0;
diff --git a/fio.1 b/fio.1
index f86b7fdf65c0c3b7d1df40f09206325101b94477..a5ec19992625e4ae4e5c4091d2190f0e9d9a4096 100644 (file)
--- a/fio.1
+++ b/fio.1
@@ -2018,6 +2018,10 @@ iodepth_batch_complete=0).
 Set RWF_HIPRI on IO, indicating to the kernel that it's of
 higher priority than normal.
 .TP
 Set RWF_HIPRI on IO, indicating to the kernel that it's of
 higher priority than normal.
 .TP
+.BI (pvsync2)hipri_percentage
+When hipri is set this determines the probability of a pvsync2 IO being high
+priority. The default is 100%.
+.TP
 .BI (net,netsplice)hostname \fR=\fPstr
 The host name or IP address to use for TCP or UDP based IO.
 If the job is a TCP listener or UDP reader, the hostname is not
 .BI (net,netsplice)hostname \fR=\fPstr
 The host name or IP address to use for TCP or UDP based IO.
 If the job is a TCP listener or UDP reader, the hostname is not