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/
Home Products Support Community News


Re: [Xen-users] Setting CPU (core) frequency from dom0

To: "Tian, Kevin" <kevin.tian@xxxxxxxxx>
Subject: Re: [Xen-users] Setting CPU (core) frequency from dom0
From: Alberto Munoz <amunoz0221@xxxxxxxxxxx>
Date: Mon, 24 Nov 2008 16:30:13 -0800
Cc: "Liu, Jinsong" <jinsong.liu@xxxxxxxxx>, "bmunoz@xxxxxxx" <bmunoz@xxxxxxx>, "xen-users@xxxxxxxxxxxxxxxxxxx" <xen-users@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Mon, 24 Nov 2008 16:31:18 -0800
Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta; t=1227573018; bh=cf5Q8bxS9HXkviqb6DAp8afOFC0=; h=DomainKey-Signature:MIME-Version:Sender:Reply-To:In-Reply-To: References:Date:X-Google-Sender-Auth:Message-ID:Subject:From:To:Cc: Content-Type:X-GMailtapped-By:X-GMailtapped; b=VSdYTNauaDGGcr/lNEm ULSCAiSxs2gB3eqTmYv4usBHLqR8iXgVcWFK4xXysU6l1VbEvPBj/3rVMRsBbzhwo0w ==
Domainkey-signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns; h=mime-version:sender:reply-to:in-reply-to:references:date: x-google-sender-auth:message-id:subject:from:to:cc:content-type: x-gmailtapped-by:x-gmailtapped; b=UMKySY6ArqcJhNft3dVX9JLNA84Q0VXl3IAy0vzY6gjnt13Ug6pzhypJVMoOUSvL0 jx7cVX4ocyWu/wE/TQi6A==
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <0A882F4D99BBF6449D58E61AAFD7EDD601E23B5E@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-users-request@lists.xensource.com?subject=help>
List-id: Xen user discussion <xen-users.lists.xensource.com>
List-post: <mailto:xen-users@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=unsubscribe>
References: <fe5f99e40811191050m3cf00eb4wd5a522471962376@xxxxxxxxxxxxxx> <0A882F4D99BBF6449D58E61AAFD7EDD601E23B40@xxxxxxxxxxxxxxxxxxxxxxxxxxxx> <fe5f99e40811201038q96d0830i40ff3ffb3f52c751@xxxxxxxxxxxxxx> <0A882F4D99BBF6449D58E61AAFD7EDD601E23B53@xxxxxxxxxxxxxxxxxxxxxxxxxxxx> <fe5f99e40811210847s1e38aceai9d20278ecd48c058@xxxxxxxxxxxxxx> <0A882F4D99BBF6449D58E61AAFD7EDD601E23B5E@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Reply-to: bmunoz@xxxxxxx
Sender: xen-users-bounces@xxxxxxxxxxxxxxxxxxx
Hi Kevin,

As it turns out, my problem was due to not having all of the right options set for the dom0 kernel (in the .config file). The one option that got me is CONFIG_X86_POWERNOW_K8_ACPI. As it turns out, that option, when not set, replaces a number of the functions in powernow-k8.c with stubs that return -ENODEV.

Once I got that option set, everyting worked as it should.

For those of you interested, here is what I did:

- set cpufreq=dom0-kernel option for the kernel line in the grub menu file (/boot/grub/menu.lst for ubuntu distributions)

- set option CONFIG_CPU_FREQ for the dom0 kernel (I added an entry to linux-2.6.18-xen.hg/arch/x86_64/Kconfig)

- Ensure that CONFIG_ACPI_PROCESSOR is set to "y" (not "m"!) in the configuration file. In my case this option was set to "m", and that was preventing CONFIG_X86_POWERNOW_K8_ACPI from being set.

- Use the sysfs interface (/sys/devices/system/cpu/cpu*/cpufreq/) to set the CPUs to the desired frequency.

On Sun, Nov 23, 2008 at 9:06 PM, Tian, Kevin <kevin.tian@xxxxxxxxx> wrote:
We can copy you in the CC list when submitting patches.

Yes, that would be great. Thank you.

We didn't try mode A on 3.3, since we don't think it right thing to do. But from what you have done, it looks enough. :-)

Yes, I works just fine.

Thank you for all the help.


From: Alberto Munoz [mailto:ajmunoz@xxxxxxxxxx]
Sent: Saturday, November 22, 2008 12:47 AM
To: Tian, Kevin
Cc: bmunoz@xxxxxxx; xen-users@xxxxxxxxxxxxxxxxxxx; Liu, Jinsong

Subject: Re: [Xen-users] Setting CPU (core) frequency from dom0

Hi Kevin,

On Thu, Nov 20, 2008 at 7:02 PM, Tian, Kevin <kevin.tian@xxxxxxxxx> wrote:
ETA can be in one or two weeks, and now coding is close to end (by Jinsong). This patch sets will cover many control bits besides allowing user to change freq as I said earlier.

