WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] xenpm: Allow user to enable/disable dbs g

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xenpm: Allow user to enable/disable dbs governor turbo mode.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 08 Feb 2010 00:55:17 -0800
Delivery-date: Mon, 08 Feb 2010 00:55:55 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1265618920 0
# Node ID a06e9def02bb54b1231be027cce1ce9a44a4d248
# Parent  4f2d9156424defd85d39bc91e17dc9d2533224f5
xenpm: Allow user to enable/disable dbs governor turbo mode.

Signed-off-by: Lu Guanqun <guanqun.lu@xxxxxxxxx>
---
 tools/libxc/xc_pm.c                    |   25 ++++++++++++++++
 tools/libxc/xenctrl.h                  |    2 +
 tools/misc/xenpm.c                     |   50 +++++++++++++++++++++++++++++++++
 xen/drivers/acpi/pmstat.c              |   16 +++++++++-
 xen/drivers/cpufreq/cpufreq_ondemand.c |   37 ++++++++++++++++++++++--
 xen/drivers/cpufreq/utility.c          |   13 ++++++++
 xen/include/acpi/cpufreq/cpufreq.h     |    6 +++
 xen/include/public/sysctl.h            |    5 +++
 8 files changed, 150 insertions(+), 4 deletions(-)

diff -r 4f2d9156424d -r a06e9def02bb tools/libxc/xc_pm.c
--- a/tools/libxc/xc_pm.c       Mon Feb 08 08:43:25 2010 +0000
+++ b/tools/libxc/xc_pm.c       Mon Feb 08 08:48:40 2010 +0000
@@ -425,3 +425,28 @@ int xc_set_cpuidle_max_cstate(int xc_han
     return do_sysctl(xc_handle, &sysctl);
 }
 
+int xc_enable_turbo(int xc_handle, int cpuid)
+{
+    DECLARE_SYSCTL;
+
+    if ( xc_handle < 0 )
+        return -EINVAL;
+
+    sysctl.cmd = XEN_SYSCTL_pm_op;
+    sysctl.u.pm_op.cmd = XEN_SYSCTL_pm_op_enable_turbo;
+    sysctl.u.pm_op.cpuid = cpuid;
+    return do_sysctl(xc_handle, &sysctl);
+}
+
+int xc_disable_turbo(int xc_handle, int cpuid)
+{
+    DECLARE_SYSCTL;
+
+    if ( xc_handle < 0 )
+        return -EINVAL;
+
+    sysctl.cmd = XEN_SYSCTL_pm_op;
+    sysctl.u.pm_op.cmd = XEN_SYSCTL_pm_op_disable_turbo;
+    sysctl.u.pm_op.cpuid = cpuid;
+    return do_sysctl(xc_handle, &sysctl);
+}
diff -r 4f2d9156424d -r a06e9def02bb tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h     Mon Feb 08 08:43:25 2010 +0000
+++ b/tools/libxc/xenctrl.h     Mon Feb 08 08:48:40 2010 +0000
@@ -1312,6 +1312,8 @@ int xc_get_cpuidle_max_cstate(int xc_han
 int xc_get_cpuidle_max_cstate(int xc_handle, uint32_t *value);
 int xc_set_cpuidle_max_cstate(int xc_handle, uint32_t value);
 
+int xc_enable_turbo(int xc_handle, int cpuid);
+int xc_disable_turbo(int xc_handle, int cpuid);
 /**
  * tmem operations
  */
diff -r 4f2d9156424d -r a06e9def02bb tools/misc/xenpm.c
--- a/tools/misc/xenpm.c        Mon Feb 08 08:43:25 2010 +0000
+++ b/tools/misc/xenpm.c        Mon Feb 08 08:48:40 2010 +0000
@@ -62,6 +62,8 @@ void show_help(void)
             " set-max-cstate        <num>         set the C-State limitation 
(<num> >= 0)\n"
             " start [seconds]                     start collect Cx/Px 
statistics,\n"
             "                                     output after CTRL-C or 
SIGINT or several seconds.\n"
+            " enable-turbo-mode     [cpuid]       enable Turbo Mode in DBS 
governor.\n"
+            " disable-turbo-mode    [cpuid]       disable Turbo Mode in DBS 
governor.\n"
             );
 }
 /* wrapper function */
