qemu-patch-raspberry4/include/qemu
Sascha Silbe f14a39ccb9 Improve block job rate limiting for small bandwidth values
ratelimit_calculate_delay() previously reset the accounting every time
slice, no matter how much data had been processed before. This had (at
least) two consequences:

1. The minimum speed is rather large, e.g. 5 MiB/s for commit and stream.

   Not sure if there are real-world use cases where this would be a
   problem. Mirroring and backup over a slow link (e.g. DSL) would
   come to mind, though.

2. Tests for block job operations (e.g. cancel) were rather racy

   All block jobs currently use a time slice of 100ms. That's a
   reasonable value to get smooth output during regular
   operation. However this also meant that the state of block jobs
   changed every 100ms, no matter how low the configured limit was. On
   busy hosts, qemu often transferred additional chunks until the test
   case had a chance to cancel the job.

Fix the block job rate limit code to delay for more than one time
slice to address the above issues. To make it easier to handle
oversized chunks we switch the semantics from returning a delay
_before_ the current request to a delay _after_ the current
request. If necessary, this delay consists of multiple time slice
units.

Since the mirror job sends multiple chunks in one go even if the rate
limit was exceeded in between, we need to keep track of the start of
the current time slice so we can correctly re-compute the delay for
the updated amount of data.

The minimum bandwidth now is 1 data unit per time slice. The block
jobs are currently passing the amount of data transferred in sectors
and using 100ms time slices, so this translates to 5120
bytes/second. With chunk sizes usually being O(512KiB), tests have
plenty of time (O(100s)) to operate on block jobs. The chance of a
race condition now is fairly remote, except possibly on insanely
loaded systems.

