From: "Benoît Canet" <benoit@irqsave.net>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, wuzhy@linux.vnet.ibm.com,
"Benoît Canet" <benoit@irqsave.net>,
stefanha@redhat.com
Subject: [Qemu-devel] [PATCH] Fix I/O throttling pathologic oscillating behavior
Date: Wed, 20 Mar 2013 10:12:13 +0100 [thread overview]
Message-ID: <1363770734-30970-1-git-send-email-benoit@irqsave.net> (raw)
Limiting a virtio device backed by a QED file at 150 iops with
"-drive file=test.qed,if=virtio,cache=none,iops=150" and running in the guest
the load.c program lead to an iops oscillating behavior which amplify itself
as the time goes on.
At first an extract of "iostats -x -d 2" would look like this:
Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz
vdb 0,00 4,11 0,10 149,09 0,39 614,02 8,24
vdb 0,00 0,00 0,00 163,27 0,00 653,06 8,00
vdb 0,00 0,00 0,00 164,65 0,00 658,59 8,00
vdb 0,00 0,00 0,00 84,85 0,00 339,39 8,00
vdb 0,00 0,00 0,00 170,71 0,00 682,83 8,00
vdb 0,00 0,00 0,00 185,71 0,00 742,86 8,00
vdb 0,00 0,00 0,00 174,75 0,00 698,99 8,00
vdb 0,00 0,00 0,00 87,88 0,00 351,52 8,00
w/s seems ok
After a few moment it would look like this:
Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz
vdb 0,00 0,00 0,00 249,00 0,00 996,00 8,00
vdb 0,00 0,00 0,00 0,00 0,00 0,00 0,00
vdb 0,00 0,00 0,00 260,00 0,00 1040,00 8,00
vdb 0,00 0,00 0,00 0,00 0,00 0,00 0,00
vdb 0,00 0,00 0,00 250,00 0,00 1000,00 8,00
vdb 0,00 0,00 0,00 249,49 0,00 997,98 8,00
vdb 0,00 0,00 0,00 0,00 0,00 0,00 0,00
Here w/s start to oscillate on a few second cycle.
Waiting around ten hours leads to this.
Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz
db 0,00 0,00 0,00 0,00 0,00 0,00 0,00
vdb 0,00 0,00 0,00 267,68 0,00 1070,71 8,00
vdb 0,00 0,00 0,00 1184,38 0,00 4737,50 8,00
vdb 0,00 0,00 0,00 0,00 0,00 0,00 0,00
vdb 0,00 0,00 0,00 0,00 0,00 0,00 0,00
vdb 0,00 0,00 0,00 0,00 0,00 0,00 0,00
vdb 0,00 0,00 0,00 0,00 0,00 0,00 0,00
vdb 0,00 0,00 0,00 0,00 0,00 0,00 0,00
vdb 0,00 0,00 0,00 0,00 0,00 0,00 0,00
vdb 0,00 0,00 0,00 0,00 0,00 0,00 0,00
vdb 0,00 0,00 0,00 0,00 0,00 0,00 0,00
vdb 0,00 0,00 0,00 1415,15 0,00 5660,61 8,00
vdb 0,00 0,00 0,00 0,00 0,00 0,00 0,00
vdb 0,00 0,00 0,00 0,00 0,00 0,00 0,00
vdb 0,00 0,00 0,00 0,00 0,00 0,00 0,00
vdb 0,00 0,00 0,00 0,00 0,00 0,00 0,00
vdb 0,00 0,00 0,00 0,00 0,00 0,00 0,00
vdb 0,00 0,00 0,00 0,00 0,00 0,00 0,00
vdb 0,00 0,00 0,00 0,00 0,00 0,00 0,00
vdb 0,00 0,00 0,00 0,00 0,00 0,00 0,00
vdb 0,00 0,00 0,00 939,18 0,00 3756,70 8,00
vdb 0,00 0,00 0,00 523,71 0,00 2094,85 8,00
It seems to get worse with the amplitude and duration of the cycle growing.
As the cause of the amplification of the oscillation seems to be the growing of
the cycle duration I wrote the "block: fix bdrv_exceed_iops_limits wait
computation" patch which solve this problem.
load.c - beware of hardcoded "/dev/vdb"
-------------------------------------------------------------------------------
#define _GNU_SOURCE
#include <pthread.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#define BLOCKSIZE 4096
#define THREAD_COUNT 50
#define IOS 100000
pthread_mutex_t mutex;
pthread_cond_t condition;
void *io_thread_body(void *opaque)
{
int j, fd;
int i = (int) *(int *) opaque;
void *buffer;
posix_memalign(&buffer, BLOCKSIZE, BLOCKSIZE);
fd = open("/dev/vdb", O_RDWR|O_DIRECT);
if (fd < 0) {
printf("Fail to open /dev/vdb in O_DIRECT\n");
goto exit;
}
printf("Waiting for signal\n");
pthread_mutex_lock(&mutex);
pthread_cond_wait(&condition, &mutex);
pthread_mutex_unlock(&mutex);
printf("Starting ios\n");
while (1) {
off_t offset = (i * IOS * BLOCKSIZE) + j * BLOCKSIZE;
pwrite(fd, buffer, BLOCKSIZE, offset);
j++;
}
exit:
free(opaque);
pthread_exit(NULL);
}
int main(int argc, char **argv)
{
int i;
pthread_t threads[THREAD_COUNT];
pthread_attr_t attr;
pthread_mutex_init(&mutex, NULL);
pthread_cond_init(&condition, NULL);
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
printf("Creating threads\n");
for (i = 0; i < THREAD_COUNT; i++) {
int *j = malloc(sizeof(j));
*j = i;
pthread_create(&threads[i], &attr, io_thread_body, j);
}
sleep(1);
printf("Waking up threads\n");
pthread_cond_broadcast(&condition);
printf("Waiting threads to finish\n");
for (i = 0; i < THREAD_COUNT; i++) {
pthread_join(threads[i], NULL);
}
pthread_attr_destroy(&attr);
pthread_mutex_destroy(&mutex);
pthread_cond_destroy(&condition);
return 0;
}
-------------------------------------------------------------------------------
Benoît Canet (1):
block: fix bdrv_exceed_iops_limits wait computation
block.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--
1.7.10.4
next reply other threads:[~2013-03-20 9:11 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-20 9:12 Benoît Canet [this message]
2013-03-20 9:12 ` [Qemu-devel] [PATCH] block: fix bdrv_exceed_iops_limits wait computation Benoît Canet
2013-03-20 10:55 ` Zhi Yong Wu
2013-03-20 13:29 ` Stefan Hajnoczi
2013-03-20 14:28 ` Stefan Hajnoczi
2013-03-20 14:56 ` Benoît Canet
2013-03-20 15:12 ` Stefan Hajnoczi
2013-03-21 1:18 ` Zhi Yong Wu
2013-03-21 9:17 ` Stefan Hajnoczi
2013-03-21 13:04 ` Zhi Yong Wu
2013-03-21 15:14 ` Stefan Hajnoczi
2013-03-20 15:27 ` Benoît Canet
2013-03-21 10:34 ` Stefan Hajnoczi
2013-03-21 14:28 ` Benoît Canet
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=1363770734-30970-1-git-send-email-benoit@irqsave.net \
--to=benoit@irqsave.net \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=wuzhy@linux.vnet.ibm.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).