throttle: improve command-line parameter documentation
v2 cover throttle: improve command-line parameter documentation
v2:
* Fixed s/bps/iops/ copy-paste error in Patch 1 [Berto]
* Rephrased warning about guest hangs and errors [Berto]
* Added Patch 2 to hide the internal .max value from the monitor
Patch 1 fleshes out the documentation for I/O throttling command-line parameters.
Patch 2 hides an internal value that was being exposed to users via the monitor and caused confusion.
I ended up not adding QMP-style throttling.* names to the command-line documentation because the names are very long and unlikely to be used. I couldn't see a nice way of adding them while still keeping the documentation readable.
Stefan Hajnoczi (2):
qemu-options: explain disk I/O throttling options
throttle: make throttle_config(throttle_get_config()) symmetric
tests/test-throttle.c | 8 ++++---- util/throttle.c | 16 ++++++++++++++++ qemu-options.hx | 24 ++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 4 deletions(-)
Signature · 1 line
2.9.3
PATCH v2 1/2 qemu-options: explain disk I/O throttling options
The disk I/O throttling options have been listed for a long time but never explained on the QEMU man page.
--- qemu-options.hx | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
qemu-options.hx +24 -0
@@ -587,6 +587,30 @@ file sectors into the image file. conversion of plain zero writes by the OS to driver specific optimized zero write commands. You may even choose "unmap" if @var{discard} is set to "unmap" to allow a zero write to be converted to an UNMAP operation. +@item bps=@var{b},bps_rd=@var{r},bps_wr=@var{w} +Specify bandwidth throttling limits in bytes per second, either for all request +types or for reads or writes only. Small values can lead to timeouts or hangs +inside the guest. A safe minimum for disks is 2 MB/s. +@item bps_max=@var{bm},bps_rd_max=@var{rm},bps_wr_max=@var{wm} +Specify bursts in bytes per second, either for all request types or for reads +or writes only. Bursts allow the guest I/O to spike above the limit +temporarily. +@item iops=@var{i},iops_rd=@var{r},iops_wr=@var{w} +Specify request rate limits in requests per second, either for all request +types or for reads or writes only. +@item iops_max=@var{bm},iops_rd_max=@var{rm},iops_wr_max=@var{wm} +Specify bursts in requests per second, either for all request types or for reads +or writes only. Bursts allow the guest I/O to spike above the limit +temporarily. +@item iops_size=@var{is} +Let every @var{is} bytes of a request count as a new request for iops +throttling purposes. Use this option to prevent guests from circumventing iops +limits by sending fewer but larger requests. +@item group=@var{g} +Join a throttling quota group with given name @var{g}. All drives that are +members of the same group are accounted for together. Use this option to +prevent guests from circumventing throttling limits by using many small disks +instead of a single larger disk. @end table By default, the @option{cache=writeback} mode is used. It will report data
Signature · 1 line
2.9.3
Re: [Qemu-devel] [PATCH v2 1/2] qemu-options: explain disk I/O throttling options
Quoted 6 lines · Stefan Hajnoczi
The disk I/O throttling options have been listed for a long time but never explained on the QEMU man page.
Suggested-by Nini Gu <[email protected]>Cc Alberto Garcia <[email protected]>Signed-off-by Stefan Hajnoczi <[email protected]>
Berto
PATCH v2 2/2 throttle: make throttle_config(throttle_get_config()) symmetric
In reply to Stefan HajnocziThrottling has a weird property that throttle_get_config() does not always return the same throttling settings that were given with throttle_config(). In other words, the set and get functions aren't symmetric.
If .max is 0 then the throttling code assigns a default value of .avg / 10 in throttle_config(). This is an implementation detail of the throttling algorithm. When throttle_get_config() is called the .max value returned should still be 0.
Users are exposed to this quirk via "info block" or "query-block" monitor commands. This has caused confusion because it looks like a bug when an unexpected value is reported.
This patch hides the .max value adjustment in throttle_get_config() and updates test-throttle.c appropriately.
--- tests/test-throttle.c | 8 ++++---- util/throttle.c | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-)
tests/test-throttle.c +4 -4
@@ -205,8 +205,8 @@ static void test_config_functions(void) orig_cfg.buckets[THROTTLE_OPS_READ ].avg =69 ; orig_cfg.buckets[THROTTLE_OPS_WRITE ].avg =23 ; - orig_cfg.buckets[THROTTLE_BPS_TOTAL ].max =0 ;/* should be corrected */ - orig_cfg.buckets[THROTTLE_BPS_READ ].max =1 ;/* should not be corrected */ + orig_cfg.buckets[THROTTLE_BPS_TOTAL ].max =0 ; + orig_cfg.buckets[THROTTLE_BPS_READ ].max =1 ; orig_cfg.buckets[THROTTLE_BPS_WRITE ].max =120 ; orig_cfg.buckets[THROTTLE_OPS_TOTAL ].max =150 ;
@@ -246,8 +246,8 @@ static void test_config_functions(void)g_assert (final_cfg.buckets[THROTTLE_OPS_READ ].avg ==69 );g_assert (final_cfg.buckets[THROTTLE_OPS_WRITE ].avg ==23 ); -g_assert (final_cfg.buckets[THROTTLE_BPS_TOTAL ].max ==15.3 );/* fixed */ -g_assert (final_cfg.buckets[THROTTLE_BPS_READ ].max ==1 );/* not fixed */ +g_assert (final_cfg.buckets[THROTTLE_BPS_TOTAL ].max ==0 ); +g_assert (final_cfg.buckets[THROTTLE_BPS_READ ].max ==1 );g_assert (final_cfg.buckets[THROTTLE_BPS_WRITE ].max ==120 );g_assert (final_cfg.buckets[THROTTLE_OPS_TOTAL ].max ==150 );
util/throttle.c +16 -0
@@ -380,6 +380,16 @@ static void throttle_fix_bucket(LeakyBucket *bkt) } } +/* undo internal bucket parameter changes (see throttle_fix_bucket()) */ +static void throttle_unfix_bucket (LeakyBucket *bkt) +{ +double min = bkt->avg /10 ; + +if (bkt->max == min) { + bkt->max =0 ; + } +} +/* take care of canceling a timer */ static void throttle_cancel_timer (QEMUTimer *timer) {
@@ -420,7 +430,13 @@ void throttle_config(ThrottleState *ts,*/ void throttle_get_config (ThrottleState *ts,ThrottleConfig *cfg) { +int i; + *cfg = ts->cfg; + +for (i =0 ; i <BUCKETS_COUNT ; i++) { +throttle_unfix_bucket (&cfg->buckets[i]); + } }
Signature · 1 line
2.9.3
Re: [Qemu-devel] [PATCH v2 2/2] throttle: make throttle_config(throttle_get_config()) symmetric
util/throttle.c static void throttle_fix_bucket(LeakyBucket *bkt) · line 391
Quoted 9 lines · Stefan Hajnoczi
util/throttle.c +9
-0+/* undo internal bucket parameter changes (see throttle_fix_bucket()) */ +static void throttle_unfix_bucket (LeakyBucket *bkt) +{ +double min = bkt->avg /10 ; + +if (bkt->max == min) { + bkt->max =0 ; + } +}
I guess you could do the more general if (bkt->max < bkt->avg), but your solution is also fine with me.
Berto
Re: [Qemu-devel] [Qemu-block] [PATCH v2 2/2] throttle: make throttle_config(throttle_get_config()) symmetric
Quoted 14 lines · Alberto Garcia
util/throttle.c static void throttle_fix_bucket(LeakyBucket *bkt) · line 391
Quoted 9 lines · Stefan Hajnoczi
util/throttle.c +9
-0+/* undo internal bucket parameter changes (see throttle_fix_bucket()) */ +static void throttle_unfix_bucket (LeakyBucket *bkt) +{ +double min = bkt->avg /10 ; + +if (bkt->max == min) { + bkt->max =0 ; + } +}I guess you could do the more general if (
bkt->max<bkt->avg), but your solution is also fine with me.
Quoted 1 line
Reviewed-by Alberto Garcia <[email protected]>
I did that originally because I try to avoid floating-point equality. The test case uses an invalid setting though (->max = 1, ->avg = 56) which would be rejected if given on the command-line.
Thinking about this again, it's probably better to modify the test case and use max < avg.
Will send a v3.
Stefan