Currently cpufreq_add_dev() firsts allocates policy, calls driver->init() and
then checks if this cpu is already managed or not. And if it is already managed,
free its policy.
We can save all this if we somehow know cpu is managed or not in advance.
policy->related_cpus contains list of all valid sibling cpus of policy->cpu. We
can check this to know if current cpu is already managed.
>From now on, platforms don't really need to set related_cpus from their init()
routines, as the same work is done by core too.
If platform driver needs to set the related_cpus mask with some additional cpus,
other than cpus present in policy->cpus, they are free to do it as we aren't
overriding anything.
Signed-off-by: Viresh Kumar <viresh.kumar(a)linaro.org>
Tested-by: Shawn Guo <shawn.guo(a)linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki(a)intel.com>
---
V2->V3:
- Set all cpus present in policy->cpus in related_cpus as well.
- Remove code to set related_cpus from SPEAr cpufreq driver.
drivers/cpufreq/cpufreq.c | 158 +++++++++++++++-------------------------
drivers/cpufreq/spear-cpufreq.c | 1 -
2 files changed, 58 insertions(+), 101 deletions(-)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index f1bb8f8..db81382 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -554,8 +554,6 @@ static ssize_t show_cpus(const struct cpumask *mask, char *buf)
*/
static ssize_t show_related_cpus(struct cpufreq_policy *policy, char *buf)
{
- if (cpumask_empty(policy->related_cpus))
- return show_cpus(policy->cpus, buf);
return show_cpus(policy->related_cpus, buf);
}
@@ -711,92 +709,6 @@ static struct kobj_type ktype_cpufreq = {
.release = cpufreq_sysfs_release,
};
-/*
- * Returns:
- * Negative: Failure
- * 0: Success
- * Positive: When we have a managed CPU and the sysfs got symlinked
- */
-static int cpufreq_add_dev_policy(unsigned int cpu,
- struct cpufreq_policy *policy,
- struct device *dev)
-{
- int ret = 0;
-#ifdef CONFIG_SMP
- unsigned long flags;
- unsigned int j;
-#ifdef CONFIG_HOTPLUG_CPU
- struct cpufreq_governor *gov;
-
- gov = __find_governor(per_cpu(cpufreq_cpu_governor, cpu));
- if (gov) {
- policy->governor = gov;
- pr_debug("Restoring governor %s for cpu %d\n",
- policy->governor->name, cpu);
- }
-#endif
-
- for_each_cpu(j, policy->cpus) {
- struct cpufreq_policy *managed_policy;
-
- if (cpu == j)
- continue;
-
- /* Check for existing affected CPUs.
- * They may not be aware of it due to CPU Hotplug.
- * cpufreq_cpu_put is called when the device is removed
- * in __cpufreq_remove_dev()
- */
- managed_policy = cpufreq_cpu_get(j);
- if (unlikely(managed_policy)) {
-
- /* Set proper policy_cpu */
- unlock_policy_rwsem_write(cpu);
- per_cpu(cpufreq_policy_cpu, cpu) = managed_policy->cpu;
-
- if (lock_policy_rwsem_write(cpu) < 0) {
- /* Should not go through policy unlock path */
- if (cpufreq_driver->exit)
- cpufreq_driver->exit(policy);
- cpufreq_cpu_put(managed_policy);
- return -EBUSY;
- }
-
- __cpufreq_governor(managed_policy, CPUFREQ_GOV_STOP);
-
- spin_lock_irqsave(&cpufreq_driver_lock, flags);
- cpumask_copy(managed_policy->cpus, policy->cpus);
- per_cpu(cpufreq_cpu_data, cpu) = managed_policy;
- spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
-
- __cpufreq_governor(managed_policy, CPUFREQ_GOV_START);
- __cpufreq_governor(managed_policy, CPUFREQ_GOV_LIMITS);
-
- pr_debug("CPU already managed, adding link\n");
- ret = sysfs_create_link(&dev->kobj,
- &managed_policy->kobj,
- "cpufreq");
- if (ret)
- cpufreq_cpu_put(managed_policy);
- /*
- * Success. We only needed to be added to the mask.
- * Call driver->exit() because only the cpu parent of
- * the kobj needed to call init().
- */
- if (cpufreq_driver->exit)
- cpufreq_driver->exit(policy);
-
- if (!ret)
- return 1;
- else
- return ret;
- }
- }
-#endif
- return ret;
-}
-
-
/* symlink affected CPUs */
static int cpufreq_add_dev_symlink(unsigned int cpu,
struct cpufreq_policy *policy)
@@ -901,6 +813,42 @@ err_out_kobj_put:
return ret;
}
+#ifdef CONFIG_HOTPLUG_CPU
+static int cpufreq_add_policy_cpu(unsigned int cpu, unsigned int sibling,
+ struct device *dev)
+{
+ struct cpufreq_policy *policy;
+ int ret = 0;
+ unsigned long flags;
+
+ policy = cpufreq_cpu_get(sibling);
+ WARN_ON(!policy);
+
+ per_cpu(cpufreq_policy_cpu, cpu) = policy->cpu;
+
+ lock_policy_rwsem_write(cpu);
+
+ __cpufreq_governor(policy, CPUFREQ_GOV_STOP);
+
+ spin_lock_irqsave(&cpufreq_driver_lock, flags);
+ cpumask_set_cpu(cpu, policy->cpus);
+ per_cpu(cpufreq_cpu_data, cpu) = policy;
+ spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
+
+ __cpufreq_governor(policy, CPUFREQ_GOV_START);
+ __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS);
+
+ unlock_policy_rwsem_write(cpu);
+
+ ret = sysfs_create_link(&dev->kobj, &policy->kobj, "cpufreq");
+ if (ret) {
+ cpufreq_cpu_put(policy);
+ return ret;
+ }
+
+ return 0;
+}
+#endif
/**
* cpufreq_add_dev - add a CPU device
@@ -913,12 +861,12 @@ err_out_kobj_put:
*/
static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)
{
- unsigned int cpu = dev->id;
- int ret = 0, found = 0;
+ unsigned int j, cpu = dev->id;
+ int ret = -ENOMEM, found = 0;
struct cpufreq_policy *policy;
unsigned long flags;
- unsigned int j;
#ifdef CONFIG_HOTPLUG_CPU
+ struct cpufreq_governor *gov;
int sibling;
#endif
@@ -935,6 +883,15 @@ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)
cpufreq_cpu_put(policy);
return 0;
}
+
+#ifdef CONFIG_HOTPLUG_CPU
+ /* Check if this cpu was hot-unplugged earlier and has siblings */
+ for_each_online_cpu(sibling) {
+ struct cpufreq_policy *cp = per_cpu(cpufreq_cpu_data, sibling);
+ if (cp && cpumask_test_cpu(cpu, cp->related_cpus))
+ return cpufreq_add_policy_cpu(cpu, sibling, dev);
+ }
+#endif
#endif
if (!try_module_get(cpufreq_driver->owner)) {
@@ -942,7 +899,6 @@ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)
goto module_out;
}
- ret = -ENOMEM;
policy = kzalloc(sizeof(struct cpufreq_policy), GFP_KERNEL);
if (!policy)
goto nomem_out;
@@ -987,6 +943,9 @@ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)
goto err_unlock_policy;
}
+ /* related cpus should atleast have policy->cpus */
+ cpumask_or(policy->related_cpus, policy->related_cpus, policy->cpus);
+
/*
* affected cpus must always be the one, which are online. We aren't
* managing offline cpus here.
@@ -1000,14 +959,14 @@ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)
blocking_notifier_call_chain(&cpufreq_policy_notifier_list,
CPUFREQ_START, policy);
- ret = cpufreq_add_dev_policy(cpu, policy, dev);
- if (ret) {
- if (ret > 0)
- /* This is a managed cpu, symlink created,
- exit with 0 */
- ret = 0;
- goto err_unlock_policy;
+#ifdef CONFIG_HOTPLUG_CPU
+ gov = __find_governor(per_cpu(cpufreq_cpu_governor, cpu));
+ if (gov) {
+ policy->governor = gov;
+ pr_debug("Restoring governor %s for cpu %d\n",
+ policy->governor->name, cpu);
}
+#endif
ret = cpufreq_add_dev_interface(cpu, policy, dev);
if (ret)
@@ -1021,7 +980,6 @@ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)
return 0;
-
err_out_unregister:
spin_lock_irqsave(&cpufreq_driver_lock, flags);
for_each_cpu(j, policy->cpus)
diff --git a/drivers/cpufreq/spear-cpufreq.c b/drivers/cpufreq/spear-cpufreq.c
index 8ff26af..fc714a6 100644
--- a/drivers/cpufreq/spear-cpufreq.c
+++ b/drivers/cpufreq/spear-cpufreq.c
@@ -189,7 +189,6 @@ static int spear_cpufreq_init(struct cpufreq_policy *policy)
policy->cur = spear_cpufreq_get(0);
cpumask_copy(policy->cpus, topology_core_cpumask(policy->cpu));
- cpumask_copy(policy->related_cpus, policy->cpus);
return 0;
}
--
1.7.12.rc2.18.g61b472e
With the addition of following patch, related_cpus is required to be set by
cpufreq platform drivers:
commit c1070fd743533efb54e98142252283583f379190
Author: Viresh Kumar <viresh.kumar(a)linaro.org>
Date: Mon Jan 14 13:23:04 2013 +0000
cpufreq: Simplify cpufreq_add_dev()
Because this change is required by all platform drivers, why not do this in the
core itself. Hence, this patch is an attempt towards fixing all broken drivers.
>From now on, platforms don't really need to set related_cpus from their init()
routines, as the same work is done by core too.
If platform driver needs to set the related_cpus mask with some additional cpus,
other than cpus present in policy->cpus, they are free to do it as we aren't
overriding anything.
Signed-off-by: Viresh Kumar <viresh.kumar(a)linaro.org>
---
Inderpal,
Can you please add your tested-by for this patch? And this will require you to
drop your patch for exynos-cpufreq.c :)
drivers/cpufreq/cpufreq.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index f5dc02b..db81382 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -554,8 +554,6 @@ static ssize_t show_cpus(const struct cpumask *mask, char *buf)
*/
static ssize_t show_related_cpus(struct cpufreq_policy *policy, char *buf)
{
- if (cpumask_empty(policy->related_cpus))
- return show_cpus(policy->cpus, buf);
return show_cpus(policy->related_cpus, buf);
}
@@ -945,6 +943,9 @@ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)
goto err_unlock_policy;
}
+ /* related cpus should atleast have policy->cpus */
+ cpumask_or(policy->related_cpus, policy->related_cpus, policy->cpus);
+
/*
* affected cpus must always be the one, which are online. We aren't
* managing offline cpus here.
--
1.7.12.rc2.18.g61b472e
Hi, All
Android team now has tools for updating the kernel related files without
recreating the sdcard.
The detail information about the tools is described here:
https://wiki.linaro.org/Platform/Android/KernelUpdateTools
And here just list some examples:
1. update all the kernel related files with boot.tar.bz2
./update-android.sh out/target/product/pandaboard/boot.tar.bz2
2. only update one file that will be in the boot.tar.bz2 when packaged,
Like board.dtb/uImage/cmdline
./update-android.sh out/target/product/pandaboard/boot/board.dtb
./update-android.sh out/target/product/pandaboard/boot/uImage
./update-android.sh out/target/product/pandaboard/boot/cmdline
3. update all kernel modules.
./update-android.sh out/target/product/pandaboard/obj/kernel
4. update files in uInitrd
./update-uInitrd.sh /tmp/init.rc
this will replace the /ini.rc file in uInitrd with the passed
/tmp/init.rc
Hope these tools will be helpful during your development of android.
Any comments/suggestion, please feel free to send to me.
Thanks,
Yongqin Liu
---------------------------------------------------------------
#mailing list
linaro-android(a)lists.linaro.org <linaro-dev(a)lists.linaro.org>
http://lists.linaro.org/mailman/listinfo/linaro-android
linaro-validation(a)lists.linaro.org <linaro-dev(a)lists.linaro.org>
http://lists.linaro.org/pipermail/linaro-validation
Hi all,
These are my PM-QA commits recently, send them out FYI.
Hongbo Zhang (8):
thermal: kill heater program if test is terminated by signal
thermal: don't check launch of the glmark2 if it isn't there
thermal: remove unnecessary variable TRIP_CROSSED_COUNT
thermal: Consolidate launching glmark2 as GPU heater
thermal: add switch for thermal_06.sh
thermal: enable launching glmark2 in Android
pm-qa: enable thermal test scipts.
Version 0.4.0
Makefile | 4 ++--
VERSION | 2 +-
include/thermal_functions.sh | 41 +++++++++++++++++++++++++++++++++++++++++
thermal/thermal_03.sh | 29 ++++++++++++-----------------
thermal/thermal_04.sh | 11 ++++++++++-
thermal/thermal_06.sh | 39 ++++++++++++++++++++-------------------
6 files changed, 86 insertions(+), 40 deletions(-)
--
1.8.0
Hi All,
How about having a generic Virtio-based machine for emulating a virtual
desktop ?
I know folks have already thought about this and probably also tried
something or other on this front but, it will be good to know the downsides.
Virtio-desktop can be a separate specification describing a virtual
desktop.
Of-course we cannot avoid few architecture dependent virtual devices in but
the Virtio-desktop specification will try to keep minimum possible
architecture dependent devices.
As per our thoughts, a Virtio-desktop will have two kinds of devices:
1. Architecture dependent devices: This devices will be emulated in-kernel
by architecture specific code of KVM or Xen or Some other hypervisor.
a) Virtualized CPU
b) Virtualized PIC (i.e. in-kernel architecture specific emulation of
irqchip)
c) Virtualized Timer (i.e. in-kernel architecture specific emulation of
timer chip)
2. Architecture independent devices: This are Virtio-based devices which
are usually required by a desktop virtual machine.
a) Virtio-blk (storage)
- Already available
b) Virtio-net (network)
- Already available
c) Virtio-fb (display)
- It seems some work has been already done for Virtio frame buffer but
I did not find drivers/fb/virtio-fb.c in latest kernel
(http://thread.gmane.org/gmane.comp.emulators.kvm.devel/42720)
- Is Virtio-fb work still in-progress ??
d) Virtio-input (keyboard/mouse/multi-touch)
- Currently not available
- It will provide keyboard input events
- It will provide mouse input events
- It will provide multi-touch input events
e) Virtio-power (reset/shutdown/enumeration)
- It can provides info about the entire virtual machine including CPU,
PIC, Timer, available Virtio devices, etc.
- It can also provide CPU and Virtio-device hot-plugging
- Its primary purpose would be to provide reset and shutdown of CPU
and Virtio devices.
- There will be only one instance of this device and its location will
be fixed for each architecture.
The Virtio-desktop specification may also describe a recommended memory map
of for each architecture.
Right now, only missing devices seems to be Virtio-fb, Virtio-input, and
Virtio-power, which some of us are willing to take-up.
IMHO, If we have something like Virtio-desktop specification then all
possible guest OSes can have support for it and different hypervisor can
emulate it without worrying about guest support.
Best Regards,
Anup
On 26 January 2013 07:19, Alex Shi <alex.shi(a)intel.com> wrote:
> This patchset can be used, but causes burst waking benchmark aim9 drop 5~7%
> on my 2 sockets machine. The reason is too light runnable load in early stage
> of waked tasks causes imbalance in balancing.
>
> So, it is immature and just a reference for guys who want to go gurther.
>
> V2 change:
> 1, attached the 1~3 patches, which were sent in power awareness scheduling
> 2, remove CONFIG_FAIR_GROUP_SCHED mask in patch 5th.
>
> Thanks Ingo's comments and testing provided by Fengguang's kbuild system.
> Now it is indepent patchset bases on Linus' tree.
Pushed as: runnable-load-avg-in-load-balance-v2