Excellent! How do I find out when the patch has been made available?
For the code you mentioned, it's one bug since as you cited that return-0 means success. However it looks that this warning doesn't hurt the behavior:
if (!cpufreq_register_notifier(&time_cpufreq_notifier_block,
                        CPUFREQ_TRANSITION_NOTIFIER)) {
                printk(KERN_ERR "failed to set up cpufreq notifier\n");
                return -ENODEV;
return 0;
Notifier is registered successfully and there's no code to reverse the effect even when -ENODEV is returned. :-)

Yes, I figured that out yesterday. Other than printing the error, the system does nothing with the -ENODEV return. Still, I am not getting a sysfs interface for cpufreq and I haven't been able to figure out why.

In case this was not clear, I am trying to use method A (cpufreq=dom0-kernel) with Xen 3.3 (not 3.2). Does that not work in Xen 3.3?

Also, do you happen to know of a place where I can get a list of what needs to be set up in order to get this frequency scaling to work. I am pretty sure that my problem with not getting the sysfs interface for cpufreq (it is available for other things) is related to something I am missing in the configuration. So far, what I have done (for method A) is:

- Set the option cpufreq=dom0-kernel as an option to the Xen hypervisor (in grub)

- Disable PROCESSOR_EXTERNAL_CONTROL in drivers/acpi/Kconfig (for dom0)

- Enable CONFIG_CPU_FREQ for dom0 (I did this from arch/x86_64/Kconfig)

Perhaps there is a BIOS setting for the CPU that I am unaware of (my machine is using Barcelona CPUs)?

Thank you,


Sent: Friday, November 21, 2008 2:39 AM
To: Tian, Kevin
Cc: bmunoz@xxxxxxx; xen-users@xxxxxxxxxxxxxxxxxxx
Subject: Re: [Xen-users] Setting CPU (core) frequency from dom0

Hi Kevin,

Thank you very much for the reply.

PLease see comments below.


On Wed, Nov 19, 2008 at 7:05 PM, Tian, Kevin <kevin.tian@xxxxxxxxx> wrote:
Your description is basically correct. Do you want to control cpu frequency from dom0 user level, or just try cpufreq governor in dom0?

I would like to control frequency from dom0. I want to arbitrarily set the  CPU frequency to a value and have it stay there (regardless of  the load on that CPU) until I change it.

For the former, we're currently adding more flexibility to xen cpufreq (such as user space governor) and control options to xenpm (such as manually changing freq), which is expected to reach xen upstream soon.

Yes, I thik this is what I need (ability to manually change frequency). Do you have an ETA (estimated time of arrival) for that functionality?
For the latter, it's suboptimal with limitations which is why xen cpufreq is develeoped. You may manually disable PROCESSOR_EXTERNAL_CONTROL in drivers/acpi/Kconfig to rebuild dom0 kernel for mode A.

OK.  I will do that.

By the way, I have been running onto an error  when booting (in mode A). The function  cpufreq_time_setup() in linux-2.6.18-xen.hg/arch/i386/kernel/time-xen.c is printing the following message during boot (and returning -ENODEV to its caller):

failed to set up cpufreq notifier

Further examination of the code shows that this happens when  notifier_chain_register() in linux-2.6.18-xen.hg/kernel/sys.c returns 0. The problem is that in the code I have, that function ALWAYS returns 0. The code for that function is as follows:

static int notifier_chain_register(struct notifier_block **nl,
        struct notifier_block *n)
    while ((*nl) != NULL) {
        if (n->priority > (*nl)->priority)
        nl = &((*nl)->next);
    n->next = *nl;
    rcu_assign_pointer(*nl, n);
    return 0;

think (but are not 100% sure yet) that as a result of this error, dom0 is not creating a cpufreq /sys interface (i.e

Do you happen to know what may be going on? perhaps I am just misreading the code? or perhaps not disabling PROCESSOR_EXTERNAL_CONTROL is what is causing this behavior? I will run some experiments on this last thing today.

Thanks again,



From: xen-users-bounces@xxxxxxxxxxxxxxxxxxx [mailto:xen-users-bounces@xxxxxxxxxxxxxxxxxxx] On Behalf Of Alberto Munoz
Sent: Thursday, November 20, 2008 2:50 AM
To: xen-users@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-users] Setting CPU (core) frequency from dom0

Hello everyone,

I am running some experiments that require changing the frequency of a CPU in a SunFire machine (32-core quad socket AMD Barcelona).

For what I have found (bits and pieces but not a comprehensive description), there are two meachisms for controlling core (most probably socket) frequency in Xen:

A- The older (xen-3.2.1) mechnism through dom0 (option cpufreq=dom0-kernel), which for what I gather uses a module in dom0 (cpufreqd?) that allows one to set cpu frequency.

B- The newer (xen-3.3), which has moved the governor to the hypervisor (option cpufreq=xen), which other than a utility to read processor P and C states (xenpm) does not (yet) allow user (dom0) control of CPU frequency.

My first question is whetherot what I have written above is accurate. My second question is where can I find detailed information on how to set up my system to make use of A above and be able to set cpu frequency "manually" from Dom0 (assuming that is still possible in Xen 3.3).

I am running the latest testing version of Xen 3.3 (about a week old).

Any information would be greatly appreciated.

Thank you,


Xen-users mailing list

Xen-users mailing list