Signed-off-by: Sascha Silbe <silbe@linux.vnet.ibm.com>
Message-id: 1467127721-9564-2-git-send-email-silbe@linux.vnet.ibm.com
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
2016-07-13 13:41:38 +02:00
..
acl.h Clean up ill-advised or unusual header guards 2016-07-12 16:20:46 +02:00
atomic.h Clean up ill-advised or unusual header guards 2016-07-12 16:20:46 +02:00
base64.h Clean up ill-advised or unusual header guards 2016-07-12 16:20:46 +02:00
bcd.h Clean up decorations and whitespace around header guards 2016-07-12 16:20:46 +02:00
bitmap.h all: Remove unnecessary glib.h includes 2016-06-07 18:19:24 +03:00
bitops.h bitops: Add MAKE_64BIT_MASK macro 2016-07-04 13:15:22 +01:00
bswap.h bswap.h: Document cpu_to_* and *_to_cpu conversion functions 2016-07-12 15:08:53 +01:00
buffer.h Clean up ill-advised or unusual header guards 2016-07-12 16:20:46 +02:00
compatfd.h include: Clean up includes 2016-02-23 12:43:05 +00:00
compiler.h compiler.h: add QEMU_ALIGNED() to enforce struct alignment 2016-06-11 22:59:33 +00:00
config-file.h Clean up header guards that don't match their file name 2016-07-12 16:19:16 +02:00
coroutine.h coroutine: move entry argument to qemu_coroutine_create 2016-07-13 13:26:02 +02:00
coroutine_int.h coroutine: use QSIMPLEQ instead of QTAILQ 2016-07-13 13:26:02 +02:00
crc32c.h include/qemu/crc32c.h: Rename include guards to match filename 2014-02-26 17:20:07 +00:00
cutils.h Clean up decorations and whitespace around header guards 2016-07-12 16:20:46 +02:00
envlist.h misc: move include files to include/qemu/ 2012-12-19 08:32:39 +01:00
error-report.h Clean up header guards that don't match their file name 2016-07-12 16:19:16 +02:00
event_notifier.h event-notifier: Add "is_external" parameter 2016-04-22 16:43:56 +02:00
fifo8.h Clean up header guards that don't match their file name 2016-07-12 16:19:16 +02:00
fifo32.h hw: Clean up includes 2016-06-07 18:19:23 +03:00
fprintf-fn.h Clean up decorations and whitespace around header guards 2016-07-12 16:20:46 +02:00
hbitmap.h Clean up decorations and whitespace around header guards 2016-07-12 16:20:46 +02:00
help_option.h Clean up decorations and whitespace around header guards 2016-07-12 16:20:46 +02:00
host-utils.h Clean up decorations and whitespace around header guards 2016-07-12 16:20:46 +02:00
id.h Clean up decorations and whitespace around header guards 2016-07-12 16:20:46 +02:00
int128.h include: Clean up includes 2016-02-23 12:43:05 +00:00
iov.h include/qemu/iov.h: Don't include qemu-common.h 2016-03-22 22:20:16 +01:00
log.h log: Fix qemu_set_log_filename() error handling 2016-06-20 16:39:08 +02:00
main-loop.h coroutine: move entry argument to qemu_coroutine_create 2016-07-13 13:26:02 +02:00
memfd.h include: Clean up includes 2016-02-23 12:43:05 +00:00
mmap-alloc.h Clean up ill-advised or unusual header guards 2016-07-12 16:20:46 +02:00
module.h module: Rename machine_init() to opts_init() 2016-03-16 15:54:23 -03:00
notify.h notify: add NotiferWithReturn so notifier list can abort 2013-06-28 09:20:26 +02:00
option.h Clean up header guards that don't match their file name 2016-07-12 16:19:16 +02:00
option_int.h Clean up header guards that don't match their file name 2016-07-12 16:19:16 +02:00
osdep.h osdep: Introduce qemu_dup 2016-07-13 13:26:02 +02:00
path.h Clean up decorations and whitespace around header guards 2016-07-12 16:20:46 +02:00
processor.h include/processor.h: define cpu_relax() 2016-06-11 23:10:17 +00:00
qdist.h clean-includes: run it once more 2016-06-16 18:39:03 +02:00
qht.h clean-includes: run it once more 2016-06-16 18:39:03 +02:00
queue.h Clean up ill-advised or unusual header guards 2016-07-12 16:20:46 +02:00
range.h range: Replace internal representation of Range 2016-07-04 16:49:33 +03:00
ratelimit.h Improve block job rate limiting for small bandwidth values 2016-07-13 13:41:38 +02:00
rcu.h all: Remove unnecessary glib.h includes 2016-06-07 18:19:24 +03:00
rcu_queue.h Clean up decorations and whitespace around header guards 2016-07-12 16:20:46 +02:00
readline.h Clean up decorations and whitespace around header guards 2016-07-12 16:20:46 +02:00
rfifolock.h rfifolock: add recursive FIFO lock 2014-03-13 14:42:21 +01:00
seqlock.h Clean up decorations and whitespace around header guards 2016-07-12 16:20:46 +02:00
sockets.h Clean up header guards that don't match their file name 2016-07-12 16:19:16 +02:00
thread-posix.h Clean up ill-advised or unusual header guards 2016-07-12 16:20:46 +02:00
thread-win32.h Clean up ill-advised or unusual header guards 2016-07-12 16:20:46 +02:00
thread.h Clean up ill-advised or unusual header guards 2016-07-12 16:20:46 +02:00
throttle.h include: Clean up includes 2016-02-23 12:43:05 +00:00
timed-average.h include: Clean up includes 2016-02-23 12:43:05 +00:00
timer.h include: move CPU-related definitions out of qemu-common.h 2016-05-19 13:08:04 +02:00
typedefs.h migration: delete QEMUSizedBuffer struct 2016-05-26 11:31:58 +05:30
unicode.h Clean up decorations and whitespace around header guards 2016-07-12 16:20:46 +02:00
uri.h misc: move include files to include/qemu/ 2012-12-19 08:32:39 +01:00
xattr.h include: Clean up includes 2016-02-23 12:43:05 +00:00