@@ -527,6 +529,8 @@ static void print_cpufreq_para(int cpuid
                p_cpufreq->u.ondemand.sampling_rate);
         printf("    up_threshold     : %u\n",
                p_cpufreq->u.ondemand.up_threshold);
+        printf("    turbo mode       : %s\n",
+               p_cpufreq->u.ondemand.turbo_enabled ? "enabled" : "disabled");
     }
 
     printf("scaling_avail_freq   :");
@@ -951,6 +955,50 @@ void set_max_cstate_func(int argc, char 
     return;
 }
 
+void enable_turbo_mode(int argc, char *argv[])
+{
+    int cpuid = -1;
+
+    if ( argc > 0 && sscanf(argv[0], "%d", &cpuid) != 1 )
+        cpuid = -1;
+
+    if ( cpuid >= max_cpu_nr )
+        cpuid = -1;
+
+    if ( cpuid < 0 )
+    {
+        /* enable turbo modes on all cpus,
+         * only make effects on dbs governor */
+        int i;
+        for ( i = 0; i < max_cpu_nr; i++ )
+            xc_enable_turbo(xc_fd, i);
+    }
+    else
+        xc_enable_turbo(xc_fd, cpuid);
+}
+
+void disable_turbo_mode(int argc, char *argv[])
+{
+    int cpuid = -1;
+
+    if ( argc > 0 && sscanf(argv[0], "%d", &cpuid) != 1 )
+        cpuid = -1;
+
+    if ( cpuid >= max_cpu_nr )
+        cpuid = -1;
+
+    if ( cpuid < 0 )
+    {
+        /* disable turbo modes on all cpus,
+         * only make effects on dbs governor */
+        int i;
+        for ( i = 0; i < max_cpu_nr; i++ )
+            xc_disable_turbo(xc_fd, i);
+    }
+    else
+        xc_disable_turbo(xc_fd, cpuid);
+}
+
 struct {
     const char *name;
     void (*function)(int argc, char *argv[]);
@@ -971,6 +1019,8 @@ struct {
     { "get-vcpu-migration-delay", get_vcpu_migration_delay_func},
     { "set-vcpu-migration-delay", set_vcpu_migration_delay_func},
     { "set-max-cstate", set_max_cstate_func},
+    { "enable-turbo-mode", enable_turbo_mode },
+    { "disable-turbo-mode", disable_turbo_mode },
 };
 
 int main(int argc, char *argv[])
diff -r 4f2d9156424d -r a06e9def02bb xen/drivers/acpi/pmstat.c
--- a/xen/drivers/acpi/pmstat.c Mon Feb 08 08:43:25 2010 +0000
+++ b/xen/drivers/acpi/pmstat.c Mon Feb 08 08:48:40 2010 +0000
@@ -298,7 +298,9 @@ static int get_cpufreq_para(struct xen_s
             &op->u.get_para.u.ondemand.sampling_rate_max,
             &op->u.get_para.u.ondemand.sampling_rate_min,
             &op->u.get_para.u.ondemand.sampling_rate,
-            &op->u.get_para.u.ondemand.up_threshold); 
+            &op->u.get_para.u.ondemand.up_threshold);
+        op->u.get_para.u.ondemand.turbo_enabled =
+            cpufreq_dbs_get_turbo_status(op->cpuid);
     }
 
     return ret;
@@ -549,6 +551,18 @@ int do_pm_op(struct xen_sysctl_pm_op *op
         break;
     }
 
+    case XEN_SYSCTL_pm_op_enable_turbo:
+    {
+        cpufreq_dbs_enable_turbo(op->cpuid);
+        break;
+    }
+
+    case XEN_SYSCTL_pm_op_disable_turbo:
+    {
+        cpufreq_dbs_disable_turbo(op->cpuid);
+        break;
+    }
+
     default:
         printk("not defined sub-hypercall @ do_pm_op\n");
         ret = -ENOSYS;
