All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3][uq/master] Basic TSC-Scaling support v2
@ 2011-07-07 14:13 ` Joerg Roedel
  0 siblings, 0 replies; 32+ messages in thread
From: Joerg Roedel @ 2011-07-07 14:13 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti; +Cc: kvm, qemu-devel

Hi Avi, Marcelo,

here is v2 of the patches to support setting the guests tsc-frequency
from the qemu command line. This version addresses the comment from Avi
on the first version. To reflect that units can be given to the
frequency, the parameter was renamed from tsc_khz to tsc_freq.

Thanks,

	Joerg

Diffstat:

 cutils.c            |   16 +++++++++++-----
 qemu-common.h       |    2 ++
 target-i386/cpu.h   |    1 +
 target-i386/cpuid.c |   13 +++++++++++++
 target-i386/kvm.c   |   18 +++++++++++++++++-
 5 files changed, 44 insertions(+), 6 deletions(-)



^ permalink raw reply	[flat|nested] 32+ messages in thread

* [Qemu-devel] [PATCH 0/3][uq/master] Basic TSC-Scaling support v2
@ 2011-07-07 14:13 ` Joerg Roedel
  0 siblings, 0 replies; 32+ messages in thread
From: Joerg Roedel @ 2011-07-07 14:13 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti; +Cc: qemu-devel, kvm

Hi Avi, Marcelo,

here is v2 of the patches to support setting the guests tsc-frequency
from the qemu command line. This version addresses the comment from Avi
on the first version. To reflect that units can be given to the
frequency, the parameter was renamed from tsc_khz to tsc_freq.

Thanks,

	Joerg

Diffstat:

 cutils.c            |   16 +++++++++++-----
 qemu-common.h       |    2 ++
 target-i386/cpu.h   |    1 +
 target-i386/cpuid.c |   13 +++++++++++++
 target-i386/kvm.c   |   18 +++++++++++++++++-
 5 files changed, 44 insertions(+), 6 deletions(-)

^ permalink raw reply	[flat|nested] 32+ messages in thread

* [PATCH 1/3] qemu: Add strtosz_suffix_unit function
  2011-07-07 14:13 ` [Qemu-devel] " Joerg Roedel
@ 2011-07-07 14:13   ` Joerg Roedel
  -1 siblings, 0 replies; 32+ messages in thread
From: Joerg Roedel @ 2011-07-07 14:13 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti; +Cc: kvm, qemu-devel, Joerg Roedel

This function does the same as the strtosz_suffix function
except that it allows to specify the unit to which the
k/M/B/T suffixes apply. This function will be used later to
parse the tsc-frequency from the command-line.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
 cutils.c      |   16 +++++++++++-----
 qemu-common.h |    2 ++
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/cutils.c b/cutils.c
index f9a7e36..28049e0 100644
--- a/cutils.c
+++ b/cutils.c
@@ -322,7 +322,8 @@ int fcntl_setfl(int fd, int flag)
  * value must be terminated by whitespace, ',' or '\0'. Return -1 on
  * error.
  */
-int64_t strtosz_suffix(const char *nptr, char **end, const char default_suffix)
+int64_t strtosz_suffix_unit(const char *nptr, char **end,
+                            const char default_suffix, int64_t unit)
 {
     int64_t retval = -1;
     char *endptr;
@@ -362,20 +363,20 @@ int64_t strtosz_suffix(const char *nptr, char **end, const char default_suffix)
         }
         break;
     case STRTOSZ_DEFSUFFIX_KB:
-        mul = 1 << 10;
+        mul = unit;
         break;
     case 0:
         if (mul_required) {
             goto fail;
         }
     case STRTOSZ_DEFSUFFIX_MB:
-        mul = 1ULL << 20;
+        mul = unit * unit;
         break;
     case STRTOSZ_DEFSUFFIX_GB:
-        mul = 1ULL << 30;
+        mul = unit * unit * unit;
         break;
     case STRTOSZ_DEFSUFFIX_TB:
-        mul = 1ULL << 40;
+        mul = unit * unit * unit * unit;
         break;
     default:
         goto fail;
@@ -405,6 +406,11 @@ fail:
     return retval;
 }
 
