Skip to contentSkip to conversation

libxl/qemu-xen: use cache=writeback for IDE and cache=none for SCSI

PATCH Superseded Stefano Stabellini 2 participants 6 messages Aug 14, 2012 – Sep 25, 2012

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxl/qemu-xen: use cache=writeback for IDE and cache=none for SCSI

tools/libxl/libxl_dm.c +4 -4
index 0c0084f..1c94e80 100644
@@ -549,10 +549,10 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc,
             if (disks[i].is_cdrom) {
                 if (disks[i].format == LIBXL_DISK_FORMAT_EMPTY)
                     drive = libxl__sprintf
-                        (gc, "if=ide,index=%d,media=cdrom", disk);
+                        (gc, "if=ide,index=%d,media=cdrom,cache=writeback", disk);
                 else
                     drive = libxl__sprintf
-                        (gc, "file=%s,if=ide,index=%d,media=cdrom,format=%s",
+                        (gc, "file=%s,if=ide,index=%d,media=cdrom,format=%s,cache=writeback",
                          disks[i].pdev_path, disk, format);
             } else {
                 if (disks[i].format == LIBXL_DISK_FORMAT_EMPTY) {
@@ -575,11 +575,11 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc,
                  */
                 if (strncmp(disks[i].vdev, "sd", 2) == 0)
                     drive = libxl__sprintf
-                        (gc, "file=%s,if=scsi,bus=0,unit=%d,format=%s",
+                        (gc, "file=%s,if=scsi,bus=0,unit=%d,format=%s,cache=none",
                          disks[i].pdev_path, disk, format);
                 else if (disk < 4)
                     drive = libxl__sprintf
-                        (gc, "file=%s,if=ide,index=%d,media=disk,format=%s",
+                        (gc, "file=%s,if=ide,index=%d,media=disk,format=%s,cache=writeback",
                          disks[i].pdev_path, disk, format);
                 else
                     continue; /* Do not emulate this disk */
#1 lore raw
Quoted 1 line · Stefano Stabellini

ping

Quoted 37 lines
tools/libxl/libxl_dm.c +4 -4
index 0c0084f..1c94e80 100644
@@ -549,10 +549,10 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc,
             if (disks[i].is_cdrom) {
                 if (disks[i].format == LIBXL_DISK_FORMAT_EMPTY)
                     drive = libxl__sprintf
-                        (gc, "if=ide,index=%d,media=cdrom", disk);
+                        (gc, "if=ide,index=%d,media=cdrom,cache=writeback", disk);
                 else
                     drive = libxl__sprintf
-                        (gc, "file=%s,if=ide,index=%d,media=cdrom,format=%s",
+                        (gc, "file=%s,if=ide,index=%d,media=cdrom,format=%s,cache=writeback",
                          disks[i].pdev_path, disk, format);
             } else {
                 if (disks[i].format == LIBXL_DISK_FORMAT_EMPTY) {
@@ -575,11 +575,11 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc,
                  */
                 if (strncmp(disks[i].vdev, "sd", 2) == 0)
                     drive = libxl__sprintf
-                        (gc, "file=%s,if=scsi,bus=0,unit=%d,format=%s",
+                        (gc, "file=%s,if=scsi,bus=0,unit=%d,format=%s,cache=none",
                          disks[i].pdev_path, disk, format);
                 else if (disk < 4)
                     drive = libxl__sprintf
-                        (gc, "file=%s,if=ide,index=%d,media=disk,format=%s",
+                        (gc, "file=%s,if=ide,index=%d,media=disk,format=%s,cache=writeback",
                          disks[i].pdev_path, disk, format);
                 else
                     continue; /* Do not emulate this disk */

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#2 lore raw
Quoted 4 lines · Stefano Stabellini
Quoted 1 line · Stefano Stabellini

ping

Is this an appropriate change during rcs, is it critical for 4.2 or should it wait for 4.3?

I think the changelog here is rather lacking, which makes it hard for me to decide what to do. e.g. the usual stuff: Why are you making this change? What is the impact? etc

What is the default for all these cases?

Quoted 10 lines

tools/libxl/libxl_dm.c static char ** libxl__build_device_model_args_new(libxl__gc *gc, · line 552

Quoted 10 lines
tools/libxl/libxl_dm.c +1 -1
index 0c0084f..1c94e80 100644
@@ -549,10 +549,10 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc,
             if (disks[i].is_cdrom) {
                 if (disks[i].format == LIBXL_DISK_FORMAT_EMPTY)
                     drive = libxl__sprintf
-                        (gc, "if=ide,index=%d,media=cdrom", disk);
+                        (gc, "if=ide,index=%d,media=cdrom,cache=writeback", disk);

Why does the cacheability matter for an empty device?

Quoted 4 lines

tools/libxl/libxl_dm.c static char ** libxl__build_device_model_args_new(libxl__gc *gc, · line 555

Quoted 4 lines
tools/libxl/libxl_dm.c +1 -1
                 else
                     drive = libxl__sprintf
-                        (gc, "file=%s,if=ide,index=%d,media=cdrom,format=%s",
+                        (gc, "file=%s,if=ide,index=%d,media=cdrom,format=%s,cache=writeback",

Does writeback mean anything for a r/o device?

Quoted 6 lines
Quoted 6 lines
tools/libxl/libxl_dm.c +0 -0
                          disks[i].pdev_path, disk, format);
             } else {
                 if (disks[i].format == LIBXL_DISK_FORMAT_EMPTY) {
@@ -575,11 +575,11 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc,
                  */
                 if (strncmp(disks[i].vdev, "sd", 2) == 0)
Quoted 8 lines

tools/libxl/libxl_dm.c static char ** libxl__build_device_model_args_new(libxl__gc *gc, · line 582

Quoted 8 lines
tools/libxl/libxl_dm.c +2 -2
                     drive = libxl__sprintf
-                        (gc, "file=%s,if=scsi,bus=0,unit=%d,format=%s",
+                        (gc, "file=%s,if=scsi,bus=0,unit=%d,format=%s,cache=none",
                          disks[i].pdev_path, disk, format);
                 else if (disk < 4)
                     drive = libxl__sprintf
-                        (gc, "file=%s,if=ide,index=%d,media=disk,format=%s",
+                        (gc, "file=%s,if=ide,index=%d,media=disk,format=%s,cache=writeback",

Why is an SCSI disk treated differently to an IDE one wrt caching?

Ian.

#3 lore raw
Quoted 5 lines · Ian Campbell
Quoted 4 lines · Stefano Stabellini
Quoted 1 line · Stefano Stabellini

ping

pong?

Quoted 54 lines

Is this an appropriate change during rcs, is it critical for 4.2 or should it wait for 4.3?

I think the changelog here is rather lacking, which makes it hard for me to decide what to do. e.g. the usual stuff: Why are you making this change? What is the impact? etc

What is the default for all these cases?

Quoted 10 lines

tools/libxl/libxl_dm.c static char ** libxl__build_device_model_args_new(libxl__gc *gc, · line 552

Quoted 10 lines
tools/libxl/libxl_dm.c +1 -1
index 0c0084f..1c94e80 100644
@@ -549,10 +549,10 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc,
             if (disks[i].is_cdrom) {
                 if (disks[i].format == LIBXL_DISK_FORMAT_EMPTY)
                     drive = libxl__sprintf
-                        (gc, "if=ide,index=%d,media=cdrom", disk);
+                        (gc, "if=ide,index=%d,media=cdrom,cache=writeback", disk);

Why does the cacheability matter for an empty device?

Quoted 4 lines

tools/libxl/libxl_dm.c static char ** libxl__build_device_model_args_new(libxl__gc *gc, · line 555

Quoted 4 lines
tools/libxl/libxl_dm.c +1 -1
                 else
                     drive = libxl__sprintf
-                        (gc, "file=%s,if=ide,index=%d,media=cdrom,format=%s",
+                        (gc, "file=%s,if=ide,index=%d,media=cdrom,format=%s,cache=writeback",

Does writeback mean anything for a r/o device?

Quoted 6 lines
Quoted 6 lines
tools/libxl/libxl_dm.c +0 -0
                          disks[i].pdev_path, disk, format);
             } else {
                 if (disks[i].format == LIBXL_DISK_FORMAT_EMPTY) {
@@ -575,11 +575,11 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc,
                  */
                 if (strncmp(disks[i].vdev, "sd", 2) == 0)
Quoted 8 lines

tools/libxl/libxl_dm.c static char ** libxl__build_device_model_args_new(libxl__gc *gc, · line 582

Quoted 8 lines
tools/libxl/libxl_dm.c +2 -2
                     drive = libxl__sprintf
-                        (gc, "file=%s,if=scsi,bus=0,unit=%d,format=%s",
+                        (gc, "file=%s,if=scsi,bus=0,unit=%d,format=%s,cache=none",
                          disks[i].pdev_path, disk, format);
                 else if (disk < 4)
                     drive = libxl__sprintf
-                        (gc, "file=%s,if=ide,index=%d,media=disk,format=%s",
+                        (gc, "file=%s,if=ide,index=%d,media=disk,format=%s,cache=writeback",

Why is an SCSI disk treated differently to an IDE one wrt caching?

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#4 lore raw
In reply to Ian Campbell

I found this email in my draft mailbox, I must have forgotten to send it.

Quoted 8 lines · Ian Campbell
Quoted 4 lines · Stefano Stabellini
Quoted 1 line · Stefano Stabellini

ping

Is this an appropriate change during rcs, is it critical for 4.2 or should it wait for 4.3?

It should go in one of the 4.2.x releases.

Quoted 3 lines

I think the changelog here is rather lacking, which makes it hard for me to decide what to do. e.g. the usual stuff: Why are you making this change? What is the impact? etc

This patch makes QEMU upstream behave like QEMU traditional, that changed behavior at the same time this patch was sent (effd5676225761abdab90becac519716515c3be4).

Quoted 1 line

What is the default for all these cases?

The default is writethrough, that is very slow.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
tools/libxl/libxl_dm.c +0 -0
index 0c0084f..1c94e80 100644
Quoted 8 lines
Quoted 6 lines

tools/libxl/libxl_dm.c static char ** libxl__build_device_model_args_new(libxl__gc *gc, · line 552

Quoted 6 lines
tools/libxl/libxl_dm.c +1 -1
@@ -549,10 +549,10 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc,
             if (disks[i].is_cdrom) {
                 if (disks[i].format == LIBXL_DISK_FORMAT_EMPTY)
                     drive = libxl__sprintf
-                        (gc, "if=ide,index=%d,media=cdrom", disk);
+                        (gc, "if=ide,index=%d,media=cdrom,cache=writeback", disk);

Why does the cacheability matter for an empty device?

It doesn't but the default would stay the same when a cdrom is inserted (it is a property of the drive).

Quoted 6 lines
Quoted 4 lines

tools/libxl/libxl_dm.c static char ** libxl__build_device_model_args_new(libxl__gc *gc, · line 555

Quoted 4 lines
tools/libxl/libxl_dm.c +1 -1
                 else
                     drive = libxl__sprintf
-                        (gc, "file=%s,if=ide,index=%d,media=cdrom,format=%s",
+                        (gc, "file=%s,if=ide,index=%d,media=cdrom,format=%s,cache=writeback",

Does writeback mean anything for a r/o device?

I doesn't. Do you want me to resend without this hunk?

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
tools/libxl/libxl_dm.c +0 -1
                          disks[i].pdev_path, disk, format);
             } else {
                 if (disks[i].format == LIBXL_DISK_FORMAT_EMPTY) {
@@ -575,11 +575,11 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc,
                  */
                 if (strncmp(disks[i].vdev, "sd", 2) == 0)
                     drive = libxl__sprintf
-                        (gc, "file=%s,if=scsi,bus=0,unit=%d,format=%s",
Quoted 9 lines
Quoted 6 lines

tools/libxl/libxl_dm.c static char ** libxl__build_device_model_args_new(libxl__gc *gc, · line 582

Quoted 6 lines
tools/libxl/libxl_dm.c +2 -1
+                        (gc, "file=%s,if=scsi,bus=0,unit=%d,format=%s,cache=none",
                          disks[i].pdev_path, disk, format);
                 else if (disk < 4)
                     drive = libxl__sprintf
-                        (gc, "file=%s,if=ide,index=%d,media=disk,format=%s",
+                        (gc, "file=%s,if=ide,index=%d,media=disk,format=%s,cache=writeback",

Why is an SCSI disk treated differently to an IDE one wrt caching?

We chose writeback for IDE because IDE has an explicit flush command that the guest is going to issue when it wants the data to reach the disk. At that point we can do a datasync on the filesystem.
I don't know enough about SCSI to be sure that is the case there as well, so I wanted to stay on the safe side and chose cache=none instead (that means O_DIRECT).

#5 lore raw
Quoted 15 lines · Stefano Stabellini

I found this email in my draft mailbox, I must have forgotten to send it.

Quoted 8 lines · Ian Campbell
Quoted 4 lines · Stefano Stabellini
Quoted 1 line · Stefano Stabellini

ping

Is this an appropriate change during rcs, is it critical for 4.2 or should it wait for 4.3?

It should go in one of the 4.2.x releases.

Quoted 7 lines
Quoted 3 lines

I think the changelog here is rather lacking, which makes it hard for me to decide what to do. e.g. the usual stuff: Why are you making this change? What is the impact? etc

This patch makes QEMU upstream behave like QEMU traditional, that changed behavior at the same time this patch was sent (effd5676225761abdab90becac519716515c3be4).

Thanks, please can duplicate most of that commit message here as well please, in particular the reference the ML thread. A reference to the trad commit ID might be useful too.

Quoted 3 lines
Quoted 1 line

What is the default for all these cases?

The default is writethrough, that is very slow.

Say "change caching mode from writethrough to writeback" in the commit message? Mention that this is a performance issue.

Quoted 14 lines
Quoted 13 lines
Quoted 11 lines

tools/libxl/libxl_dm.c static char ** libxl__build_device_model_args_new(libxl__gc *gc, · line 552

Quoted 11 lines
tools/libxl/libxl_dm.c +1 -1
index 0c0084f..1c94e80 100644
@@ -549,10 +549,10 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc,
             if (disks[i].is_cdrom) {
                 if (disks[i].format == LIBXL_DISK_FORMAT_EMPTY)
                     drive = libxl__sprintf
-                        (gc, "if=ide,index=%d,media=cdrom", disk);
+                        (gc, "if=ide,index=%d,media=cdrom,cache=writeback", disk);

Why does the cacheability matter for an empty device?

Quoted 2 lines

It doesn't but the default would stay the same when a cdrom is inserted (it is a property of the drive).

OK.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

tools/libxl/libxl_dm.c static char ** libxl__build_device_model_args_new(libxl__gc *gc, · line 555

Quoted 4 lines
tools/libxl/libxl_dm.c +1 -1
                 else
                     drive = libxl__sprintf
-                        (gc, "file=%s,if=ide,index=%d,media=cdrom,format=%s",
+                        (gc, "file=%s,if=ide,index=%d,media=cdrom,format=%s,cache=writeback",

Does writeback mean anything for a r/o device?

I doesn't. Do you want me to resend without this hunk?

Up to you. I guess it is at least consistent with the other devices. (it feels like this same line is repeated a lot, but lets not tackle that here)

Quoted 18 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
tools/libxl/libxl_dm.c +0 -1
                          disks[i].pdev_path, disk, format);
             } else {
                 if (disks[i].format == LIBXL_DISK_FORMAT_EMPTY) {
@@ -575,11 +575,11 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc,
                  */
                 if (strncmp(disks[i].vdev, "sd", 2) == 0)
                     drive = libxl__sprintf
-                        (gc, "file=%s,if=scsi,bus=0,unit=%d,format=%s",
Quoted 9 lines
Quoted 6 lines

tools/libxl/libxl_dm.c static char ** libxl__build_device_model_args_new(libxl__gc *gc, · line 582

Quoted 6 lines
tools/libxl/libxl_dm.c +2 -1
+                        (gc, "file=%s,if=scsi,bus=0,unit=%d,format=%s,cache=none",
                          disks[i].pdev_path, disk, format);
                 else if (disk < 4)
                     drive = libxl__sprintf
-                        (gc, "file=%s,if=ide,index=%d,media=disk,format=%s",
+                        (gc, "file=%s,if=ide,index=%d,media=disk,format=%s,cache=writeback",

Why is an SCSI disk treated differently to an IDE one wrt caching?

Quoted 6 lines

We chose writeback for IDE because IDE has an explicit flush command that the guest is going to issue when it wants the data to reach the disk. At that point we can do a datasync on the filesystem.
I don't know enough about SCSI to be sure that is the case there as well, so I wanted to stay on the safe side and chose cache=none instead (that means O_DIRECT).

I'm pretty sure SCSI must have an explicit flush command as well although it might be nice if someone could confirm. And also check that qemu actually flushes...

Ian.