From: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@globallogic.com>
To: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Ian Campbell <Ian.Campbell@citrix.com>,
jinsong.liu@alibaba-inc.com, Tim Deegan <tim@xen.org>,
xen-devel <xen-devel@lists.xen.org>,
Jan Beulich <jbeulich@suse.com>,
jacob.shin@amd.com,
Andrii Tseglytskyi <andrii.tseglytskyi@globallogic.com>
Subject: Re: cpufreq implementation for OMAP under xen hypervisor.
Date: Thu, 25 Sep 2014 14:15:01 +0300 [thread overview]
Message-ID: <CAN58jivKwNpuuBWhH5LeNxytUU4BUe_1vKEn1w91evD+FvH2+g@mail.gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1409251111080.22344@kaball.uk.xensource.com>
On Thu, Sep 25, 2014 at 1:14 PM, Stefano Stabellini
<stefano.stabellini@eu.citrix.com> wrote:
> On Thu, 25 Sep 2014, Oleksandr Dmytryshyn wrote:
>> On Wed, Sep 24, 2014 at 5:36 PM, Stefano Stabellini
>> <stefano.stabellini@eu.citrix.com> wrote:
>> > On Tue, 16 Sep 2014, Oleksandr Dmytryshyn wrote:
>> >> On Wed, Sep 10, 2014 at 10:31 PM, Konrad Rzeszutek Wilk
>> >> <konrad.wilk@oracle.com> wrote:
>> >> > On Wed, Sep 10, 2014 at 07:35:47PM +0100, Stefano Stabellini wrote:
>> >> >> On Wed, 10 Sep 2014, Andrii Tseglytskyi wrote:
>> >> >> > Hi,
>> >> >> >
>> >> >> > On Wed, Sep 10, 2014 at 12:42 PM, Ian Campbell <Ian.Campbell@citrix.com> wrote:
>> >> >> > >
>> >> >> > > On Tue, 2014-09-09 at 22:41 +0100, Stefano Stabellini wrote:
>> >> >> > > > On Tue, 9 Sep 2014, Ian Campbell wrote:
>> >> >> > > > > On Thu, 2014-09-04 at 22:56 +0100, Stefano Stabellini wrote:
>> >> >> > > > > > I am trying to think of an alternative, such as passing the real cpu
>> >> >> > > > > > nodes to dom0 but then adding status = "disabled", but I am not sure
>> >> >> > > > > > whether Linux checks the status for cpu nodes.
>> >> >> > > > >
>> >> >> > > > > status = "disabled" is defined to have a specific (i.e. non-default)
>> >> >> > > > > meaning for cpu nodes, Julien mentioned this when I tried to add a
>> >> >> > > > > similar patch to Xen to ignore them. I think it basically means "present
>> >> >> > > > > but not running, you should start them!".
>> >> >> > > > >
>> >> >> > > > > > In addition this scheme
>> >> >> > > > > > wouldn't support the case where dom0 has more vcpus than pcpus on the
>> >> >> > > > > > system. Granted it is not very common and might even be detrimental for
>> >> >> > > > > > performances, but we should be able to support it.
>> >> >> > > > >
>> >> >> > > > > It's a bit of an edge case, for sure. I guess it wouldn't be totally
>> >> >> > > > > unreasonable to say that if you use this sort of configuration you may
>> >> >> > > > > not get cpufreq support.
>> >> >> > > > >
>> >> >> > > > > > Ian, what do you think about this?
>> >> >> > > > >
>> >> >> > > > > All the options suck in one way or another AFAICT. I think we are going
>> >> >> > > > > to be looking for the least bad solution not necessarily a good one.
>> >> >> > > > >
>> >> >> > > > > Fundamentally are we trying to avoid having to have a i2c subsystem etc
>> >> >> > > > > in the hypervisor to be be able to change the voltages before/after
>> >> >> > > > > changing the frequency?
>> >> >> > > > >
>> >> >> > > > > We can't just say "that's part of the cpufreq driver" since different
>> >> >> > > > > boards using the same SoC might use different voltage regulators, over
>> >> >> > > > > i2c or some other bus etc, so we end up with a matrix.
>> >> >> > > > >
>> >> >> > > > > It's arguable that we should be letting dom0 poke at that regulator
>> >> >> > > > > functionality anyway, at least not all of it. Taking that ability away
>> >> >> > > > > would necessarily imply more platform specific functionality in the
>> >> >> > > > > hypervisor.
>> >> >> > > >
>> >> >> > > > Right.
>> >> >> > > > I am afraid that in order to avoid more code in Xen, we end up with an
>> >> >> > > > unmaintainable interface and unupstreamable hacks in dom0.
>> >> >> > >
>> >> >> > > That's what I'm worried about to. Hence I'm wondering if we should just
>> >> >> > > do this in the hypervisor.
>> >> >> > >
>> >> >> > > Although there are a myriad of them the parts used to do voltage control
>> >> >> > > tend to be fairly simple.
>> >> >> > >
>> >> >> > > One concern I have is that i2c busses also tend to have other things on
>> >> >> > > them which dom0 might legitimately access (e.g. rtc), I'm not sure what
>> >> >> > > to suggest here.
>> >> >> >
>> >> >> > I would try to avoid i2c transactions in Xen. I2C driver is quite
>> >> >> > complicated in Linux kernel. It consists of several parts - common
>> >> >> > core + platform specific. I'm pretty sure Xen should not handle this.
>> >> >> > I think that establishing of event channel for frequency changing is a
>> >> >> > good idea. It would be good to try to implement this. In process of
>> >> >> > implementation we will see what is need to be resolved.
>> >> >>
>> >> >> OK, that's reasonable.
>> >> >>
>> >> >>
>> >> >> > The only question here is how to pass physical cpu to dom0.
>> >> >>
>> >> >> We can use a device tree based interface to pass the information to
>> >> >> dom0, but requiring a number of dom0 vcpus equal to the number of
>> >> >> physical cpus and in addition to that having to pin the vcpus each to a
>> >> >> different pcpu is quite a stringent limitation. However I don't know the
>> >> >> frequency changing interfaces in Linux well enough to know how hard
>> >> >> would be to lift it.
>> >> >>
>> >> >>
>> >> >> > Regarding x86.
>> >> >> > I'm not sure but maybe ACPI interface encapsulate voltage changing as well?
>> >> >>
>> >> >> I think so (but I am not an expert on that).
>> >> >
>> >> > The usual states are P and C states. The P states is the closes to what you
>> >> > are looking at:
>> >> >
>> >> > struct acpi_processor_px {
>> >> > u64 core_frequency; /* megahertz */
>> >> > u64 power; /* milliWatts */
>> >> > u64 transition_latency; /* microseconds */
>> >> > u64 bus_master_latency; /* microseconds */
>> >> > u64 control; /* control value */
>> >> > u64 status; /* success indicator */
>> >> > };
>> >> >
>> >> >>
>> >> >>
>> >> >>
>> >> >> > Regards,
>> >> >> > Andrii
>> >> >> >
>> >> >> >
>> >> >> > --
>> >> >> >
>> >> >> > Andrii Tseglytskyi | Embedded Dev
>> >> >> > GlobalLogic
>> >> >> > www.globallogic.com
>> >> >> >
>> >> >>
>> >> >> _______________________________________________
>> >> >> Xen-devel mailing list
>> >> >> Xen-devel@lists.xen.org
>> >> >> http://lists.xen.org/xen-devel
>> >>
>> >>
>> >> Cpufreq driver implementation.
>> >> ____________
>> >> / \
>> >> | xenpm tool |
>> >> \____________/
>> >> Dom0 kernel user-space
>> >> ---------------------------------------------------------------------------
>> >>
>> >> ________________ _____
>> >> / \ / \ CPU
>> >> | DevTree Parser | /->| ARM | driver
>> >> \________________/ | \_____/
>> >> Dom0 kernel | |
>> >> -----------------------------------------------------|-----|---------------
>> >> | |
>> >> _____________________________________ | |
>> >> | __________ ___________ | | |
>> >> | / \ / \ | | |
>> >> | | ondemand | | userspace | | | |
>> >> Registered | \__________/ \___________/ | | |
>> >> cpufreq | _____________ ___________ | | |
>> >> governor | / \ / \ | | |
>> >> | | performance | | powersave | | | |
>> >> | \_____________/ \___________/ | | |
>> >> |_____________________________________| | |
>> >> ^ | |
>> >> | | |
>> >> ______|_______ | |
>> >> / \ | | Change
>> >> | cpufreq core |-------------/ | frequency
>> >> \______________/ set/get freq |
>> >> commands |
>> >> Xen |
>> >> -----------------------------------------------------------|--------------
>> >> Hardware __V__
>> >> | |
>> >> | CPU |
>> >> |_____|
>> >>
>> >>
>> >> Description of the implementation:
>> >> Cpufreq core and registered cpufreq governors are located in xen. Dom0
>> >> has CPU driver
>> >> which can only change frequency of the physical CPUs. In addition this driver
>> >> can change CPUs regulator voltage. I'll reuse some ACPI-specific
>> >> variables for ARM.
>> >> Thus I can make minimum modification in the xen cpufreq driver and all utilities
>> >> (as xenpm) will be working without modification if the xen code. In first
>> >> implementation xenpm tool won't show information about C-states, but it can show
>> >> information about P-states and can change cpufreq parameters and
>> >> change governor.
>> >> DevTree parser is a part of the CPU driver in Dom0 and it will read information
>> >> from /cpus/cpu@0/private_data path instead of the original /cpus path.
>> >>
>> >> Steps of the initialization:
>> >> 1. Xen copies all cpu@0..cpu@N nodes (from input device tree) with properties to
>> >> /cpus/cpu@0/private_data node (device tree for Dom0). Thus we can have
>> >> any number
>> >> of VCPUs in Dom0 and we give all information about all physical CPUs in
>> >> the private_data node.
>> >>
>> >> 2. Driver in Dom0 will parse /cpus/cpu@0/private_data path instead of the /cpus
>> >> path and give the information about CPUs parameters to the hypervisor via
>> >> XENPF_set_processor_pminfo hypercall. (Some parameters are calculated in the
>> >> Dom0 driver and can not be calculated in the hypervisor).
>> >>
>> >> 3. Cpufreq core driver in the hypervisor will communicate via some interface
>> >> with Dom0 (event channel can be used to notify Dom0) and give some commands
>> >> to the CPU driver in Dom0. Those command are set/get frequency, etc.
>> >>
>> >> Can I implement cpufreq driver in this way?
>> >
>> > The architecture looks sane to me. As Konrad pointed out, the difficulty
>> > here is to be able to upstream the changes to the Linux driver in 2),
>> > that you later in the thread identified as
>> > drivers/cpufreq/cpufreq-cpu0.c.
>> I'll write driver drivers/xen/xen-cpufreq.c and it replace original
>> drivers/cpufreq/cpufreq.c
>> And in the original cpufreq-cpu0 driver I'll chande only one string -
>> path in the device tree
>> with the settings for the CPUs opp:
>> string
>> np = of_find_node_by_path("/cpus/cpu@0");
>> will changed to:
>> np = of_find_node_by_path("/cpus/cpu@0/private_data/cpu@0");
>
> There is no way that Linux upstream is going to accept code copied
> like that. However if you refactor the code from
> drivers/cpufreq/cpufreq-cpu0.c like Konrad suggested, moving the
> functions we need to a separate file, then you can call into these
> function from both cpufreq-cpu0.c and xen-cpufreq.c.
I'll see what can I do. At first I'll write and check the cpufreq
driver and then
I'll try to upstream patches for Linux and Xen hypervisor.
>
>> > If the changes are not invasive and you manage to upstream them in
>> > Linux, I am all for this solution.
>> In Linux kernel I should make few changes:
>> 1. Enable CONFIG_CPU_FREQ_TABLE
>> with disabled CONFIG_CPU_FREQ
>> 2. Enable CONFIG_GENERIC_CPUFREQ_CPU0
>> with disabled CONFIG_CPU_FREQ
>>
>> I mean make those configs dependent on
>> CONFIG_CPU_FREQ or CONFIX_XEN_DOM0
>> instead of
>> CONFIG_CPU_FREQ
next prev parent reply other threads:[~2014-09-25 11:15 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-12 10:57 cpufreq implementation for OMAP under xen hypervisor Oleksandr Dmytryshyn
2014-08-12 12:15 ` Stefano Stabellini
2014-08-12 12:19 ` Oleksandr Dmytryshyn
2014-08-19 14:02 ` Vitaly V. Ch
2014-08-21 23:05 ` Stefano Stabellini
2014-08-22 14:21 ` Vitaly Chernooky
2014-08-22 16:20 ` Stefano Stabellini
2014-08-21 11:00 ` Oleksandr Dmytryshyn
2014-08-21 23:31 ` Stefano Stabellini
2014-08-22 9:02 ` Oleksandr Dmytryshyn
2014-08-22 16:31 ` Stefano Stabellini
2014-08-22 16:51 ` Ian Campbell
2014-08-29 13:25 ` Oleksandr Dmytryshyn
2014-08-29 15:08 ` Andrii Tseglytskyi
2014-09-02 1:00 ` Stefano Stabellini
2014-09-02 9:06 ` Vitaly Chernooky
2014-09-02 15:43 ` Andrii Tseglytskyi
2014-09-02 18:39 ` Stefano Stabellini
2014-09-02 18:46 ` Andrii Tseglytskyi
2014-09-04 14:43 ` Oleksandr Dmytryshyn
2014-09-04 21:56 ` Stefano Stabellini
2014-09-09 10:19 ` Oleksandr Dmytryshyn
2014-09-09 21:52 ` Stefano Stabellini
2014-09-09 10:32 ` Ian Campbell
2014-09-09 21:41 ` Stefano Stabellini
2014-09-10 9:42 ` Ian Campbell
2014-09-10 10:19 ` Andrii Tseglytskyi
2014-09-10 18:35 ` Stefano Stabellini
2014-09-10 19:31 ` Konrad Rzeszutek Wilk
2014-09-16 13:49 ` Oleksandr Dmytryshyn
2014-09-17 17:06 ` Konrad Rzeszutek Wilk
2014-09-18 9:38 ` Oleksandr Dmytryshyn
2014-09-18 14:59 ` Konrad Rzeszutek Wilk
2014-09-19 9:38 ` Oleksandr Dmytryshyn
2014-09-24 14:36 ` Stefano Stabellini
2014-09-24 14:46 ` Konrad Rzeszutek Wilk
2014-09-25 9:13 ` Oleksandr Dmytryshyn
2014-09-25 9:08 ` Oleksandr Dmytryshyn
2014-09-25 10:14 ` Stefano Stabellini
2014-09-25 11:15 ` Oleksandr Dmytryshyn [this message]
2014-09-26 18:13 ` Konrad Rzeszutek Wilk
2014-09-29 9:45 ` Oleksandr Dmytryshyn
2014-09-29 15:18 ` Konrad Rzeszutek Wilk
2014-09-30 10:28 ` Oleksandr Dmytryshyn
2014-09-30 17:37 ` Konrad Rzeszutek Wilk
2014-09-11 9:43 ` Ian Campbell
2014-09-09 13:25 ` Vitaly Chernooky
2014-09-09 21:58 ` Stefano Stabellini
2014-09-10 10:15 ` Andrii Tseglytskyi
2014-09-10 10:24 ` Vitaly Chernooky
2014-09-10 11:18 ` Andrii Tseglytskyi
2014-09-10 18:37 ` Stefano Stabellini
2014-09-11 7:51 ` Vitaly Chernooky
2014-09-10 11:24 ` Vitaly Chernooky
2014-09-10 14:28 ` Vitaly Chernooky
2014-09-10 18:41 ` Stefano Stabellini
2014-09-11 7:48 ` Vitaly Chernooky
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=CAN58jivKwNpuuBWhH5LeNxytUU4BUe_1vKEn1w91evD+FvH2+g@mail.gmail.com \
--to=oleksandr.dmytryshyn@globallogic.com \
--cc=Ian.Campbell@citrix.com \
--cc=andrii.tseglytskyi@globallogic.com \
--cc=jacob.shin@amd.com \
--cc=jbeulich@suse.com \
--cc=jinsong.liu@alibaba-inc.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=tim@xen.org \
--cc=xen-devel@lists.xen.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).