+int64_t strtosz_suffix(const char *nptr, char **end, const char default_suffix)
+{
+        return strtosz_suffix_unit(nptr, end, default_suffix, 1024);
+}
+
 int64_t strtosz(const char *nptr, char **end)
 {
     return strtosz_suffix(nptr, end, STRTOSZ_DEFSUFFIX_MB);
diff --git a/qemu-common.h b/qemu-common.h
index 109498d..854031a 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -186,6 +186,8 @@ int fcntl_setfl(int fd, int flag);
 #define STRTOSZ_DEFSUFFIX_B	'B'
 int64_t strtosz(const char *nptr, char **end);
 int64_t strtosz_suffix(const char *nptr, char **end, const char default_suffix);
+int64_t strtosz_suffix_unit(const char *nptr, char **end,
+                            const char default_suffix, int64_t unit);
 
 /* path.c */
 void init_paths(const char *prefix);
-- 
1.7.4.1



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [Qemu-devel] [PATCH 1/3] qemu: Add strtosz_suffix_unit function
@ 2011-07-07 14:13   ` Joerg Roedel
  0 siblings, 0 replies; 32+ messages in thread
From: Joerg Roedel @ 2011-07-07 14:13 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti; +Cc: Joerg Roedel, qemu-devel, kvm

This function does the same as the strtosz_suffix function
except that it allows to specify the unit to which the
k/M/B/T suffixes apply. This function will be used later to
parse the tsc-frequency from the command-line.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
 cutils.c      |   16 +++++++++++-----
 qemu-common.h |    2 ++
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/cutils.c b/cutils.c
index f9a7e36..28049e0 100644
--- a/cutils.c
+++ b/cutils.c
@@ -322,7 +322,8 @@ int fcntl_setfl(int fd, int flag)
  * value must be terminated by whitespace, ',' or '\0'. Return -1 on
  * error.
  */
-int64_t strtosz_suffix(const char *nptr, char **end, const char default_suffix)
+int64_t strtosz_suffix_unit(const char *nptr, char **end,
+                            const char default_suffix, int64_t unit)
 {
     int64_t retval = -1;
     char *endptr;
@@ -362,20 +363,20 @@ int64_t strtosz_suffix(const char *nptr, char **end, const char default_suffix)
         }
         break;
     case STRTOSZ_DEFSUFFIX_KB:
-        mul = 1 << 10;
+        mul = unit;
         break;
     case 0:
         if (mul_required) {
             goto fail;
         }
     case STRTOSZ_DEFSUFFIX_MB:
-        mul = 1ULL << 20;
+        mul = unit * unit;
         break;
     case STRTOSZ_DEFSUFFIX_GB:
-        mul = 1ULL << 30;
+        mul = unit * unit * unit;
         break;
     case STRTOSZ_DEFSUFFIX_TB:
-        mul = 1ULL << 40;
+        mul = unit * unit * unit * unit;
         break;
     default:
         goto fail;
@@ -405,6 +406,11 @@ fail:
     return retval;
 }
 
+int64_t strtosz_suffix(const char *nptr, char **end, const char default_suffix)
+{
+        return strtosz_suffix_unit(nptr, end, default_suffix, 1024);
+}
+
 int64_t strtosz(const char *nptr, char **end)
 {
     return strtosz_suffix(nptr, end, STRTOSZ_DEFSUFFIX_MB);
diff --git a/qemu-common.h b/qemu-common.h
index 109498d..854031a 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -186,6 +186,8 @@ int fcntl_setfl(int fd, int flag);
 #define STRTOSZ_DEFSUFFIX_B	'B'
 int64_t strtosz(const char *nptr, char **end);
 int64_t strtosz_suffix(const char *nptr, char **end, const char default_suffix);
+int64_t strtosz_suffix_unit(const char *nptr, char **end,
+                            const char default_suffix, int64_t unit);
 
 /* path.c */
 void init_paths(const char *prefix);
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 2/3] qemu-x86: Add tsc_freq option to -cpu
  2011-07-07 14:13 ` [Qemu-devel] " Joerg Roedel
@ 2011-07-07 14:13   ` Joerg Roedel
  -1 siblings, 0 replies; 32+ messages in thread
From: Joerg Roedel @ 2011-07-07 14:13 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti; +Cc: kvm, qemu-devel, Joerg Roedel

To let the user configure the desired tsc frequency for the
guest if running in KVM.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
 target-i386/cpu.h   |    1 +
 target-i386/cpuid.c |   13 +++++++++++++
 2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index cdf68ff..399e124 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -743,6 +743,7 @@ typedef struct CPUX86State {
     uint32_t cpuid_kvm_features;
     uint32_t cpuid_svm_features;
     bool tsc_valid;
+    int tsc_khz;
     
     /* in order to simplify APIC support, we leave this pointer to the
        user */
diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
index e1ae3af..89e9623 100644
--- a/target-i386/cpuid.c
+++ b/target-i386/cpuid.c
@@ -224,6 +224,7 @@ typedef struct x86_def_t {
     int family;
     int model;
     int stepping;
+    int tsc_khz;
     uint32_t features, ext_features, ext2_features, ext3_features;
     uint32_t kvm_features, svm_features;
     uint32_t xlevel;
@@ -704,6 +705,17 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model)
             } else if (!strcmp(featurestr, "model_id")) {
                 pstrcpy(x86_cpu_def->model_id, sizeof(x86_cpu_def->model_id),
                         val);
+            } else if (!strcmp(featurestr, "tsc_freq")) {
+                int64_t tsc_freq;
+                char *err;
+
+                tsc_freq = strtosz_suffix_unit(val, &err,
+                                               STRTOSZ_DEFSUFFIX_B, 1000);
+                if (!*val || *err) {
+                    fprintf(stderr, "bad numerical value %s\n", val);
+                    goto error;
+                }
+                x86_cpu_def->tsc_khz = tsc_freq / 1000;
             } else {
                 fprintf(stderr, "unrecognized feature %s\n", featurestr);
                 goto error;
@@ -872,6 +884,7 @@ int cpu_x86_register (CPUX86State *env, const char *cpu_model)
     env->cpuid_svm_features = def->svm_features;
     env->cpuid_ext4_features = def->ext4_features;
     env->cpuid_xlevel2 = def->xlevel2;
+    env->tsc_khz = def->tsc_khz;
     if (!kvm_enabled()) {
         env->cpuid_features &= TCG_FEATURES;
         env->cpuid_ext_features &= TCG_EXT_FEATURES;
-- 
1.7.4.1



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [Qemu-devel] [PATCH 2/3] qemu-x86: Add tsc_freq option to -cpu
@ 2011-07-07 14:13   ` Joerg Roedel
  0 siblings, 0 replies; 32+ messages in thread
From: Joerg Roedel @ 2011-07-07 14:13 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti; +Cc: Joerg Roedel, qemu-devel, kvm

To let the user configure the desired tsc frequency for the
guest if running in KVM.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
 target-i386/cpu.h   |    1 +
 target-i386/cpuid.c |   13 +++++++++++++
 2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index cdf68ff..399e124 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -743,6 +743,7 @@ typedef struct CPUX86State {
     uint32_t cpuid_kvm_features;
     uint32_t cpuid_svm_features;
     bool tsc_valid;
+    int tsc_khz;
     
     /* in order to simplify APIC support, we leave this pointer to the
        user */
diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
index e1ae3af..89e9623 100644
--- a/target-i386/cpuid.c
+++ b/target-i386/cpuid.c
@@ -224,6 +224,7 @@ typedef struct x86_def_t {
     int family;
     int model;
     int stepping;
+    int tsc_khz;
     uint32_t features, ext_features, ext2_features, ext3_features;
     uint32_t kvm_features, svm_features;
     uint32_t xlevel;
@@ -704,6 +705,17 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model)
             } else if (!strcmp(featurestr, "model_id")) {
                 pstrcpy(x86_cpu_def->model_id, sizeof(x86_cpu_def->model_id),
                         val);
+            } else if (!strcmp(featurestr, "tsc_freq")) {
+                int64_t tsc_freq;
+                char *err;
+
+                tsc_freq = strtosz_suffix_unit(val, &err,
+                                               STRTOSZ_DEFSUFFIX_B, 1000);
+                if (!*val || *err) {
+                    fprintf(stderr, "bad numerical value %s\n", val);
+                    goto error;
+                }
+                x86_cpu_def->tsc_khz = tsc_freq / 1000;
             } else {
                 fprintf(stderr, "unrecognized feature %s\n", featurestr);
                 goto error;
@@ -872,6 +884,7 @@ int cpu_x86_register (CPUX86State *env, const char *cpu_model)
     env->cpuid_svm_features = def->svm_features;
     env->cpuid_ext4_features = def->ext4_features;
     env->cpuid_xlevel2 = def->xlevel2;
+    env->tsc_khz = def->tsc_khz;
     if (!kvm_enabled()) {
         env->cpuid_features &= TCG_FEATURES;
         env->cpuid_ext_features &= TCG_EXT_FEATURES;
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [PATCH 3/3] qemu-x86: Set tsc_khz in kvm when supported
  2011-07-07 14:13 ` [Qemu-devel] " Joerg Roedel
@ 2011-07-07 14:13   ` Joerg Roedel
  -1 siblings, 0 replies; 32+ messages in thread
From: Joerg Roedel @ 2011-07-07 14:13 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti; +Cc: kvm, qemu-devel, Joerg Roedel

Make use of the KVM_TSC_CONTROL feature if available.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
 target-i386/kvm.c |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 10fb2c4..923d2d5 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -354,6 +354,7 @@ int kvm_arch_init_vcpu(CPUState *env)
     uint32_t unused;
     struct kvm_cpuid_entry2 *c;
     uint32_t signature[3];
+    int r;
 
     env->cpuid_features &= kvm_arch_get_supported_cpuid(s, 1, 0, R_EDX);
 
@@ -499,7 +500,22 @@ int kvm_arch_init_vcpu(CPUState *env)
 
     qemu_add_vm_change_state_handler(cpu_update_state, env);
 
-    return kvm_vcpu_ioctl(env, KVM_SET_CPUID2, &cpuid_data);
+    r = kvm_vcpu_ioctl(env, KVM_SET_CPUID2, &cpuid_data);
+    if (r)
+	    return r;
+
+#ifdef KVM_CAP_TSC_CONTROL
+    r = kvm_check_extension(env->kvm_state, KVM_CAP_TSC_CONTROL);
+    if (r && env->tsc_khz) {
+        r = kvm_vcpu_ioctl(env, KVM_SET_TSC_KHZ, env->tsc_khz);
+        if (r < 0) {
+            fprintf(stderr, "KVM_SET_TSC_KHZ failed\n");
+            return r;
+        }
+    }
+#endif
+
+    return 0;
 }
 
 void kvm_arch_reset_vcpu(CPUState *env)
-- 
1.7.4.1



^ permalink raw reply related	[flat|nested] 32+ messages in thread

* [Qemu-devel] [PATCH 3/3] qemu-x86: Set tsc_khz in kvm when supported
@ 2011-07-07 14:13   ` Joerg Roedel
  0 siblings, 0 replies; 32+ messages in thread
From: Joerg Roedel @ 2011-07-07 14:13 UTC (permalink / raw)
  To: Avi Kivity, Marcelo Tosatti; +Cc: Joerg Roedel, qemu-devel, kvm

Make use of the KVM_TSC_CONTROL feature if available.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
 target-i386/kvm.c |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 10fb2c4..923d2d5 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -354,6 +354,7 @@ int kvm_arch_init_vcpu(CPUState *env)
     uint32_t unused;
     struct kvm_cpuid_entry2 *c;
     uint32_t signature[3];
+    int r;
 
     env->cpuid_features &= kvm_arch_get_supported_cpuid(s, 1, 0, R_EDX);
 
@@ -499,7 +500,22 @@ int kvm_arch_init_vcpu(CPUState *env)
 
     qemu_add_vm_change_state_handler(cpu_update_state, env);
 
-    return kvm_vcpu_ioctl(env, KVM_SET_CPUID2, &cpuid_data);
+    r = kvm_vcpu_ioctl(env, KVM_SET_CPUID2, &cpuid_data);
+    if (r)
+	    return r;
+
+#ifdef KVM_CAP_TSC_CONTROL
+    r = kvm_check_extension(env->kvm_state, KVM_CAP_TSC_CONTROL);
+    if (r && env->tsc_khz) {
+        r = kvm_vcpu_ioctl(env, KVM_SET_TSC_KHZ, env->tsc_khz);
+        if (r < 0) {
+            fprintf(stderr, "KVM_SET_TSC_KHZ failed\n");
+            return r;
+        }
+    }
+#endif
+
+    return 0;
 }
 
 void kvm_arch_reset_vcpu(CPUState *env)
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 32+ messages in thread

* Re: [PATCH 1/3] qemu: Add strtosz_suffix_unit function
  2011-07-07 14:13   ` [Qemu-devel] " Joerg Roedel
@ 2011-07-08  8:00     ` Markus Armbruster
  -1 siblings, 0 replies; 32+ messages in thread
From: Markus Armbruster @ 2011-07-08  8:00 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: Avi Kivity, Marcelo Tosatti, kvm, qemu-devel

Joerg Roedel <joerg.roedel@amd.com> writes:

> This function does the same as the strtosz_suffix function
> except that it allows to specify the unit to which the
> k/M/B/T suffixes apply. This function will be used later to
> parse the tsc-frequency from the command-line.
>
> Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
> ---
>  cutils.c      |   16 +++++++++++-----
>  qemu-common.h |    2 ++
>  2 files changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/cutils.c b/cutils.c
> index f9a7e36..28049e0 100644
> --- a/cutils.c
> +++ b/cutils.c
> @@ -322,7 +322,8 @@ int fcntl_setfl(int fd, int flag)
>   * value must be terminated by whitespace, ',' or '\0'. Return -1 on
>   * error.
>   */
> -int64_t strtosz_suffix(const char *nptr, char **end, const char default_suffix)
> +int64_t strtosz_suffix_unit(const char *nptr, char **end,
> +                            const char default_suffix, int64_t unit)
>  {
>      int64_t retval = -1;
>      char *endptr;
> @@ -362,20 +363,20 @@ int64_t strtosz_suffix(const char *nptr, char **end, const char default_suffix)
>          }
>          break;
>      case STRTOSZ_DEFSUFFIX_KB:
> -        mul = 1 << 10;
> +        mul = unit;
>          break;
>      case 0:
>          if (mul_required) {
>              goto fail;
>          }
>      case STRTOSZ_DEFSUFFIX_MB:
> -        mul = 1ULL << 20;
> +        mul = unit * unit;
>          break;
>      case STRTOSZ_DEFSUFFIX_GB:
> -        mul = 1ULL << 30;
> +        mul = unit * unit * unit;
>          break;
>      case STRTOSZ_DEFSUFFIX_TB:
> -        mul = 1ULL << 40;
> +        mul = unit * unit * unit * unit;
>          break;
>      default:
>          goto fail;
> @@ -405,6 +406,11 @@ fail:
>      return retval;
>  }

Why would anyone ever call this function with an unit argument other
than 1000 or 1024?

Without such a use case, I'd rather give strtosz_suffix() a flag
parameter to pick SI prefixes (multiples of 1000) vs. binary prefixes
(multiples of 1024).

[...]

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH 1/3] qemu: Add strtosz_suffix_unit function
@ 2011-07-08  8:00     ` Markus Armbruster
  0 siblings, 0 replies; 32+ messages in thread
From: Markus Armbruster @ 2011-07-08  8:00 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: Marcelo Tosatti, Avi Kivity, kvm, qemu-devel

Joerg Roedel <joerg.roedel@amd.com> writes:

> This function does the same as the strtosz_suffix function
> except that it allows to specify the unit to which the
> k/M/B/T suffixes apply. This function will be used later to
> parse the tsc-frequency from the command-line.
>
> Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
> ---
>  cutils.c      |   16 +++++++++++-----
>  qemu-common.h |    2 ++
>  2 files changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/cutils.c b/cutils.c
> index f9a7e36..28049e0 100644
> --- a/cutils.c
> +++ b/cutils.c
> @@ -322,7 +322,8 @@ int fcntl_setfl(int fd, int flag)
>   * value must be terminated by whitespace, ',' or '\0'. Return -1 on
>   * error.
>   */
> -int64_t strtosz_suffix(const char *nptr, char **end, const char default_suffix)
> +int64_t strtosz_suffix_unit(const char *nptr, char **end,
> +                            const char default_suffix, int64_t unit)
>  {
>      int64_t retval = -1;
>      char *endptr;
> @@ -362,20 +363,20 @@ int64_t strtosz_suffix(const char *nptr, char **end, const char default_suffix)
>          }
>          break;
>      case STRTOSZ_DEFSUFFIX_KB:
> -        mul = 1 << 10;
> +        mul = unit;
>          break;
>      case 0:
>          if (mul_required) {
>              goto fail;
>          }
>      case STRTOSZ_DEFSUFFIX_MB:
> -        mul = 1ULL << 20;
> +        mul = unit * unit;
>          break;
>      case STRTOSZ_DEFSUFFIX_GB:
> -        mul = 1ULL << 30;
> +        mul = unit * unit * unit;
>          break;
>      case STRTOSZ_DEFSUFFIX_TB:
> -        mul = 1ULL << 40;
> +        mul = unit * unit * unit * unit;
>          break;
>      default:
>          goto fail;
> @@ -405,6 +406,11 @@ fail:
>      return retval;
>  }

Why would anyone ever call this function with an unit argument other
than 1000 or 1024?

Without such a use case, I'd rather give strtosz_suffix() a flag
parameter to pick SI prefixes (multiples of 1000) vs. binary prefixes
(multiples of 1024).

[...]

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 2/3] qemu-x86: Add tsc_freq option to -cpu
  2011-07-07 14:13   ` [Qemu-devel] " Joerg Roedel
@ 2011-07-19 11:46     ` Marcelo Tosatti
  -1 siblings, 0 replies; 32+ messages in thread