diff -r 4f2d9156424d -r a06e9def02bb xen/drivers/cpufreq/cpufreq_ondemand.c
--- a/xen/drivers/cpufreq/cpufreq_ondemand.c    Mon Feb 08 08:43:25 2010 +0000
+++ b/xen/drivers/cpufreq/cpufreq_ondemand.c    Mon Feb 08 08:48:40 2010 +0000
@@ -58,6 +58,9 @@ static struct dbs_tuners {
 
 static struct timer dbs_timer[NR_CPUS];
 
+/* Turbo Mode */
+static int turbo_detected = 0;
+
 int write_ondemand_sampling_rate(unsigned int sampling_rate)
 {
     if ( (sampling_rate > MAX_SAMPLING_RATE / MICROSECS(1)) ||
@@ -100,15 +103,21 @@ static void dbs_check_cpu(struct cpu_dbs
     uint64_t cur_ns, total_ns;
     uint64_t max_load_freq = 0;
     struct cpufreq_policy *policy;
+    unsigned int max;
     unsigned int j;
 
     if (!this_dbs_info->enable)
         return;
 
     policy = this_dbs_info->cur_policy;
+    max = policy->max;
+    if (turbo_detected && !this_dbs_info->turbo_enabled) {
+        if (max > policy->cpuinfo.second_max_freq)
+            max = policy->cpuinfo.second_max_freq;
+    }
 
     if (unlikely(policy->resume)) {
-        __cpufreq_driver_target(policy, policy->max,CPUFREQ_RELATION_H);
+        __cpufreq_driver_target(policy, max,CPUFREQ_RELATION_H);
         return;
     }
 
@@ -145,9 +154,9 @@ static void dbs_check_cpu(struct cpu_dbs
     /* Check for frequency increase */
     if (max_load_freq > dbs_tuners_ins.up_threshold * policy->cur) {
         /* if we are already at full speed then break out early */
-        if (policy->cur == policy->max)
+        if (policy->cur == max)
             return;
-        __cpufreq_driver_target(policy, policy->max, CPUFREQ_RELATION_H);
+        __cpufreq_driver_target(policy, max, CPUFREQ_RELATION_H);
         return;
     }
 
@@ -265,6 +274,7 @@ int cpufreq_governor_dbs(struct cpufreq_
             } else
                 dbs_tuners_ins.sampling_rate = usr_sampling_rate;
         }
+        this_dbs_info->turbo_enabled = 1;
         dbs_timer_init(this_dbs_info);
 
         break;
@@ -335,6 +345,11 @@ struct cpufreq_governor cpufreq_gov_dbs 
 
 static int __init cpufreq_gov_dbs_init(void)
 {
+    unsigned int eax = cpuid_eax(6);
+    if ( eax & 0x2 ) {
+        turbo_detected = 1;
+        printk(XENLOG_INFO "Turbo Mode detected!\n");
+    }
     return cpufreq_register_governor(&cpufreq_gov_dbs);
 }
 __initcall(cpufreq_gov_dbs_init);
@@ -379,3 +394,19 @@ void cpufreq_dbs_timer_resume(void)
         }
     }
 }
+
+void cpufreq_dbs_enable_turbo(int cpuid)
+{
+    per_cpu(cpu_dbs_info, cpuid).turbo_enabled = 1;
+}
+
+void cpufreq_dbs_disable_turbo(int cpuid)
+{
+    per_cpu(cpu_dbs_info, cpuid).turbo_enabled = 0;
+}
+
+unsigned int cpufreq_dbs_get_turbo_status(int cpuid)
+{
+    return turbo_detected && per_cpu(cpu_dbs_info, cpuid).turbo_enabled;
+}
+
diff -r 4f2d9156424d -r a06e9def02bb xen/drivers/cpufreq/utility.c
--- a/xen/drivers/cpufreq/utility.c     Mon Feb 08 08:43:25 2010 +0000
+++ b/xen/drivers/cpufreq/utility.c     Mon Feb 08 08:48:40 2010 +0000
@@ -208,6 +208,7 @@ int cpufreq_frequency_table_cpuinfo(stru
 {
     unsigned int min_freq = ~0;
     unsigned int max_freq = 0;
+    unsigned int second_max_freq = 0;
     unsigned int i;
 
     for (i=0; (table[i].frequency != CPUFREQ_TABLE_END); i++) {
@@ -219,9 +220,21 @@ int cpufreq_frequency_table_cpuinfo(stru
         if (freq > max_freq)
             max_freq = freq;
     }
+    for (i=0; (table[i].frequency != CPUFREQ_TABLE_END); i++) {
+        unsigned int freq = table[i].frequency;
+        if (freq == CPUFREQ_ENTRY_INVALID || freq == max_freq)
+            continue;
+        if (freq > second_max_freq)
+            second_max_freq = freq;
+    }
+    if (second_max_freq == 0)
+        second_max_freq = max_freq;
+    printk(XENLOG_INFO "max_freq: %u    second_max_freq: %u\n",
+           max_freq, second_max_freq);
 
     policy->min = policy->cpuinfo.min_freq = min_freq;
     policy->max = policy->cpuinfo.max_freq = max_freq;
+    policy->cpuinfo.second_max_freq = second_max_freq;
 
     if (policy->min == ~0)
         return -EINVAL;
diff -r 4f2d9156424d -r a06e9def02bb xen/include/acpi/cpufreq/cpufreq.h
--- a/xen/include/acpi/cpufreq/cpufreq.h        Mon Feb 08 08:43:25 2010 +0000
+++ b/xen/include/acpi/cpufreq/cpufreq.h        Mon Feb 08 08:48:40 2010 +0000
@@ -33,6 +33,7 @@ struct acpi_cpufreq_data {
 
 struct cpufreq_cpuinfo {
     unsigned int        max_freq;
+    unsigned int        second_max_freq;    /* P1 if Turbo Mode is on */
     unsigned int        min_freq;
     unsigned int        transition_latency; /* in 10^(-9) s = nanoseconds */
 };
@@ -222,6 +223,7 @@ struct cpu_dbs_info_s {
     int cpu;
     unsigned int enable:1;
     unsigned int stoppable:1;
+    unsigned int turbo_enabled:1;
 };
 
 int cpufreq_governor_dbs(struct cpufreq_policy *policy, unsigned int event);
@@ -236,4 +238,8 @@ int write_userspace_scaling_setspeed(uns
 
 void cpufreq_dbs_timer_suspend(void);
 void cpufreq_dbs_timer_resume(void);
+
+void cpufreq_dbs_enable_turbo(int cpuid);
+void cpufreq_dbs_disable_turbo(int cpuid);
+unsigned int cpufreq_dbs_get_turbo_status(int cpuid);
 #endif /* __XEN_CPUFREQ_PM_H__ */
diff -r 4f2d9156424d -r a06e9def02bb xen/include/public/sysctl.h
--- a/xen/include/public/sysctl.h       Mon Feb 08 08:43:25 2010 +0000
+++ b/xen/include/public/sysctl.h       Mon Feb 08 08:48:40 2010 +0000
@@ -298,6 +298,7 @@ struct xen_ondemand {
 
     uint32_t sampling_rate;
     uint32_t up_threshold;
+    uint32_t turbo_enabled;
 };
 typedef struct xen_ondemand xen_ondemand_t;
 
@@ -389,6 +390,10 @@ struct xen_sysctl_pm_op {
     /* set scheduler migration cost value */
     #define XEN_SYSCTL_pm_op_set_vcpu_migration_delay   0x24
     #define XEN_SYSCTL_pm_op_get_vcpu_migration_delay   0x25
+
+    /* enable/disable turbo mode when in dbs governor */
+    #define XEN_SYSCTL_pm_op_enable_turbo               0x26
+    #define XEN_SYSCTL_pm_op_disable_turbo              0x27
 
     uint32_t cmd;
     uint32_t cpuid;

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] xenpm: Allow user to enable/disable dbs governor turbo mode., Xen patchbot-unstable <=