All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jan Beulich" <jbeulich@novell.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] x86: add hypercall to query current underlying pCPU's frequency
Date: Fri, 19 Sep 2008 14:10:49 +0100	[thread overview]
Message-ID: <48D3C0F9.76E4.0078.0@novell.com> (raw)

Signed-off-by: Jan Beulich <jbeulich@novell.com>

Index: 2008-09-19/xen/arch/x86/platform_hypercall.c
===================================================================
--- 2008-09-19.orig/xen/arch/x86/platform_hypercall.c	2008-09-19 14:12:02.000000000 +0200
+++ 2008-09-19/xen/arch/x86/platform_hypercall.c	2008-09-19 14:12:56.000000000 +0200
@@ -21,7 +21,7 @@
 #include <xen/acpi.h>
 #include <asm/current.h>
 #include <public/platform.h>
-#include <acpi/cpufreq/processor_perf.h>
+#include <acpi/cpufreq/cpufreq.h>
 #include <asm/edd.h>
 #include <asm/mtrr.h>
 #include "cpu/mtrr/mtrr.h"
@@ -55,6 +55,7 @@ static long cpu_frequency_change_helper(
 ret_t do_platform_op(XEN_GUEST_HANDLE(xen_platform_op_t) u_xenpf_op)
 {
     ret_t ret = 0;
+    struct vcpu *v;
     struct xen_platform_op curop, *op = &curop;
 
     if ( !IS_PRIV(current->domain) )
@@ -312,7 +313,6 @@ ret_t do_platform_op(XEN_GUEST_HANDLE(xe
     {
         uint32_t cpu;
         uint64_t idletime, now = NOW();
-        struct vcpu *v;
         struct xenctl_cpumap ctlmap;
         cpumask_t cpumap;
         XEN_GUEST_HANDLE(uint8) cpumap_bitmap;
@@ -482,6 +482,20 @@ ret_t do_platform_op(XEN_GUEST_HANDLE(xe
             break;
         }
         break;
+
+    case XENPF_get_cpu_freq:
+        if ( op->u.get_cpu_freq.vcpu >= MAX_VIRT_CPUS ||
+             !(v = current->domain->vcpu[op->u.get_cpu_freq.vcpu]) )
+        {
+            ret = -EINVAL;
+            break;
+        }
+
+        op->u.get_cpu_freq.freq = cpufreq_cpu_policy[v->processor] ?
+            cpufreq_cpu_policy[v->processor]->cur : 0;
+        if ( copy_field_to_guest(u_xenpf_op, op, u.get_cpu_freq.freq) )
+            ret = -EFAULT;
+        break;
  
     default:
         ret = -ENOSYS;
Index: 2008-09-19/xen/arch/x86/x86_64/platform_hypercall.c
===================================================================
--- 2008-09-19.orig/xen/arch/x86/x86_64/platform_hypercall.c	2008-09-19 14:12:02.000000000 +0200
+++ 2008-09-19/xen/arch/x86/x86_64/platform_hypercall.c	2008-09-19 13:59:35.000000000 +0200
@@ -21,6 +21,8 @@ DEFINE_XEN_GUEST_HANDLE(compat_platform_
 #define xen_processor_power_t   compat_processor_power_t
 #define set_cx_pminfo           compat_set_cx_pminfo
 
+#define xenpf_get_cpu_freq      compat_pf_get_cpu_freq
+
 #define xenpf_enter_acpi_sleep compat_pf_enter_acpi_sleep
 
 #define COMPAT
Index: 2008-09-19/xen/include/public/platform.h
===================================================================
--- 2008-09-19.orig/xen/include/public/platform.h	2008-09-19 14:12:02.000000000 +0200
+++ 2008-09-19/xen/include/public/platform.h	2008-09-19 13:59:35.000000000 +0200
@@ -312,6 +312,16 @@ struct xenpf_set_processor_pminfo {
 typedef struct xenpf_set_processor_pminfo xenpf_set_processor_pminfo_t;
 DEFINE_XEN_GUEST_HANDLE(xenpf_set_processor_pminfo_t);
 
+#define XENPF_get_cpu_freq        55
+struct xenpf_get_cpu_freq {
+    /* IN variables */
+    uint32_t vcpu;
+    /* OUT variables */
+    uint32_t freq; /* in kHz */
+};
+typedef struct xenpf_get_cpu_freq xenpf_get_cpu_freq_t;
+DEFINE_XEN_GUEST_HANDLE(xenpf_get_cpu_freq_t);
+
 struct xen_platform_op {
     uint32_t cmd;
     uint32_t interface_version; /* XENPF_INTERFACE_VERSION */
@@ -327,6 +337,7 @@ struct xen_platform_op {
         struct xenpf_change_freq       change_freq;
         struct xenpf_getidletime       getidletime;
         struct xenpf_set_processor_pminfo set_pminfo;
+        struct xenpf_get_cpu_freq      get_cpu_freq;
         uint8_t                        pad[128];
     } u;
 };

             reply	other threads:[~2008-09-19 13:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-19 13:10 Jan Beulich [this message]
2008-09-20  8:34 ` [PATCH] x86: add hypercall to query current underlying pCPU's frequency Keir Fraser
2008-09-22  2:26   ` Tian, Kevin
2008-09-22  7:04     ` Keir Fraser
2008-09-22  7:18       ` Tian, Kevin
2008-09-22  7:55   ` [PATCH] x86: add hypercall to query currentunderlying " Jan Beulich
2008-09-22  8:47     ` Keir Fraser
2008-09-22  9:18       ` [PATCH] x86: add hypercall to querycurrentunderlying " Jan Beulich
2008-09-22  9:24         ` Keir Fraser

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48D3C0F9.76E4.0078.0@novell.com \
    --to=jbeulich@novell.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.