From: Marcelo Tosatti @ 2011-07-19 11:46 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: Avi Kivity, kvm, qemu-devel

On Thu, Jul 07, 2011 at 04:13:12PM +0200, Joerg Roedel wrote:
> To let the user configure the desired tsc frequency for the
> guest if running in KVM.
> 
> Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
> ---
>  target-i386/cpu.h   |    1 +
>  target-i386/cpuid.c |   13 +++++++++++++
>  2 files changed, 14 insertions(+), 0 deletions(-)
> 
> diff --git a/target-i386/cpu.h b/target-i386/cpu.h
> index cdf68ff..399e124 100644
> --- a/target-i386/cpu.h
> +++ b/target-i386/cpu.h
> @@ -743,6 +743,7 @@ typedef struct CPUX86State {
>      uint32_t cpuid_kvm_features;
>      uint32_t cpuid_svm_features;
>      bool tsc_valid;
> +    int tsc_khz;

This should be saved/restore in migration data (missing VMSTATE entry).

>      /* in order to simplify APIC support, we leave this pointer to the
>         user */
> diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
> index e1ae3af..89e9623 100644
> --- a/target-i386/cpuid.c
> +++ b/target-i386/cpuid.c
> @@ -224,6 +224,7 @@ typedef struct x86_def_t {
>      int family;
>      int model;
>      int stepping;
> +    int tsc_khz;
>      uint32_t features, ext_features, ext2_features, ext3_features;
>      uint32_t kvm_features, svm_features;
>      uint32_t xlevel;
> @@ -704,6 +705,17 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model)
>              } else if (!strcmp(featurestr, "model_id")) {
>                  pstrcpy(x86_cpu_def->model_id, sizeof(x86_cpu_def->model_id),
>                          val);
> +            } else if (!strcmp(featurestr, "tsc_freq")) {
> +                int64_t tsc_freq;
> +                char *err;
> +
> +                tsc_freq = strtosz_suffix_unit(val, &err,
> +                                               STRTOSZ_DEFSUFFIX_B, 1000);
> +                if (!*val || *err) {
> +                    fprintf(stderr, "bad numerical value %s\n", val);
> +                    goto error;
> +                }
> +                x86_cpu_def->tsc_khz = tsc_freq / 1000;
>              } else {
>                  fprintf(stderr, "unrecognized feature %s\n", featurestr);
>                  goto error;
> @@ -872,6 +884,7 @@ int cpu_x86_register (CPUX86State *env, const char *cpu_model)
>      env->cpuid_svm_features = def->svm_features;
>      env->cpuid_ext4_features = def->ext4_features;
>      env->cpuid_xlevel2 = def->xlevel2;
> +    env->tsc_khz = def->tsc_khz;
>      if (!kvm_enabled()) {
>          env->cpuid_features &= TCG_FEATURES;
>          env->cpuid_ext_features &= TCG_EXT_FEATURES;
> -- 
> 1.7.4.1
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH 2/3] qemu-x86: Add tsc_freq option to -cpu
@ 2011-07-19 11:46     ` Marcelo Tosatti
  0 siblings, 0 replies; 32+ messages in thread
From: Marcelo Tosatti @ 2011-07-19 11:46 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: Avi Kivity, kvm, qemu-devel

On Thu, Jul 07, 2011 at 04:13:12PM +0200, Joerg Roedel wrote:
> To let the user configure the desired tsc frequency for the
> guest if running in KVM.
> 
> Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
> ---
>  target-i386/cpu.h   |    1 +
>  target-i386/cpuid.c |   13 +++++++++++++
>  2 files changed, 14 insertions(+), 0 deletions(-)
> 
> diff --git a/target-i386/cpu.h b/target-i386/cpu.h
> index cdf68ff..399e124 100644
> --- a/target-i386/cpu.h
> +++ b/target-i386/cpu.h
> @@ -743,6 +743,7 @@ typedef struct CPUX86State {
>      uint32_t cpuid_kvm_features;
>      uint32_t cpuid_svm_features;
>      bool tsc_valid;
> +    int tsc_khz;

This should be saved/restore in migration data (missing VMSTATE entry).

>      /* in order to simplify APIC support, we leave this pointer to the
>         user */
> diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
> index e1ae3af..89e9623 100644
> --- a/target-i386/cpuid.c
> +++ b/target-i386/cpuid.c
> @@ -224,6 +224,7 @@ typedef struct x86_def_t {
>      int family;
>      int model;
>      int stepping;
> +    int tsc_khz;
>      uint32_t features, ext_features, ext2_features, ext3_features;
>      uint32_t kvm_features, svm_features;
>      uint32_t xlevel;
> @@ -704,6 +705,17 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model)
>              } else if (!strcmp(featurestr, "model_id")) {
>                  pstrcpy(x86_cpu_def->model_id, sizeof(x86_cpu_def->model_id),
>                          val);
> +            } else if (!strcmp(featurestr, "tsc_freq")) {
> +                int64_t tsc_freq;
> +                char *err;
> +
> +                tsc_freq = strtosz_suffix_unit(val, &err,
> +                                               STRTOSZ_DEFSUFFIX_B, 1000);
> +                if (!*val || *err) {
> +                    fprintf(stderr, "bad numerical value %s\n", val);
> +                    goto error;
> +                }
> +                x86_cpu_def->tsc_khz = tsc_freq / 1000;
>              } else {
>                  fprintf(stderr, "unrecognized feature %s\n", featurestr);
>                  goto error;
> @@ -872,6 +884,7 @@ int cpu_x86_register (CPUX86State *env, const char *cpu_model)
>      env->cpuid_svm_features = def->svm_features;
>      env->cpuid_ext4_features = def->ext4_features;
>      env->cpuid_xlevel2 = def->xlevel2;
> +    env->tsc_khz = def->tsc_khz;
>      if (!kvm_enabled()) {
>          env->cpuid_features &= TCG_FEATURES;
>          env->cpuid_ext_features &= TCG_EXT_FEATURES;
> -- 
> 1.7.4.1
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 3/3] qemu-x86: Set tsc_khz in kvm when supported
  2011-07-07 14:13   ` [Qemu-devel] " Joerg Roedel
@ 2011-07-19 11:48     ` Marcelo Tosatti
  -1 siblings, 0 replies; 32+ messages in thread
From: Marcelo Tosatti @ 2011-07-19 11:48 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: Avi Kivity, kvm, qemu-devel

On Thu, Jul 07, 2011 at 04:13:13PM +0200, Joerg Roedel wrote:
> Make use of the KVM_TSC_CONTROL feature if available.
> 
> Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
> ---
>  target-i386/kvm.c |   18 +++++++++++++++++-
>  1 files changed, 17 insertions(+), 1 deletions(-)
> 
> diff --git a/target-i386/kvm.c b/target-i386/kvm.c
> index 10fb2c4..923d2d5 100644
> --- a/target-i386/kvm.c
> +++ b/target-i386/kvm.c
> @@ -354,6 +354,7 @@ int kvm_arch_init_vcpu(CPUState *env)
>      uint32_t unused;
>      struct kvm_cpuid_entry2 *c;
>      uint32_t signature[3];
> +    int r;
>  
>      env->cpuid_features &= kvm_arch_get_supported_cpuid(s, 1, 0, R_EDX);
>  
> @@ -499,7 +500,22 @@ int kvm_arch_init_vcpu(CPUState *env)
>  
>      qemu_add_vm_change_state_handler(cpu_update_state, env);
>  
> -    return kvm_vcpu_ioctl(env, KVM_SET_CPUID2, &cpuid_data);
> +    r = kvm_vcpu_ioctl(env, KVM_SET_CPUID2, &cpuid_data);
> +    if (r)
> +	    return r;
> +
> +#ifdef KVM_CAP_TSC_CONTROL
> +    r = kvm_check_extension(env->kvm_state, KVM_CAP_TSC_CONTROL);
> +    if (r && env->tsc_khz) {
> +        r = kvm_vcpu_ioctl(env, KVM_SET_TSC_KHZ, env->tsc_khz);
> +        if (r < 0) {
> +            fprintf(stderr, "KVM_SET_TSC_KHZ failed\n");
> +            return r;
> +        }
> +    }
> +#endif

And this should be moved to kvm_arch_put_registers, in case 
level == KVM_PUT_FULL_STATE.


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH 3/3] qemu-x86: Set tsc_khz in kvm when supported
@ 2011-07-19 11:48     ` Marcelo Tosatti
  0 siblings, 0 replies; 32+ messages in thread
From: Marcelo Tosatti @ 2011-07-19 11:48 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: Avi Kivity, kvm, qemu-devel

On Thu, Jul 07, 2011 at 04:13:13PM +0200, Joerg Roedel wrote:
> Make use of the KVM_TSC_CONTROL feature if available.
> 
> Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
> ---
>  target-i386/kvm.c |   18 +++++++++++++++++-
>  1 files changed, 17 insertions(+), 1 deletions(-)
> 
> diff --git a/target-i386/kvm.c b/target-i386/kvm.c
> index 10fb2c4..923d2d5 100644
> --- a/target-i386/kvm.c
> +++ b/target-i386/kvm.c
> @@ -354,6 +354,7 @@ int kvm_arch_init_vcpu(CPUState *env)
>      uint32_t unused;
>      struct kvm_cpuid_entry2 *c;
>      uint32_t signature[3];
> +    int r;
>  
>      env->cpuid_features &= kvm_arch_get_supported_cpuid(s, 1, 0, R_EDX);
>  
> @@ -499,7 +500,22 @@ int kvm_arch_init_vcpu(CPUState *env)
>  
>      qemu_add_vm_change_state_handler(cpu_update_state, env);
>  
> -    return kvm_vcpu_ioctl(env, KVM_SET_CPUID2, &cpuid_data);
> +    r = kvm_vcpu_ioctl(env, KVM_SET_CPUID2, &cpuid_data);
> +    if (r)
> +	    return r;
> +
> +#ifdef KVM_CAP_TSC_CONTROL
> +    r = kvm_check_extension(env->kvm_state, KVM_CAP_TSC_CONTROL);
> +    if (r && env->tsc_khz) {
> +        r = kvm_vcpu_ioctl(env, KVM_SET_TSC_KHZ, env->tsc_khz);
> +        if (r < 0) {
> +            fprintf(stderr, "KVM_SET_TSC_KHZ failed\n");
> +            return r;
> +        }
> +    }
> +#endif

And this should be moved to kvm_arch_put_registers, in case 
level == KVM_PUT_FULL_STATE.

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 2/3] qemu-x86: Add tsc_freq option to -cpu
  2011-07-19 11:46     ` [Qemu-devel] " Marcelo Tosatti
@ 2011-07-19 12:20       ` Avi Kivity
  -1 siblings, 0 replies; 32+ messages in thread
