Skip to content
Snippets Groups Projects
Commit 08b04e4a authored by Dmitry Fleytman's avatar Dmitry Fleytman Committed by Avi Kivity
Browse files

tests: test various buffer sizes in misc-bdev-write test


Xen block driver now supports new featute called indirect descriptors.
This feature allows to put more data into each ring cell but it activates
for "long" reads and writes only - longer than 11 pages.

With this patch test by default runs 2 scenarious:
  * 1 page buffers
  * 32 pages buffers

Also introduced command line parameter to specify
size of buffers explicitly.

Signed-off-by: default avatarDmitry Fleytman <dmitry@daynix.com>
Signed-off-by: default avatarAvi Kivity <avi@cloudius-systems.com>
parent 1e6cd8f7
No related branches found
No related tags found
No related merge requests found
......@@ -28,7 +28,7 @@ static void bio_done(struct bio* bio)
{
auto err = bio->bio_flags & BIO_ERROR;
bytes_written += bio->bio_bcount;
memory::free_page(bio->bio_data);
delete [] (char*) bio->bio_data;
destroy_bio(bio);
bio_inflights--;
if (err) {
......@@ -36,28 +36,10 @@ static void bio_done(struct bio* bio)
}
}
int main(int argc, char const *argv[])
void do_test_cycle(struct device *dev, int buf_size_pages, long max_offset)
{
struct device *dev;
if (argc < 2) {
printf("Usage: %s <dev-name>\n", argv[0]);
return 1;
}
if (device_open(argv[1], DO_RDWR, &dev)) {
printf("open failed\n");
return 1;
}
long max_offset = 0;
if (argc > 2) {
max_offset = atol(argv[2]);
}
printf("bdev-write test offset limit: %ld byte(s)\n", max_offset);
const std::chrono::seconds test_duration(10);
const int buf_size = 4*KB;
const int buf_size = buf_size_pages * memory::page_size;
long total = 0;
long offset = 0;
......@@ -65,6 +47,8 @@ int main(int argc, char const *argv[])
auto test_start = s_clock.now();
auto end_at = test_start + test_duration;
printf("Testing with %d page(s) buffers:\n", buf_size_pages);
stat_printer _stat_printer(bytes_written, [] (float bytes_per_second) {
printf("%.3f Mb/s\n", (float)bytes_per_second / MB);
}, 1000);
......@@ -74,7 +58,7 @@ int main(int argc, char const *argv[])
bio_inflights++;
bio->bio_cmd = BIO_WRITE;
bio->bio_dev = dev;
bio->bio_data = memory::alloc_page();
bio->bio_data = new char[buf_size];
bio->bio_offset = offset;
bio->bio_bcount = buf_size;
bio->bio_caller1 = bio;
......@@ -97,7 +81,42 @@ int main(int argc, char const *argv[])
_stat_printer.stop();
auto actual_test_duration = to_seconds(test_end - test_start);
printf("Wrote %.3f MB in %.2f s = %.3f Mb/s\n", (double) total / MB, actual_test_duration,
(double) total / MB / actual_test_duration);
printf("Wrote %.3f MB in %.2f s = %.3f Mb/s\n", (double) total / MB,
actual_test_duration, (double) total / MB / actual_test_duration);
}
int main(int argc, char const *argv[])
{
struct device *dev;
if (argc < 2) {
printf("Usage: %s <dev-name> [max-write-offset] "
"[buffer size in pages]\n", argv[0]);
return 1;
}
if (device_open(argv[1], DO_RDWR, &dev)) {
printf("open failed\n");
return 1;
}
long max_offset = 0;
if (argc > 2) {
max_offset = atol(argv[2]);
}
long buffer_size_pages = 0;
if (argc > 3) {
buffer_size_pages = atol(argv[3]);
}
printf("bdev-write test offset limit: %ld byte(s)\n", max_offset);
if (buffer_size_pages == 0) {
do_test_cycle(dev, 32, max_offset);
do_test_cycle(dev, 1, max_offset);
} else {
do_test_cycle(dev, buffer_size_pages, max_offset);
}
return 0;
}
\ No newline at end of file
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment