Skip to contentSkip to conversation

xl: tsc_mode parameter in guest configuration file

PATCH In review Eric Chanudet 3 participants 7 messages Mar 29, 2010 – Mar 30, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xl: tsc_mode parameter in guest configuration file

This patch handle tsc_mode argument in guest configuration file.

tools/libxl/libxl.h +1 -0
@@ -74,6 +74,7 @@ typedef struct {
     int vpt_align;
     int max_vcpus;
     int cur_vcpus;
+    int tsc_mode;
     uint32_t max_memkb;
     uint32_t target_memkb;
     uint32_t video_memkb;
tools/libxl/libxl_dom.c +0 -0
@@ -176,7 +176,7 @@ int build_hvm(struct libxl_ctx *ctx, uin
     ret = hvm_build_set_params(ctx->xch, domid, info->u.hvm.apic,

info->u.hvm.acpi,

                                info->u.hvm.pae, info->u.hvm.nx,
info->u.hvm.viridian,
                                info->max_vcpus,
-                               state->store_port, &state->store_mfn);
+                               state->store_port, &state->store_mfn,
info->tsc_mode);
     if (ret) {
         XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, ret, "hvm build set params failed");
         return ERROR_FAIL;
tools/libxl/libxl_internal.h +0 -1
@@ -158,7 +158,7 @@ int libxl_device_pci_flr(struct libxl_ct
 /* from xenguest (helper */
 int hvm_build_set_params(int handle, uint32_t domid,
                          int apic, int acpi, int pae, int nx, int viridian,
-                         int vcpus, int store_evtchn, unsigned long

*store_mfn);
+ int vcpus, int store_evtchn, unsigned long
*store_mfn, int tsc_mode);

/* xl_exec */

tools/libxl/xenguest.c +1 -1
@@ -20,7 +20,7 @@
 
 int hvm_build_set_params(int handle, uint32_t domid,
                          int apic, int acpi, int pae, int nx, int viridian,
-                         int vcpus, int store_evtchn, unsigned long *store_mfn)
+                         int vcpus, int store_evtchn, unsigned long

*store_mfn, int tsc_mode)

 {
     struct hvm_info_table *va_hvm;
     uint8_t *va_map, sum;
@@ -47,5 +47,6 @@ int hvm_build_set_params(int handle, uin
     xc_set_hvm_param(handle, domid, HVM_PARAM_VIRIDIAN, viridian);
 #endif
     xc_set_hvm_param(handle, domid, HVM_PARAM_STORE_EVTCHN, store_evtchn);
+    xc_domain_set_tsc_info(handle, domid, tsc_mode, 0, 0, 0);
     return 0;

}

tools/libxl/xl.c +4 -0
@@ -235,6 +235,7 @@ static void printf_info(libxl_domain_cre
     printf("hpet: %d\n", b_info->hpet);
     printf("vpt_align: %d\n", b_info->vpt_align);
     printf("max_vcpus: %d\n", b_info->max_vcpus);
+    printf("tsc_mode: %d\n", b_info->tsc_mode);
     printf("max_memkb: %d\n", b_info->max_memkb);
     printf("target_memkb: %d\n", b_info->target_memkb);
     printf("kernel: %s\n", b_info->kernel);
@@ -382,6 +383,9 @@ static void parse_config_file(const char
         b_info->target_memkb = b_info->max_memkb;
     }
 
+    if (!xlu_cfg_get_long(config, "tsc_mode", &l))
+        b_info->tsc_mode = l;
+
     if (!xlu_cfg_get_long (config, "shadow_memory", &l))
         b_info->shadow_memkb = l * 1024;
 
Signature · 2 lines
Eric CHANUDET
XenClient Team
#1 lore raw

Hi Eric --

Sorry I don't know my way around xl source, so just checking:

The tsc_mode parameter is important for both HVM and PV. Looking through the patch, I see a lot of hvm changes. Does the patch also handle PV tsc_mode?

Thanks,
Dan

Quoted 108 lines

-----Original Message-----
From: Eric Chanudet [mailto:[email protected]]
Sent: Monday, March 29, 2010 6:35 AM
To: xen-devel
Subject: [Xen-devel] [PATCH] xl: tsc_mode parameter in guest configuration file

This patch handle tsc_mode argument in guest configuration file.

tools/libxl/libxl.h +1 -0
@@ -74,6 +74,7 @@ typedef struct {
     int vpt_align;
     int max_vcpus;
     int cur_vcpus;
+    int tsc_mode;
     uint32_t max_memkb;
     uint32_t target_memkb;
     uint32_t video_memkb;
tools/libxl/libxl_dom.c +1 -1
@@ -176,7 +176,7 @@ int build_hvm(struct libxl_ctx *ctx, uin
     ret = hvm_build_set_params(ctx->xch, domid, info->u.hvm.apic,
 info->u.hvm.acpi,
                                info->u.hvm.pae, info->u.hvm.nx,
 info->u.hvm.viridian,
                                info->max_vcpus,
-                               state->store_port, &state->store_mfn);
+                               state->store_port, &state->store_mfn,
 info->tsc_mode);

if (ret) {
XL_LOG_ERRNOVAL(ctx, XL_LOG_ERROR, ret, "hvm build set params

failed");
         return ERROR_FAIL;
tools/libxl/libxl_internal.h +1 -1
@@ -158,7 +158,7 @@ int libxl_device_pci_flr(struct libxl_ct
 /* from xenguest (helper */
 int hvm_build_set_params(int handle, uint32_t domid,
                          int apic, int acpi, int pae, int nx, int
 viridian,
-                         int vcpus, int store_evtchn, unsigned long
 *store_mfn);
+                         int vcpus, int store_evtchn, unsigned long
 *store_mfn, int tsc_mode);

/* xl_exec */

tools/libxl/xenguest.c +1 -1
@@ -20,7 +20,7 @@
 
 int hvm_build_set_params(int handle, uint32_t domid,
                          int apic, int acpi, int pae, int nx, int
 viridian,
-                         int vcpus, int store_evtchn, unsigned long
 *store_mfn)
+                         int vcpus, int store_evtchn, unsigned long
 *store_mfn, int tsc_mode)
 {
     struct hvm_info_table *va_hvm;
     uint8_t *va_map, sum;
tools/libxl/xenguest.c +1 -0
@@ -47,5 +47,6 @@ int hvm_build_set_params(int handle, uin
     xc_set_hvm_param(handle, domid, HVM_PARAM_VIRIDIAN, viridian);
 #endif
     xc_set_hvm_param(handle, domid, HVM_PARAM_STORE_EVTCHN,
 store_evtchn);
+    xc_domain_set_tsc_info(handle, domid, tsc_mode, 0, 0, 0);
     return 0;

}

tools/libxl/xl.c +4 -1
@@ -235,6 +235,7 @@ static void printf_info(libxl_domain_cre
     printf("hpet: %d\n", b_info->hpet);
     printf("vpt_align: %d\n", b_info->vpt_align);
     printf("max_vcpus: %d\n", b_info->max_vcpus);
+    printf("tsc_mode: %d\n", b_info->tsc_mode);
     printf("max_memkb: %d\n", b_info->max_memkb);
     printf("target_memkb: %d\n", b_info->target_memkb);
     printf("kernel: %s\n", b_info->kernel);
@@ -382,6 +383,9 @@ static void parse_config_file(const char
         b_info->target_memkb = b_info->max_memkb;
     }
 
+    if (!xlu_cfg_get_long(config, "tsc_mode", &l))
+        b_info->tsc_mode = l;
+
     if (!xlu_cfg_get_long (config, "shadow_memory", &l))
         b_info->shadow_memkb = l * 1024;
 
 
--

Eric CHANUDET
XenClient Team

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

#2 lore raw
Quoted 8 lines · Dan Magenheimer

Hi Eric --

Sorry I don't know my way around xl source, so just checking:

The tsc_mode parameter is important for both HVM and PV. Looking through the patch, I see a lot of hvm changes. Does the patch also handle PV tsc_mode?

Hi Dan,

I don't believe we ever did that, with seems wrong indeed. Thanks for pointing it out.

Eric, any chance you can move the tsc_mode call to build_pre (which is called by pv and hvm) and refresh the patch ?

Thanks,

Signature · 4 lines
Vincent

-- 
Vincent
author Acked-by Vincent Hanquez
#3 lore raw
Quoted 5 lines · Vincent Hanquez

I don't believe we ever did that, with seems wrong indeed. Thanks for pointing it out.

Eric, any chance you can move the tsc_mode call to build_pre (which is called by pv and hvm) and refresh the patch ?

Here is the new patch including these changes.

tools/libxl/libxl.h +1 -0
@@ -74,6 +74,7 @@ typedef struct {
     int vpt_align;
     int max_vcpus;
     int cur_vcpus;
+    int tsc_mode;
     uint32_t max_memkb;
     uint32_t target_memkb;
     uint32_t video_memkb;
tools/libxl/libxl_dom.c +1 -0
@@ -72,6 +72,7 @@ int build_pre(struct libxl_ctx *ctx, uin
     xc_domain_set_memmap_limit(ctx->xch, domid, 
             (info->hvm) ? info->max_memkb : 
             (info->max_memkb + info->u.pv.slack_memkb));
+    xc_domain_set_tsc_info(ctx->xch, domid, info->tsc_mode, 0, 0, 0);
 
     if (info->hvm) {
         unsigned long shadow;
tools/libxl/xl.c +4 -0
@@ -235,6 +235,7 @@ static void printf_info(libxl_domain_cre
     printf("hpet: %d\n", b_info->hpet);
     printf("vpt_align: %d\n", b_info->vpt_align);
     printf("max_vcpus: %d\n", b_info->max_vcpus);
+    printf("tsc_mode: %d\n", b_info->tsc_mode);
     printf("max_memkb: %d\n", b_info->max_memkb);
     printf("target_memkb: %d\n", b_info->target_memkb);
     printf("kernel: %s\n", b_info->kernel);
@@ -382,6 +383,9 @@ static void parse_config_file(const char
         b_info->target_memkb = b_info->max_memkb;
     }
 
+    if (!xlu_cfg_get_long(config, "tsc_mode", &l))
+        b_info->tsc_mode = l;
+
     if (!xlu_cfg_get_long (config, "shadow_memory", &l))
         b_info->shadow_memkb = l * 1024;
 
Signature · 2 lines
Eric Chanudet
XenClient Team
#4 lore raw

Thanks Eric!

Sorry I didn't mention this earlier, but I just remembered it.

For some of the tsc_mode's to work properly, tsc_mode AND additional tsc information must be preserved across a save/restore/migration. Also, the no_migrate config option has an indirect impact on tsc_mode; with no_migrate specified certain guests will be able to use tsc as their primary clocksource, which can be much faster. (IOW, implementing no_migrate is not a requirement, but may be worthwhile.)

(See xen-4.0.hg/docs/misc/tscmode.txt for more info on all of this.)

Quoted 68 lines

-----Original Message-----
From: Eric Chanudet [mailto:[email protected]]
Sent: Monday, March 29, 2010 12:32 PM
To: Vincent Hanquez; xen-devel
Cc: Dan Magenheimer
Subject: Re: [Xen-devel] [PATCH] xl: tsc_mode parameter in guest configuration file

Quoted 4 lines · Vincent Hanquez

I don't believe we ever did that, with seems wrong indeed. Thanks for pointing it out.

Eric, any chance you can move the tsc_mode call to build_pre (which

is

Quoted 1 line

called by pv and hvm) and refresh the patch ?

Here is the new patch including these changes.

tools/libxl/libxl.h +1 -0
@@ -74,6 +74,7 @@ typedef struct {
     int vpt_align;
     int max_vcpus;
     int cur_vcpus;
+    int tsc_mode;
     uint32_t max_memkb;
     uint32_t target_memkb;
     uint32_t video_memkb;
tools/libxl/libxl_dom.c +1 -0
@@ -72,6 +72,7 @@ int build_pre(struct libxl_ctx *ctx, uin
     xc_domain_set_memmap_limit(ctx->xch, domid,
             (info->hvm) ? info->max_memkb :
             (info->max_memkb + info->u.pv.slack_memkb));
+    xc_domain_set_tsc_info(ctx->xch, domid, info->tsc_mode, 0, 0, 0);
 
     if (info->hvm) {
         unsigned long shadow;
tools/libxl/xl.c +4 -1
@@ -235,6 +235,7 @@ static void printf_info(libxl_domain_cre
     printf("hpet: %d\n", b_info->hpet);
     printf("vpt_align: %d\n", b_info->vpt_align);
     printf("max_vcpus: %d\n", b_info->max_vcpus);
+    printf("tsc_mode: %d\n", b_info->tsc_mode);
     printf("max_memkb: %d\n", b_info->max_memkb);
     printf("target_memkb: %d\n", b_info->target_memkb);
     printf("kernel: %s\n", b_info->kernel);
@@ -382,6 +383,9 @@ static void parse_config_file(const char
         b_info->target_memkb = b_info->max_memkb;
     }
 
+    if (!xlu_cfg_get_long(config, "tsc_mode", &l))
+        b_info->tsc_mode = l;
+
     if (!xlu_cfg_get_long (config, "shadow_memory", &l))
         b_info->shadow_memkb = l * 1024;
 
 
--

Eric Chanudet
XenClient Team

#5 lore raw
Quoted 11 lines · Dan Magenheimer

Thanks Eric!

Sorry I didn't mention this earlier, but I just remembered it.

For some of the tsc_mode's to work properly, tsc_mode AND additional tsc information must be preserved across a save/restore/migration. Also, the no_migrate config option has an indirect impact on tsc_mode; with no_migrate specified certain guests will be able to use tsc as their primary clocksource, which can be much faster. (IOW, implementing no_migrate is not a requirement, but may be worthwhile.)

it seems that the tsc information are automatically save by xenguest saving code, and embedded in the save image.

Signature · 1 line
Vincent
#6 lore raw
In reply to Dan Magenheimer
Quoted 3 lines · Dan Magenheimer

The tsc_mode parameter is important for both HVM and PV. Looking through the patch, I see a lot of hvm changes. Does the patch also handle PV tsc_mode?

No, the tsc_mode parameter is ignored for PV guests in this patch.

Signature · 2 lines
Eric Chanudet
XenClient Team