From: Avi Kivity @ 2011-07-19 12:20 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: Joerg Roedel, kvm, qemu-devel

On 07/19/2011 02:46 PM, Marcelo Tosatti wrote:
> On Thu, Jul 07, 2011 at 04:13:12PM +0200, Joerg Roedel wrote:
> >  To let the user configure the desired tsc frequency for the
> >  guest if running in KVM.
> >
> >  Signed-off-by: Joerg Roedel<joerg.roedel@amd.com>
> >  ---
> >   target-i386/cpu.h   |    1 +
> >   target-i386/cpuid.c |   13 +++++++++++++
> >   2 files changed, 14 insertions(+), 0 deletions(-)
> >
> >  diff --git a/target-i386/cpu.h b/target-i386/cpu.h
> >  index cdf68ff..399e124 100644
> >  --- a/target-i386/cpu.h
> >  +++ b/target-i386/cpu.h
> >  @@ -743,6 +743,7 @@ typedef struct CPUX86State {
> >       uint32_t cpuid_kvm_features;
> >       uint32_t cpuid_svm_features;
> >       bool tsc_valid;
> >  +    int tsc_khz;
>
> This should be saved/restore in migration data (missing VMSTATE entry).

Why?  It's static data.  Traditionally we only migrate runtime data.

(although we've been talking about starting a naked qemu and pushing all 
of the configuration from the source).

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH 2/3] qemu-x86: Add tsc_freq option to -cpu
@ 2011-07-19 12:20       ` Avi Kivity
  0 siblings, 0 replies; 32+ messages in thread
From: Avi Kivity @ 2011-07-19 12:20 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: Joerg Roedel, qemu-devel, kvm

On 07/19/2011 02:46 PM, Marcelo Tosatti wrote:
> On Thu, Jul 07, 2011 at 04:13:12PM +0200, Joerg Roedel wrote:
> >  To let the user configure the desired tsc frequency for the
> >  guest if running in KVM.
> >
> >  Signed-off-by: Joerg Roedel<joerg.roedel@amd.com>
> >  ---
> >   target-i386/cpu.h   |    1 +
> >   target-i386/cpuid.c |   13 +++++++++++++
> >   2 files changed, 14 insertions(+), 0 deletions(-)
> >
> >  diff --git a/target-i386/cpu.h b/target-i386/cpu.h
> >  index cdf68ff..399e124 100644
> >  --- a/target-i386/cpu.h
> >  +++ b/target-i386/cpu.h
> >  @@ -743,6 +743,7 @@ typedef struct CPUX86State {
> >       uint32_t cpuid_kvm_features;
> >       uint32_t cpuid_svm_features;
> >       bool tsc_valid;
> >  +    int tsc_khz;
>
> This should be saved/restore in migration data (missing VMSTATE entry).

Why?  It's static data.  Traditionally we only migrate runtime data.

(although we've been talking about starting a naked qemu and pushing all 
of the configuration from the source).

-- 
error compiling committee.c: too many arguments to function

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 2/3] qemu-x86: Add tsc_freq option to -cpu
  2011-07-19 12:20       ` [Qemu-devel] " Avi Kivity
@ 2011-07-19 12:56         ` Marcelo Tosatti
  -1 siblings, 0 replies; 32+ messages in thread
From: Marcelo Tosatti @ 2011-07-19 12:56 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Joerg Roedel, kvm, qemu-devel

On Tue, Jul 19, 2011 at 03:20:37PM +0300, Avi Kivity wrote:
> On 07/19/2011 02:46 PM, Marcelo Tosatti wrote:
> >On Thu, Jul 07, 2011 at 04:13:12PM +0200, Joerg Roedel wrote:
> >>  To let the user configure the desired tsc frequency for the
> >>  guest if running in KVM.
> >>
> >>  Signed-off-by: Joerg Roedel<joerg.roedel@amd.com>
> >>  ---
> >>   target-i386/cpu.h   |    1 +
> >>   target-i386/cpuid.c |   13 +++++++++++++
> >>   2 files changed, 14 insertions(+), 0 deletions(-)
> >>
> >>  diff --git a/target-i386/cpu.h b/target-i386/cpu.h
> >>  index cdf68ff..399e124 100644
> >>  --- a/target-i386/cpu.h
> >>  +++ b/target-i386/cpu.h
> >>  @@ -743,6 +743,7 @@ typedef struct CPUX86State {
> >>       uint32_t cpuid_kvm_features;
> >>       uint32_t cpuid_svm_features;
> >>       bool tsc_valid;
> >>  +    int tsc_khz;
> >
> >This should be saved/restore in migration data (missing VMSTATE entry).
> 
> Why?  It's static data.  Traditionally we only migrate runtime data.
> 
> (although we've been talking about starting a naked qemu and pushing
> all of the configuration from the source).

Right.


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH 2/3] qemu-x86: Add tsc_freq option to -cpu
@ 2011-07-19 12:56         ` Marcelo Tosatti
  0 siblings, 0 replies; 32+ messages in thread
From: Marcelo Tosatti @ 2011-07-19 12:56 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Joerg Roedel, qemu-devel, kvm

On Tue, Jul 19, 2011 at 03:20:37PM +0300, Avi Kivity wrote:
> On 07/19/2011 02:46 PM, Marcelo Tosatti wrote:
> >On Thu, Jul 07, 2011 at 04:13:12PM +0200, Joerg Roedel wrote:
> >>  To let the user configure the desired tsc frequency for the
> >>  guest if running in KVM.
> >>
> >>  Signed-off-by: Joerg Roedel<joerg.roedel@amd.com>
> >>  ---
> >>   target-i386/cpu.h   |    1 +
> >>   target-i386/cpuid.c |   13 +++++++++++++
> >>   2 files changed, 14 insertions(+), 0 deletions(-)
> >>
> >>  diff --git a/target-i386/cpu.h b/target-i386/cpu.h
> >>  index cdf68ff..399e124 100644
> >>  --- a/target-i386/cpu.h
> >>  +++ b/target-i386/cpu.h
> >>  @@ -743,6 +743,7 @@ typedef struct CPUX86State {
> >>       uint32_t cpuid_kvm_features;
> >>       uint32_t cpuid_svm_features;
> >>       bool tsc_valid;
> >>  +    int tsc_khz;
> >
> >This should be saved/restore in migration data (missing VMSTATE entry).
> 
> Why?  It's static data.  Traditionally we only migrate runtime data.
> 
> (although we've been talking about starting a naked qemu and pushing
> all of the configuration from the source).

Right.

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 0/3][uq/master] Basic TSC-Scaling support v2
  2011-07-07 14:13 ` [Qemu-devel] " Joerg Roedel
@ 2011-07-19 13:04   ` Marcelo Tosatti
  -1 siblings, 0 replies; 32+ messages in thread
From: Marcelo Tosatti @ 2011-07-19 13:04 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: Avi Kivity, kvm, qemu-devel

On Thu, Jul 07, 2011 at 04:13:10PM +0200, Joerg Roedel wrote:
> Hi Avi, Marcelo,
> 
> here is v2 of the patches to support setting the guests tsc-frequency
> from the qemu command line. This version addresses the comment from Avi
> on the first version. To reflect that units can be given to the
> frequency, the parameter was renamed from tsc_khz to tsc_freq.
> 
> Thanks,
> 
> 	Joerg

Applied to uq/master, thanks.


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH 0/3][uq/master] Basic TSC-Scaling support v2
@ 2011-07-19 13:04   ` Marcelo Tosatti
  0 siblings, 0 replies; 32+ messages in thread
From: Marcelo Tosatti @ 2011-07-19 13:04 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: Avi Kivity, kvm, qemu-devel

On Thu, Jul 07, 2011 at 04:13:10PM +0200, Joerg Roedel wrote:
> Hi Avi, Marcelo,
> 
> here is v2 of the patches to support setting the guests tsc-frequency
> from the qemu command line. This version addresses the comment from Avi
> on the first version. To reflect that units can be given to the
> frequency, the parameter was renamed from tsc_khz to tsc_freq.
> 
> Thanks,
> 
> 	Joerg

Applied to uq/master, thanks.

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 2/3] qemu-x86: Add tsc_freq option to -cpu
  2011-07-19 12:20       ` [Qemu-devel] " Avi Kivity
@ 2011-07-19 13:30         ` Joerg Roedel
  -1 siblings, 0 replies; 32+ messages in thread
From: Joerg Roedel @ 2011-07-19 13:30 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Marcelo Tosatti, Joerg Roedel, kvm, qemu-devel

On Tue, Jul 19, 2011 at 03:20:37PM +0300, Avi Kivity wrote:
> On 07/19/2011 02:46 PM, Marcelo Tosatti wrote:
>> On Thu, Jul 07, 2011 at 04:13:12PM +0200, Joerg Roedel wrote:
>> >  To let the user configure the desired tsc frequency for the
>> >  guest if running in KVM.
>> >
>> >  Signed-off-by: Joerg Roedel<joerg.roedel@amd.com>
>> >  ---
>> >   target-i386/cpu.h   |    1 +
>> >   target-i386/cpuid.c |   13 +++++++++++++
>> >   2 files changed, 14 insertions(+), 0 deletions(-)
>> >
>> >  diff --git a/target-i386/cpu.h b/target-i386/cpu.h
>> >  index cdf68ff..399e124 100644
>> >  --- a/target-i386/cpu.h
>> >  +++ b/target-i386/cpu.h
>> >  @@ -743,6 +743,7 @@ typedef struct CPUX86State {
>> >       uint32_t cpuid_kvm_features;
>> >       uint32_t cpuid_svm_features;
>> >       bool tsc_valid;
>> >  +    int tsc_khz;
>>
>> This should be saved/restore in migration data (missing VMSTATE entry).
>
> Why?  It's static data.  Traditionally we only migrate runtime data.
>
> (although we've been talking about starting a naked qemu and pushing all  
> of the configuration from the source).

Hmm, I planned to do the VMSTATE thing in a follow-on patch-set. The
plan is to read the VCPU tsc_freq at guest start time on !tsc-scale
hosts and migrate it over so that the destination host can set the
tsc-freq if it supports tsc-scaling.

	Joerg


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH 2/3] qemu-x86: Add tsc_freq option to -cpu
@ 2011-07-19 13:30         ` Joerg Roedel
  0 siblings, 0 replies; 32+ messages in thread
From: Joerg Roedel @ 2011-07-19 13:30 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Joerg Roedel, Marcelo Tosatti, qemu-devel, kvm

On Tue, Jul 19, 2011 at 03:20:37PM +0300, Avi Kivity wrote:
> On 07/19/2011 02:46 PM, Marcelo Tosatti wrote:
>> On Thu, Jul 07, 2011 at 04:13:12PM +0200, Joerg Roedel wrote:
>> >  To let the user configure the desired tsc frequency for the
>> >  guest if running in KVM.
>> >
>> >  Signed-off-by: Joerg Roedel<joerg.roedel@amd.com>
>> >  ---
>> >   target-i386/cpu.h   |    1 +
>> >   target-i386/cpuid.c |   13 +++++++++++++
>> >   2 files changed, 14 insertions(+), 0 deletions(-)
>> >
>> >  diff --git a/target-i386/cpu.h b/target-i386/cpu.h
>> >  index cdf68ff..399e124 100644
>> >  --- a/target-i386/cpu.h
>> >  +++ b/target-i386/cpu.h
>> >  @@ -743,6 +743,7 @@ typedef struct CPUX86State {
>> >       uint32_t cpuid_kvm_features;
>> >       uint32_t cpuid_svm_features;
>> >       bool tsc_valid;
>> >  +    int tsc_khz;
>>
>> This should be saved/restore in migration data (missing VMSTATE entry).
>
> Why?  It's static data.  Traditionally we only migrate runtime data.
>
> (although we've been talking about starting a naked qemu and pushing all  
> of the configuration from the source).

Hmm, I planned to do the VMSTATE thing in a follow-on patch-set. The
plan is to read the VCPU tsc_freq at guest start time on !tsc-scale
hosts and migrate it over so that the destination host can set the
tsc-freq if it supports tsc-scaling.

	Joerg

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 2/3] qemu-x86: Add tsc_freq option to -cpu
  2011-07-19 13:30         ` [Qemu-devel] " Joerg Roedel
@ 2011-07-19 13:54           ` Avi Kivity
  -1 siblings, 0 replies; 32+ messages in thread
From: Avi Kivity @ 2011-07-19 13:54 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: Marcelo Tosatti, Joerg Roedel, kvm, qemu-devel

On 07/19/2011 04:30 PM, Joerg Roedel wrote:
> >
> >  (although we've been talking about starting a naked qemu and pushing all
> >  of the configuration from the source).
>
> Hmm, I planned to do the VMSTATE thing in a follow-on patch-set. The
> plan is to read the VCPU tsc_freq at guest start time on !tsc-scale
> hosts and migrate it over so that the destination host can set the
> tsc-freq if it supports tsc-scaling.

This can be done by a management tool if desired.

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH 2/3] qemu-x86: Add tsc_freq option to -cpu
@ 2011-07-19 13:54           ` Avi Kivity
  0 siblings, 0 replies; 32+ messages in thread
From: Avi Kivity @ 2011-07-19 13:54 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: Joerg Roedel, Marcelo Tosatti, qemu-devel, kvm

On 07/19/2011 04:30 PM, Joerg Roedel wrote:
> >
> >  (although we've been talking about starting a naked qemu and pushing all
> >  of the configuration from the source).
>
> Hmm, I planned to do the VMSTATE thing in a follow-on patch-set. The
> plan is to read the VCPU tsc_freq at guest start time on !tsc-scale
> hosts and migrate it over so that the destination host can set the
> tsc-freq if it supports tsc-scaling.

This can be done by a management tool if desired.

-- 
error compiling committee.c: too many arguments to function

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 2/3] qemu-x86: Add tsc_freq option to -cpu
  2011-07-19 13:54           ` [Qemu-devel] " Avi Kivity
@ 2011-07-19 13:55             ` Avi Kivity
  -1 siblings, 0 replies; 32+ messages in thread
From: Avi Kivity @ 2011-07-19 13:55 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: Marcelo Tosatti, Joerg Roedel, kvm, qemu-devel

On 07/19/2011 04:54 PM, Avi Kivity wrote:
> On 07/19/2011 04:30 PM, Joerg Roedel wrote:
>> >
>> >  (although we've been talking about starting a naked qemu and 
>> pushing all
>> >  of the configuration from the source).
>>
>> Hmm, I planned to do the VMSTATE thing in a follow-on patch-set. The
>> plan is to read the VCPU tsc_freq at guest start time on !tsc-scale
>> hosts and migrate it over so that the destination host can set the
>> tsc-freq if it supports tsc-scaling.
>
> This can be done by a management tool if desired.
>

Although, if we do this unconditionally (that is, also for tsc-scale 
hosts) then we get stable tsc even without supplying a tsc frequency 
argument... need to think about this.

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH 2/3] qemu-x86: Add tsc_freq option to -cpu
@ 2011-07-19 13:55             ` Avi Kivity
  0 siblings, 0 replies; 32+ messages in thread
From: Avi Kivity @ 2011-07-19 13:55 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: Joerg Roedel, Marcelo Tosatti, qemu-devel, kvm

On 07/19/2011 04:54 PM, Avi Kivity wrote:
> On 07/19/2011 04:30 PM, Joerg Roedel wrote:
>> >
>> >  (although we've been talking about starting a naked qemu and 
>> pushing all
>> >  of the configuration from the source).
>>
>> Hmm, I planned to do the VMSTATE thing in a follow-on patch-set. The
>> plan is to read the VCPU tsc_freq at guest start time on !tsc-scale
>> hosts and migrate it over so that the destination host can set the
>> tsc-freq if it supports tsc-scaling.
>
> This can be done by a management tool if desired.
>

Although, if we do this unconditionally (that is, also for tsc-scale 
hosts) then we get stable tsc even without supplying a tsc frequency 
argument... need to think about this.

-- 
error compiling committee.c: too many arguments to function

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 2/3] qemu-x86: Add tsc_freq option to -cpu
  2011-07-19 13:55             ` [Qemu-devel] " Avi Kivity
@ 2011-07-19 14:14               ` Joerg Roedel
  -1 siblings, 0 replies; 32+ messages in thread
From: Joerg Roedel @ 2011-07-19 14:14 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Marcelo Tosatti, Joerg Roedel, kvm, qemu-devel

On Tue, Jul 19, 2011 at 04:55:53PM +0300, Avi Kivity wrote:
> On 07/19/2011 04:54 PM, Avi Kivity wrote:
>> On 07/19/2011 04:30 PM, Joerg Roedel wrote:

>>> Hmm, I planned to do the VMSTATE thing in a follow-on patch-set. The
>>> plan is to read the VCPU tsc_freq at guest start time on !tsc-scale
>>> hosts and migrate it over so that the destination host can set the
>>> tsc-freq if it supports tsc-scaling.
>>
>> This can be done by a management tool if desired.
>>
>
> Although, if we do this unconditionally (that is, also for tsc-scale  
> hosts) then we get stable tsc even without supplying a tsc frequency  
> argument... need to think about this.

It has the advantage that it "just works", without the need to extend
management tools and the like. And it makes migration more transparent
to the guests.

	Joerg


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH 2/3] qemu-x86: Add tsc_freq option to -cpu
@ 2011-07-19 14:14               ` Joerg Roedel
  0 siblings, 0 replies; 32+ messages in thread
From: Joerg Roedel @ 2011-07-19 14:14 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Joerg Roedel, Marcelo Tosatti, qemu-devel, kvm

On Tue, Jul 19, 2011 at 04:55:53PM +0300, Avi Kivity wrote:
> On 07/19/2011 04:54 PM, Avi Kivity wrote:
>> On 07/19/2011 04:30 PM, Joerg Roedel wrote:

>>> Hmm, I planned to do the VMSTATE thing in a follow-on patch-set. The
>>> plan is to read the VCPU tsc_freq at guest start time on !tsc-scale
>>> hosts and migrate it over so that the destination host can set the
>>> tsc-freq if it supports tsc-scaling.
>>
>> This can be done by a management tool if desired.
>>
>
> Although, if we do this unconditionally (that is, also for tsc-scale  
> hosts) then we get stable tsc even without supplying a tsc frequency  
> argument... need to think about this.

It has the advantage that it "just works", without the need to extend
management tools and the like. And it makes migration more transparent
to the guests.

	Joerg

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 2/3] qemu-x86: Add tsc_freq option to -cpu
  2011-07-19 14:14               ` [Qemu-devel] " Joerg Roedel
@ 2011-07-19 15:55                 ` Avi Kivity
  -1 siblings, 0 replies; 32+ messages in thread
From: Avi Kivity @ 2011-07-19 15:55 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: Marcelo Tosatti, Joerg Roedel, kvm, qemu-devel

On 07/19/2011 05:14 PM, Joerg Roedel wrote:
> On Tue, Jul 19, 2011 at 04:55:53PM +0300, Avi Kivity wrote:
> >  On 07/19/2011 04:54 PM, Avi Kivity wrote:
> >>  On 07/19/2011 04:30 PM, Joerg Roedel wrote:
>
> >>>  Hmm, I planned to do the VMSTATE thing in a follow-on patch-set. The
> >>>  plan is to read the VCPU tsc_freq at guest start time on !tsc-scale
> >>>  hosts and migrate it over so that the destination host can set the
> >>>  tsc-freq if it supports tsc-scaling.
> >>
> >>  This can be done by a management tool if desired.
> >>
> >
> >  Although, if we do this unconditionally (that is, also for tsc-scale
> >  hosts) then we get stable tsc even without supplying a tsc frequency
> >  argument... need to think about this.
>
> It has the advantage that it "just works", without the need to extend
> management tools and the like. And it makes migration more transparent
> to the guests.
>

Yes, exactly.  The flip side is that automagic stuff is sometimes 
unexpected and leads to breakage.  I'm not sure what the right thing is.

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH 2/3] qemu-x86: Add tsc_freq option to -cpu
@ 2011-07-19 15:55                 ` Avi Kivity
  0 siblings, 0 replies; 32+ messages in thread
From: Avi Kivity @ 2011-07-19 15:55 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: Joerg Roedel, Marcelo Tosatti, qemu-devel, kvm

On 07/19/2011 05:14 PM, Joerg Roedel wrote:
> On Tue, Jul 19, 2011 at 04:55:53PM +0300, Avi Kivity wrote:
> >  On 07/19/2011 04:54 PM, Avi Kivity wrote:
> >>  On 07/19/2011 04:30 PM, Joerg Roedel wrote:
>
> >>>  Hmm, I planned to do the VMSTATE thing in a follow-on patch-set. The
> >>>  plan is to read the VCPU tsc_freq at guest start time on !tsc-scale
> >>>  hosts and migrate it over so that the destination host can set the
> >>>  tsc-freq if it supports tsc-scaling.
> >>
> >>  This can be done by a management tool if desired.
> >>
> >
> >  Although, if we do this unconditionally (that is, also for tsc-scale
> >  hosts) then we get stable tsc even without supplying a tsc frequency
> >  argument... need to think about this.
>
> It has the advantage that it "just works", without the need to extend
> management tools and the like. And it makes migration more transparent
> to the guests.
>

Yes, exactly.  The flip side is that automagic stuff is sometimes 
unexpected and leads to breakage.  I'm not sure what the right thing is.

-- 
error compiling committee.c: too many arguments to function

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [PATCH 3/3] qemu-x86: Set tsc_khz in kvm when supported
  2011-07-19 11:48     ` [Qemu-devel] " Marcelo Tosatti
@ 2011-07-19 17:03       ` Jan Kiszka
  -1 siblings, 0 replies; 32+ messages in thread
From: Jan Kiszka @ 2011-07-19 17:03 UTC (permalink / raw)
  To: Marcelo Tosatti, Joerg Roedel; +Cc: Avi Kivity, kvm, qemu-devel

On 2011-07-19 13:48, Marcelo Tosatti wrote:
> On Thu, Jul 07, 2011 at 04:13:13PM +0200, Joerg Roedel wrote:
>> Make use of the KVM_TSC_CONTROL feature if available.
>>
>> Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
>> ---
>>  target-i386/kvm.c |   18 +++++++++++++++++-
>>  1 files changed, 17 insertions(+), 1 deletions(-)
>>
>> diff --git a/target-i386/kvm.c b/target-i386/kvm.c
>> index 10fb2c4..923d2d5 100644
>> --- a/target-i386/kvm.c
>> +++ b/target-i386/kvm.c
>> @@ -354,6 +354,7 @@ int kvm_arch_init_vcpu(CPUState *env)
>>      uint32_t unused;
>>      struct kvm_cpuid_entry2 *c;
>>      uint32_t signature[3];
>> +    int r;
>>  
>>      env->cpuid_features &= kvm_arch_get_supported_cpuid(s, 1, 0, R_EDX);
>>  
>> @@ -499,7 +500,22 @@ int kvm_arch_init_vcpu(CPUState *env)
>>  
>>      qemu_add_vm_change_state_handler(cpu_update_state, env);
>>  
>> -    return kvm_vcpu_ioctl(env, KVM_SET_CPUID2, &cpuid_data);
>> +    r = kvm_vcpu_ioctl(env, KVM_SET_CPUID2, &cpuid_data);
>> +    if (r)
>> +	    return r;
>> +
>> +#ifdef KVM_CAP_TSC_CONTROL
>> +    r = kvm_check_extension(env->kvm_state, KVM_CAP_TSC_CONTROL);
>> +    if (r && env->tsc_khz) {
>> +        r = kvm_vcpu_ioctl(env, KVM_SET_TSC_KHZ, env->tsc_khz);
>> +        if (r < 0) {
>> +            fprintf(stderr, "KVM_SET_TSC_KHZ failed\n");
>> +            return r;
>> +        }
>> +    }
>> +#endif
> 

#ifdef times are over, please clean up before pushing upstream.

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 32+ messages in thread

* Re: [Qemu-devel] [PATCH 3/3] qemu-x86: Set tsc_khz in kvm when supported
@ 2011-07-19 17:03       ` Jan Kiszka
  0 siblings, 0 replies; 32+ messages in thread
From: Jan Kiszka @ 2011-07-19 17:03 UTC (permalink / raw)
  To: Marcelo Tosatti, Joerg Roedel; +Cc: Avi Kivity, kvm, qemu-devel

On 2011-07-19 13:48, Marcelo Tosatti wrote:
> On Thu, Jul 07, 2011 at 04:13:13PM +0200, Joerg Roedel wrote:
>> Make use of the KVM_TSC_CONTROL feature if available.
>>
>> Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
>> ---
>>  target-i386/kvm.c |   18 +++++++++++++++++-
>>  1 files changed, 17 insertions(+), 1 deletions(-)
>>
>> diff --git a/target-i386/kvm.c b/target-i386/kvm.c
>> index 10fb2c4..923d2d5 100644
>> --- a/target-i386/kvm.c
>> +++ b/target-i386/kvm.c
>> @@ -354,6 +354,7 @@ int kvm_arch_init_vcpu(CPUState *env)
>>      uint32_t unused;
>>      struct kvm_cpuid_entry2 *c;
>>      uint32_t signature[3];
>> +    int r;
>>  
>>      env->cpuid_features &= kvm_arch_get_supported_cpuid(s, 1, 0, R_EDX);
>>  
>> @@ -499,7 +500,22 @@ int kvm_arch_init_vcpu(CPUState *env)
>>  
>>      qemu_add_vm_change_state_handler(cpu_update_state, env);
>>  
>> -    return kvm_vcpu_ioctl(env, KVM_SET_CPUID2, &cpuid_data);
>> +    r = kvm_vcpu_ioctl(env, KVM_SET_CPUID2, &cpuid_data);
>> +    if (r)
>> +	    return r;
>> +
>> +#ifdef KVM_CAP_TSC_CONTROL
>> +    r = kvm_check_extension(env->kvm_state, KVM_CAP_TSC_CONTROL);
>> +    if (r && env->tsc_khz) {
>> +        r = kvm_vcpu_ioctl(env, KVM_SET_TSC_KHZ, env->tsc_khz);
>> +        if (r < 0) {
>> +            fprintf(stderr, "KVM_SET_TSC_KHZ failed\n");
>> +            return r;
>> +        }
>> +    }
>> +#endif
> 

#ifdef times are over, please clean up before pushing upstream.

Jan

-- 
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2011-07-19 17:03 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-07 14:13 [PATCH 0/3][uq/master] Basic TSC-Scaling support v2 Joerg Roedel
2011-07-07 14:13 ` [Qemu-devel] " Joerg Roedel
2011-07-07 14:13 ` [PATCH 1/3] qemu: Add strtosz_suffix_unit function Joerg Roedel
2011-07-07 14:13   ` [Qemu-devel] " Joerg Roedel
2011-07-08  8:00   ` Markus Armbruster
2011-07-08  8:00     ` [Qemu-devel] " Markus Armbruster
2011-07-07 14:13 ` [PATCH 2/3] qemu-x86: Add tsc_freq option to -cpu Joerg Roedel
2011-07-07 14:13   ` [Qemu-devel] " Joerg Roedel
2011-07-19 11:46   ` Marcelo Tosatti
2011-07-19 11:46     ` [Qemu-devel] " Marcelo Tosatti
2011-07-19 12:20     ` Avi Kivity
2011-07-19 12:20       ` [Qemu-devel] " Avi Kivity
2011-07-19 12:56       ` Marcelo Tosatti
2011-07-19 12:56         ` [Qemu-devel] " Marcelo Tosatti
2011-07-19 13:30       ` Joerg Roedel
2011-07-19 13:30         ` [Qemu-devel] " Joerg Roedel
2011-07-19 13:54         ` Avi Kivity
2011-07-19 13:54           ` [Qemu-devel] " Avi Kivity
2011-07-19 13:55           ` Avi Kivity
2011-07-19 13:55             ` [Qemu-devel] " Avi Kivity
2011-07-19 14:14             ` Joerg Roedel
2011-07-19 14:14               ` [Qemu-devel] " Joerg Roedel
2011-07-19 15:55               ` Avi Kivity
2011-07-19 15:55                 ` [Qemu-devel] " Avi Kivity
2011-07-07 14:13 ` [PATCH 3/3] qemu-x86: Set tsc_khz in kvm when supported Joerg Roedel
2011-07-07 14:13   ` [Qemu-devel] " Joerg Roedel
2011-07-19 11:48   ` Marcelo Tosatti
2011-07-19 11:48     ` [Qemu-devel] " Marcelo Tosatti
2011-07-19 17:03     ` Jan Kiszka
2011-07-19 17:03       ` [Qemu-devel] " Jan Kiszka
2011-07-19 13:04 ` [PATCH 0/3][uq/master] Basic TSC-Scaling support v2 Marcelo Tosatti
2011-07-19 13:04   ` [Qemu-devel] " Marcelo Tosatti

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.