diff options
Diffstat (limited to 'drivers/cpufreq')
-rw-r--r-- | drivers/cpufreq/cpufreq.c | 79 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq_conservative.c | 50 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq_ondemand.c | 54 | ||||
-rw-r--r-- | drivers/cpufreq/cpufreq_stats.c | 6 |
4 files changed, 91 insertions, 98 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 2f5801adc739..622013fb7890 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -678,7 +678,7 @@ static struct kobj_type ktype_cpufreq = { | |||
678 | */ | 678 | */ |
679 | static int cpufreq_add_dev_policy(unsigned int cpu, | 679 | static int cpufreq_add_dev_policy(unsigned int cpu, |
680 | struct cpufreq_policy *policy, | 680 | struct cpufreq_policy *policy, |
681 | struct sys_device *sys_dev) | 681 | struct device *dev) |
682 | { | 682 | { |
683 | int ret = 0; | 683 | int ret = 0; |
684 | #ifdef CONFIG_SMP | 684 | #ifdef CONFIG_SMP |
@@ -727,7 +727,7 @@ static int cpufreq_add_dev_policy(unsigned int cpu, | |||
727 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | 727 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); |
728 | 728 | ||
729 | pr_debug("CPU already managed, adding link\n"); | 729 | pr_debug("CPU already managed, adding link\n"); |
730 | ret = sysfs_create_link(&sys_dev->kobj, | 730 | ret = sysfs_create_link(&dev->kobj, |
731 | &managed_policy->kobj, | 731 | &managed_policy->kobj, |
732 | "cpufreq"); | 732 | "cpufreq"); |
733 | if (ret) | 733 | if (ret) |
@@ -760,7 +760,7 @@ static int cpufreq_add_dev_symlink(unsigned int cpu, | |||
760 | 760 | ||
761 | for_each_cpu(j, policy->cpus) { | 761 | for_each_cpu(j, policy->cpus) { |
762 | struct cpufreq_policy *managed_policy; | 762 | struct cpufreq_policy *managed_policy; |
763 | struct sys_device *cpu_sys_dev; | 763 | struct device *cpu_dev; |
764 | 764 | ||
765 | if (j == cpu) | 765 | if (j == cpu) |
766 | continue; | 766 | continue; |
@@ -769,8 +769,8 @@ static int cpufreq_add_dev_symlink(unsigned int cpu, | |||
769 | 769 | ||
770 | pr_debug("CPU %u already managed, adding link\n", j); | 770 | pr_debug("CPU %u already managed, adding link\n", j); |
771 | managed_policy = cpufreq_cpu_get(cpu); | 771 | managed_policy = cpufreq_cpu_get(cpu); |
772 | cpu_sys_dev = get_cpu_sysdev(j); | 772 | cpu_dev = get_cpu_device(j); |
773 | ret = sysfs_create_link(&cpu_sys_dev->kobj, &policy->kobj, | 773 | ret = sysfs_create_link(&cpu_dev->kobj, &policy->kobj, |
774 | "cpufreq"); | 774 | "cpufreq"); |
775 | if (ret) { | 775 | if (ret) { |
776 | cpufreq_cpu_put(managed_policy); | 776 | cpufreq_cpu_put(managed_policy); |
@@ -782,7 +782,7 @@ static int cpufreq_add_dev_symlink(unsigned int cpu, | |||
782 | 782 | ||
783 | static int cpufreq_add_dev_interface(unsigned int cpu, | 783 | static int cpufreq_add_dev_interface(unsigned int cpu, |
784 | struct cpufreq_policy *policy, | 784 | struct cpufreq_policy *policy, |
785 | struct sys_device *sys_dev) | 785 | struct device *dev) |
786 | { | 786 | { |
787 | struct cpufreq_policy new_policy; | 787 | struct cpufreq_policy new_policy; |
788 | struct freq_attr **drv_attr; | 788 | struct freq_attr **drv_attr; |
@@ -792,7 +792,7 @@ static int cpufreq_add_dev_interface(unsigned int cpu, | |||
792 | 792 | ||
793 | /* prepare interface data */ | 793 | /* prepare interface data */ |
794 | ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq, | 794 | ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq, |
795 | &sys_dev->kobj, "cpufreq"); | 795 | &dev->kobj, "cpufreq"); |
796 | if (ret) | 796 | if (ret) |
797 | return ret; | 797 | return ret; |
798 | 798 | ||
@@ -865,9 +865,9 @@ err_out_kobj_put: | |||
865 | * with with cpu hotplugging and all hell will break loose. Tried to clean this | 865 | * with with cpu hotplugging and all hell will break loose. Tried to clean this |
866 | * mess up, but more thorough testing is needed. - Mathieu | 866 | * mess up, but more thorough testing is needed. - Mathieu |
867 | */ | 867 | */ |
868 | static int cpufreq_add_dev(struct sys_device *sys_dev) | 868 | static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif) |
869 | { | 869 | { |
870 | unsigned int cpu = sys_dev->id; | 870 | unsigned int cpu = dev->id; |
871 | int ret = 0, found = 0; | 871 | int ret = 0, found = 0; |
872 | struct cpufreq_policy *policy; | 872 | struct cpufreq_policy *policy; |
873 | unsigned long flags; | 873 | unsigned long flags; |
@@ -946,7 +946,7 @@ static int cpufreq_add_dev(struct sys_device *sys_dev) | |||
946 | blocking_notifier_call_chain(&cpufreq_policy_notifier_list, | 946 | blocking_notifier_call_chain(&cpufreq_policy_notifier_list, |
947 | CPUFREQ_START, policy); | 947 | CPUFREQ_START, policy); |
948 | 948 | ||
949 | ret = cpufreq_add_dev_policy(cpu, policy, sys_dev); | 949 | ret = cpufreq_add_dev_policy(cpu, policy, dev); |
950 | if (ret) { | 950 | if (ret) { |
951 | if (ret > 0) | 951 | if (ret > 0) |
952 | /* This is a managed cpu, symlink created, | 952 | /* This is a managed cpu, symlink created, |
@@ -955,7 +955,7 @@ static int cpufreq_add_dev(struct sys_device *sys_dev) | |||
955 | goto err_unlock_policy; | 955 | goto err_unlock_policy; |
956 | } | 956 | } |
957 | 957 | ||
958 | ret = cpufreq_add_dev_interface(cpu, policy, sys_dev); | 958 | ret = cpufreq_add_dev_interface(cpu, policy, dev); |
959 | if (ret) | 959 | if (ret) |
960 | goto err_out_unregister; | 960 | goto err_out_unregister; |
961 | 961 | ||
@@ -998,15 +998,15 @@ module_out: | |||
998 | * Caller should already have policy_rwsem in write mode for this CPU. | 998 | * Caller should already have policy_rwsem in write mode for this CPU. |
999 | * This routine frees the rwsem before returning. | 999 | * This routine frees the rwsem before returning. |
1000 | */ | 1000 | */ |
1001 | static int __cpufreq_remove_dev(struct sys_device *sys_dev) | 1001 | static int __cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif) |
1002 | { | 1002 | { |
1003 | unsigned int cpu = sys_dev->id; | 1003 | unsigned int cpu = dev->id; |
1004 | unsigned long flags; | 1004 | unsigned long flags; |
1005 | struct cpufreq_policy *data; | 1005 | struct cpufreq_policy *data; |
1006 | struct kobject *kobj; | 1006 | struct kobject *kobj; |
1007 | struct completion *cmp; | 1007 | struct completion *cmp; |
1008 | #ifdef CONFIG_SMP | 1008 | #ifdef CONFIG_SMP |
1009 | struct sys_device *cpu_sys_dev; | 1009 | struct device *cpu_dev; |
1010 | unsigned int j; | 1010 | unsigned int j; |
1011 | #endif | 1011 | #endif |
1012 | 1012 | ||
@@ -1031,7 +1031,7 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev) | |||
1031 | pr_debug("removing link\n"); | 1031 | pr_debug("removing link\n"); |
1032 | cpumask_clear_cpu(cpu, data->cpus); | 1032 | cpumask_clear_cpu(cpu, data->cpus); |
1033 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | 1033 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); |
1034 | kobj = &sys_dev->kobj; | 1034 | kobj = &dev->kobj; |
1035 | cpufreq_cpu_put(data); | 1035 | cpufreq_cpu_put(data); |
1036 | unlock_policy_rwsem_write(cpu); | 1036 | unlock_policy_rwsem_write(cpu); |
1037 | sysfs_remove_link(kobj, "cpufreq"); | 1037 | sysfs_remove_link(kobj, "cpufreq"); |
@@ -1070,8 +1070,8 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev) | |||
1070 | strncpy(per_cpu(cpufreq_cpu_governor, j), | 1070 | strncpy(per_cpu(cpufreq_cpu_governor, j), |
1071 | data->governor->name, CPUFREQ_NAME_LEN); | 1071 | data->governor->name, CPUFREQ_NAME_LEN); |
1072 | #endif | 1072 | #endif |
1073 | cpu_sys_dev = get_cpu_sysdev(j); | 1073 | cpu_dev = get_cpu_device(j); |
1074 | kobj = &cpu_sys_dev->kobj; | 1074 | kobj = &cpu_dev->kobj; |
1075 | unlock_policy_rwsem_write(cpu); | 1075 | unlock_policy_rwsem_write(cpu); |
1076 | sysfs_remove_link(kobj, "cpufreq"); | 1076 | sysfs_remove_link(kobj, "cpufreq"); |
1077 | lock_policy_rwsem_write(cpu); | 1077 | lock_policy_rwsem_write(cpu); |
@@ -1111,11 +1111,11 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev) | |||
1111 | if (unlikely(cpumask_weight(data->cpus) > 1)) { | 1111 | if (unlikely(cpumask_weight(data->cpus) > 1)) { |
1112 | /* first sibling now owns the new sysfs dir */ | 1112 | /* first sibling now owns the new sysfs dir */ |
1113 | cpumask_clear_cpu(cpu, data->cpus); | 1113 | cpumask_clear_cpu(cpu, data->cpus); |
1114 | cpufreq_add_dev(get_cpu_sysdev(cpumask_first(data->cpus))); | 1114 | cpufreq_add_dev(get_cpu_device(cpumask_first(data->cpus)), NULL); |
1115 | 1115 | ||
1116 | /* finally remove our own symlink */ | 1116 | /* finally remove our own symlink */ |
1117 | lock_policy_rwsem_write(cpu); | 1117 | lock_policy_rwsem_write(cpu); |
1118 | __cpufreq_remove_dev(sys_dev); | 1118 | __cpufreq_remove_dev(dev, sif); |
1119 | } | 1119 | } |
1120 | #endif | 1120 | #endif |
1121 | 1121 | ||
@@ -1127,9 +1127,9 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev) | |||
1127 | } | 1127 | } |
1128 | 1128 | ||
1129 | 1129 | ||
1130 | static int cpufreq_remove_dev(struct sys_device *sys_dev) | 1130 | static int cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif) |
1131 | { | 1131 | { |
1132 | unsigned int cpu = sys_dev->id; | 1132 | unsigned int cpu = dev->id; |
1133 | int retval; | 1133 | int retval; |
1134 | 1134 | ||
1135 | if (cpu_is_offline(cpu)) | 1135 | if (cpu_is_offline(cpu)) |
@@ -1138,7 +1138,7 @@ static int cpufreq_remove_dev(struct sys_device *sys_dev) | |||
1138 | if (unlikely(lock_policy_rwsem_write(cpu))) | 1138 | if (unlikely(lock_policy_rwsem_write(cpu))) |
1139 | BUG(); | 1139 | BUG(); |
1140 | 1140 | ||
1141 | retval = __cpufreq_remove_dev(sys_dev); | 1141 | retval = __cpufreq_remove_dev(dev, sif); |
1142 | return retval; | 1142 | return retval; |
1143 | } | 1143 | } |
1144 | 1144 | ||
@@ -1270,9 +1270,11 @@ out: | |||
1270 | } | 1270 | } |
1271 | EXPORT_SYMBOL(cpufreq_get); | 1271 | EXPORT_SYMBOL(cpufreq_get); |
1272 | 1272 | ||
1273 | static struct sysdev_driver cpufreq_sysdev_driver = { | 1273 | static struct subsys_interface cpufreq_interface = { |
1274 | .add = cpufreq_add_dev, | 1274 | .name = "cpufreq", |
1275 | .remove = cpufreq_remove_dev, | 1275 | .subsys = &cpu_subsys, |
1276 | .add_dev = cpufreq_add_dev, | ||
1277 | .remove_dev = cpufreq_remove_dev, | ||
1276 | }; | 1278 | }; |
1277 | 1279 | ||
1278 | 1280 | ||
@@ -1764,25 +1766,25 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb, | |||
1764 | unsigned long action, void *hcpu) | 1766 | unsigned long action, void *hcpu) |
1765 | { | 1767 | { |
1766 | unsigned int cpu = (unsigned long)hcpu; | 1768 | unsigned int cpu = (unsigned long)hcpu; |
1767 | struct sys_device *sys_dev; | 1769 | struct device *dev; |
1768 | 1770 | ||
1769 | sys_dev = get_cpu_sysdev(cpu); | 1771 | dev = get_cpu_device(cpu); |
1770 | if (sys_dev) { | 1772 | if (dev) { |
1771 | switch (action) { | 1773 | switch (action) { |
1772 | case CPU_ONLINE: | 1774 | case CPU_ONLINE: |
1773 | case CPU_ONLINE_FROZEN: | 1775 | case CPU_ONLINE_FROZEN: |
1774 | cpufreq_add_dev(sys_dev); | 1776 | cpufreq_add_dev(dev, NULL); |
1775 | break; | 1777 | break; |
1776 | case CPU_DOWN_PREPARE: | 1778 | case CPU_DOWN_PREPARE: |
1777 | case CPU_DOWN_PREPARE_FROZEN: | 1779 | case CPU_DOWN_PREPARE_FROZEN: |
1778 | if (unlikely(lock_policy_rwsem_write(cpu))) | 1780 | if (unlikely(lock_policy_rwsem_write(cpu))) |
1779 | BUG(); | 1781 | BUG(); |
1780 | 1782 | ||
1781 | __cpufreq_remove_dev(sys_dev); | 1783 | __cpufreq_remove_dev(dev, NULL); |
1782 | break; | 1784 | break; |
1783 | case CPU_DOWN_FAILED: | 1785 | case CPU_DOWN_FAILED: |
1784 | case CPU_DOWN_FAILED_FROZEN: | 1786 | case CPU_DOWN_FAILED_FROZEN: |
1785 | cpufreq_add_dev(sys_dev); | 1787 | cpufreq_add_dev(dev, NULL); |
1786 | break; | 1788 | break; |
1787 | } | 1789 | } |
1788 | } | 1790 | } |
@@ -1829,8 +1831,7 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data) | |||
1829 | cpufreq_driver = driver_data; | 1831 | cpufreq_driver = driver_data; |
1830 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); | 1832 | spin_unlock_irqrestore(&cpufreq_driver_lock, flags); |
1831 | 1833 | ||
1832 | ret = sysdev_driver_register(&cpu_sysdev_class, | 1834 | ret = subsys_interface_register(&cpufreq_interface); |
1833 | &cpufreq_sysdev_driver); | ||
1834 | if (ret) | 1835 | if (ret) |
1835 | goto err_null_driver; | 1836 | goto err_null_driver; |
1836 | 1837 | ||
@@ -1849,7 +1850,7 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data) | |||
1849 | if (ret) { | 1850 | if (ret) { |
1850 | pr_debug("no CPU initialized for driver %s\n", | 1851 | pr_debug("no CPU initialized for driver %s\n", |
1851 | driver_data->name); | 1852 | driver_data->name); |
1852 | goto err_sysdev_unreg; | 1853 | goto err_if_unreg; |
1853 | } | 1854 | } |
1854 | } | 1855 | } |
1855 | 1856 | ||
@@ -1857,9 +1858,8 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data) | |||
1857 | pr_debug("driver %s up and running\n", driver_data->name); | 1858 | pr_debug("driver %s up and running\n", driver_data->name); |
1858 | 1859 | ||
1859 | return 0; | 1860 | return 0; |
1860 | err_sysdev_unreg: | 1861 | err_if_unreg: |
1861 | sysdev_driver_unregister(&cpu_sysdev_class, | 1862 | subsys_interface_unregister(&cpufreq_interface); |
1862 | &cpufreq_sysdev_driver); | ||
1863 | err_null_driver: | 1863 | err_null_driver: |
1864 | spin_lock_irqsave(&cpufreq_driver_lock, flags); | 1864 | spin_lock_irqsave(&cpufreq_driver_lock, flags); |
1865 | cpufreq_driver = NULL; | 1865 | cpufreq_driver = NULL; |
@@ -1886,7 +1886,7 @@ int cpufreq_unregister_driver(struct cpufreq_driver *driver) | |||
1886 | 1886 | ||
1887 | pr_debug("unregistering driver %s\n", driver->name); | 1887 | pr_debug("unregistering driver %s\n", driver->name); |
1888 | 1888 | ||
1889 | sysdev_driver_unregister(&cpu_sysdev_class, &cpufreq_sysdev_driver); | 1889 | subsys_interface_unregister(&cpufreq_interface); |
1890 | unregister_hotcpu_notifier(&cpufreq_cpu_notifier); | 1890 | unregister_hotcpu_notifier(&cpufreq_cpu_notifier); |
1891 | 1891 | ||
1892 | spin_lock_irqsave(&cpufreq_driver_lock, flags); | 1892 | spin_lock_irqsave(&cpufreq_driver_lock, flags); |
@@ -1906,8 +1906,7 @@ static int __init cpufreq_core_init(void) | |||
1906 | init_rwsem(&per_cpu(cpu_policy_rwsem, cpu)); | 1906 | init_rwsem(&per_cpu(cpu_policy_rwsem, cpu)); |
1907 | } | 1907 | } |
1908 | 1908 | ||
1909 | cpufreq_global_kobject = kobject_create_and_add("cpufreq", | 1909 | cpufreq_global_kobject = kobject_create_and_add("cpufreq", &cpu_subsys.dev_root->kobj); |
1910 | &cpu_sysdev_class.kset.kobj); | ||
1911 | BUG_ON(!cpufreq_global_kobject); | 1910 | BUG_ON(!cpufreq_global_kobject); |
1912 | register_syscore_ops(&cpufreq_syscore_ops); | 1911 | register_syscore_ops(&cpufreq_syscore_ops); |
1913 | 1912 | ||
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c index c97b468ee9f7..235a340e81f2 100644 --- a/drivers/cpufreq/cpufreq_conservative.c +++ b/drivers/cpufreq/cpufreq_conservative.c | |||
@@ -95,27 +95,26 @@ static struct dbs_tuners { | |||
95 | .freq_step = 5, | 95 | .freq_step = 5, |
96 | }; | 96 | }; |
97 | 97 | ||
98 | static inline cputime64_t get_cpu_idle_time_jiffy(unsigned int cpu, | 98 | static inline u64 get_cpu_idle_time_jiffy(unsigned int cpu, u64 *wall) |
99 | cputime64_t *wall) | ||
100 | { | 99 | { |
101 | cputime64_t idle_time; | 100 | u64 idle_time; |
102 | cputime64_t cur_wall_time; | 101 | u64 cur_wall_time; |
103 | cputime64_t busy_time; | 102 | u64 busy_time; |
104 | 103 | ||
105 | cur_wall_time = jiffies64_to_cputime64(get_jiffies_64()); | 104 | cur_wall_time = jiffies64_to_cputime64(get_jiffies_64()); |
106 | busy_time = cputime64_add(kstat_cpu(cpu).cpustat.user, | ||
107 | kstat_cpu(cpu).cpustat.system); | ||
108 | 105 | ||
109 | busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.irq); | 106 | busy_time = kcpustat_cpu(cpu).cpustat[CPUTIME_USER]; |
110 | busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.softirq); | 107 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_SYSTEM]; |
111 | busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.steal); | 108 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_IRQ]; |
112 | busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.nice); | 109 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_SOFTIRQ]; |
110 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_STEAL]; | ||
111 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_NICE]; | ||
113 | 112 | ||
114 | idle_time = cputime64_sub(cur_wall_time, busy_time); | 113 | idle_time = cur_wall_time - busy_time; |
115 | if (wall) | 114 | if (wall) |
116 | *wall = (cputime64_t)jiffies_to_usecs(cur_wall_time); | 115 | *wall = jiffies_to_usecs(cur_wall_time); |
117 | 116 | ||
118 | return (cputime64_t)jiffies_to_usecs(idle_time); | 117 | return jiffies_to_usecs(idle_time); |
119 | } | 118 | } |
120 | 119 | ||
121 | static inline cputime64_t get_cpu_idle_time(unsigned int cpu, cputime64_t *wall) | 120 | static inline cputime64_t get_cpu_idle_time(unsigned int cpu, cputime64_t *wall) |
@@ -272,7 +271,7 @@ static ssize_t store_ignore_nice_load(struct kobject *a, struct attribute *b, | |||
272 | dbs_info->prev_cpu_idle = get_cpu_idle_time(j, | 271 | dbs_info->prev_cpu_idle = get_cpu_idle_time(j, |
273 | &dbs_info->prev_cpu_wall); | 272 | &dbs_info->prev_cpu_wall); |
274 | if (dbs_tuners_ins.ignore_nice) | 273 | if (dbs_tuners_ins.ignore_nice) |
275 | dbs_info->prev_cpu_nice = kstat_cpu(j).cpustat.nice; | 274 | dbs_info->prev_cpu_nice = kcpustat_cpu(j).cpustat[CPUTIME_NICE]; |
276 | } | 275 | } |
277 | return count; | 276 | return count; |
278 | } | 277 | } |
@@ -353,20 +352,20 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) | |||
353 | 352 | ||
354 | cur_idle_time = get_cpu_idle_time(j, &cur_wall_time); | 353 | cur_idle_time = get_cpu_idle_time(j, &cur_wall_time); |
355 | 354 | ||
356 | wall_time = (unsigned int) cputime64_sub(cur_wall_time, | 355 | wall_time = (unsigned int) |
357 | j_dbs_info->prev_cpu_wall); | 356 | (cur_wall_time - j_dbs_info->prev_cpu_wall); |
358 | j_dbs_info->prev_cpu_wall = cur_wall_time; | 357 | j_dbs_info->prev_cpu_wall = cur_wall_time; |
359 | 358 | ||
360 | idle_time = (unsigned int) cputime64_sub(cur_idle_time, | 359 | idle_time = (unsigned int) |
361 | j_dbs_info->prev_cpu_idle); | 360 | (cur_idle_time - j_dbs_info->prev_cpu_idle); |
362 | j_dbs_info->prev_cpu_idle = cur_idle_time; | 361 | j_dbs_info->prev_cpu_idle = cur_idle_time; |
363 | 362 | ||
364 | if (dbs_tuners_ins.ignore_nice) { | 363 | if (dbs_tuners_ins.ignore_nice) { |
365 | cputime64_t cur_nice; | 364 | u64 cur_nice; |
366 | unsigned long cur_nice_jiffies; | 365 | unsigned long cur_nice_jiffies; |
367 | 366 | ||
368 | cur_nice = cputime64_sub(kstat_cpu(j).cpustat.nice, | 367 | cur_nice = kcpustat_cpu(j).cpustat[CPUTIME_NICE] - |
369 | j_dbs_info->prev_cpu_nice); | 368 | j_dbs_info->prev_cpu_nice; |
370 | /* | 369 | /* |
371 | * Assumption: nice time between sampling periods will | 370 | * Assumption: nice time between sampling periods will |
372 | * be less than 2^32 jiffies for 32 bit sys | 371 | * be less than 2^32 jiffies for 32 bit sys |
@@ -374,7 +373,7 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) | |||
374 | cur_nice_jiffies = (unsigned long) | 373 | cur_nice_jiffies = (unsigned long) |
375 | cputime64_to_jiffies64(cur_nice); | 374 | cputime64_to_jiffies64(cur_nice); |
376 | 375 | ||
377 | j_dbs_info->prev_cpu_nice = kstat_cpu(j).cpustat.nice; | 376 | j_dbs_info->prev_cpu_nice = kcpustat_cpu(j).cpustat[CPUTIME_NICE]; |
378 | idle_time += jiffies_to_usecs(cur_nice_jiffies); | 377 | idle_time += jiffies_to_usecs(cur_nice_jiffies); |
379 | } | 378 | } |
380 | 379 | ||
@@ -501,10 +500,9 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
501 | 500 | ||
502 | j_dbs_info->prev_cpu_idle = get_cpu_idle_time(j, | 501 | j_dbs_info->prev_cpu_idle = get_cpu_idle_time(j, |
503 | &j_dbs_info->prev_cpu_wall); | 502 | &j_dbs_info->prev_cpu_wall); |
504 | if (dbs_tuners_ins.ignore_nice) { | 503 | if (dbs_tuners_ins.ignore_nice) |
505 | j_dbs_info->prev_cpu_nice = | 504 | j_dbs_info->prev_cpu_nice = |
506 | kstat_cpu(j).cpustat.nice; | 505 | kcpustat_cpu(j).cpustat[CPUTIME_NICE]; |
507 | } | ||
508 | } | 506 | } |
509 | this_dbs_info->down_skip = 0; | 507 | this_dbs_info->down_skip = 0; |
510 | this_dbs_info->requested_freq = policy->cur; | 508 | this_dbs_info->requested_freq = policy->cur; |
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c index 53ad4c780744..c3e0652520a1 100644 --- a/drivers/cpufreq/cpufreq_ondemand.c +++ b/drivers/cpufreq/cpufreq_ondemand.c | |||
@@ -119,27 +119,26 @@ static struct dbs_tuners { | |||
119 | .powersave_bias = 0, | 119 | .powersave_bias = 0, |
120 | }; | 120 | }; |
121 | 121 | ||
122 | static inline cputime64_t get_cpu_idle_time_jiffy(unsigned int cpu, | 122 | static inline u64 get_cpu_idle_time_jiffy(unsigned int cpu, u64 *wall) |
123 | cputime64_t *wall) | ||
124 | { | 123 | { |
125 | cputime64_t idle_time; | 124 | u64 idle_time; |
126 | cputime64_t cur_wall_time; | 125 | u64 cur_wall_time; |
127 | cputime64_t busy_time; | 126 | u64 busy_time; |
128 | 127 | ||
129 | cur_wall_time = jiffies64_to_cputime64(get_jiffies_64()); | 128 | cur_wall_time = jiffies64_to_cputime64(get_jiffies_64()); |
130 | busy_time = cputime64_add(kstat_cpu(cpu).cpustat.user, | ||
131 | kstat_cpu(cpu).cpustat.system); | ||
132 | 129 | ||
133 | busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.irq); | 130 | busy_time = kcpustat_cpu(cpu).cpustat[CPUTIME_USER]; |
134 | busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.softirq); | 131 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_SYSTEM]; |
135 | busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.steal); | 132 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_IRQ]; |
136 | busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.nice); | 133 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_SOFTIRQ]; |
134 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_STEAL]; | ||
135 | busy_time += kcpustat_cpu(cpu).cpustat[CPUTIME_NICE]; | ||
137 | 136 | ||
138 | idle_time = cputime64_sub(cur_wall_time, busy_time); | 137 | idle_time = cur_wall_time - busy_time; |
139 | if (wall) | 138 | if (wall) |
140 | *wall = (cputime64_t)jiffies_to_usecs(cur_wall_time); | 139 | *wall = jiffies_to_usecs(cur_wall_time); |
141 | 140 | ||
142 | return (cputime64_t)jiffies_to_usecs(idle_time); | 141 | return jiffies_to_usecs(idle_time); |
143 | } | 142 | } |
144 | 143 | ||
145 | static inline cputime64_t get_cpu_idle_time(unsigned int cpu, cputime64_t *wall) | 144 | static inline cputime64_t get_cpu_idle_time(unsigned int cpu, cputime64_t *wall) |
@@ -345,7 +344,7 @@ static ssize_t store_ignore_nice_load(struct kobject *a, struct attribute *b, | |||
345 | dbs_info->prev_cpu_idle = get_cpu_idle_time(j, | 344 | dbs_info->prev_cpu_idle = get_cpu_idle_time(j, |
346 | &dbs_info->prev_cpu_wall); | 345 | &dbs_info->prev_cpu_wall); |
347 | if (dbs_tuners_ins.ignore_nice) | 346 | if (dbs_tuners_ins.ignore_nice) |
348 | dbs_info->prev_cpu_nice = kstat_cpu(j).cpustat.nice; | 347 | dbs_info->prev_cpu_nice = kcpustat_cpu(j).cpustat[CPUTIME_NICE]; |
349 | 348 | ||
350 | } | 349 | } |
351 | return count; | 350 | return count; |
@@ -442,24 +441,24 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) | |||
442 | cur_idle_time = get_cpu_idle_time(j, &cur_wall_time); | 441 | cur_idle_time = get_cpu_idle_time(j, &cur_wall_time); |
443 | cur_iowait_time = get_cpu_iowait_time(j, &cur_wall_time); | 442 | cur_iowait_time = get_cpu_iowait_time(j, &cur_wall_time); |
444 | 443 | ||
445 | wall_time = (unsigned int) cputime64_sub(cur_wall_time, | 444 | wall_time = (unsigned int) |
446 | j_dbs_info->prev_cpu_wall); | 445 | (cur_wall_time - j_dbs_info->prev_cpu_wall); |
447 | j_dbs_info->prev_cpu_wall = cur_wall_time; | 446 | j_dbs_info->prev_cpu_wall = cur_wall_time; |
448 | 447 | ||
449 | idle_time = (unsigned int) cputime64_sub(cur_idle_time, | 448 | idle_time = (unsigned int) |
450 | j_dbs_info->prev_cpu_idle); | 449 | (cur_idle_time - j_dbs_info->prev_cpu_idle); |
451 | j_dbs_info->prev_cpu_idle = cur_idle_time; | 450 | j_dbs_info->prev_cpu_idle = cur_idle_time; |
452 | 451 | ||
453 | iowait_time = (unsigned int) cputime64_sub(cur_iowait_time, | 452 | iowait_time = (unsigned int) |
454 | j_dbs_info->prev_cpu_iowait); | 453 | (cur_iowait_time - j_dbs_info->prev_cpu_iowait); |
455 | j_dbs_info->prev_cpu_iowait = cur_iowait_time; | 454 | j_dbs_info->prev_cpu_iowait = cur_iowait_time; |
456 | 455 | ||
457 | if (dbs_tuners_ins.ignore_nice) { | 456 | if (dbs_tuners_ins.ignore_nice) { |
458 | cputime64_t cur_nice; | 457 | u64 cur_nice; |
459 | unsigned long cur_nice_jiffies; | 458 | unsigned long cur_nice_jiffies; |
460 | 459 | ||
461 | cur_nice = cputime64_sub(kstat_cpu(j).cpustat.nice, | 460 | cur_nice = kcpustat_cpu(j).cpustat[CPUTIME_NICE] - |
462 | j_dbs_info->prev_cpu_nice); | 461 | j_dbs_info->prev_cpu_nice; |
463 | /* | 462 | /* |
464 | * Assumption: nice time between sampling periods will | 463 | * Assumption: nice time between sampling periods will |
465 | * be less than 2^32 jiffies for 32 bit sys | 464 | * be less than 2^32 jiffies for 32 bit sys |
@@ -467,7 +466,7 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info) | |||
467 | cur_nice_jiffies = (unsigned long) | 466 | cur_nice_jiffies = (unsigned long) |
468 | cputime64_to_jiffies64(cur_nice); | 467 | cputime64_to_jiffies64(cur_nice); |
469 | 468 | ||
470 | j_dbs_info->prev_cpu_nice = kstat_cpu(j).cpustat.nice; | 469 | j_dbs_info->prev_cpu_nice = kcpustat_cpu(j).cpustat[CPUTIME_NICE]; |
471 | idle_time += jiffies_to_usecs(cur_nice_jiffies); | 470 | idle_time += jiffies_to_usecs(cur_nice_jiffies); |
472 | } | 471 | } |
473 | 472 | ||
@@ -646,10 +645,9 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy, | |||
646 | 645 | ||
647 | j_dbs_info->prev_cpu_idle = get_cpu_idle_time(j, | 646 | j_dbs_info->prev_cpu_idle = get_cpu_idle_time(j, |
648 | &j_dbs_info->prev_cpu_wall); | 647 | &j_dbs_info->prev_cpu_wall); |
649 | if (dbs_tuners_ins.ignore_nice) { | 648 | if (dbs_tuners_ins.ignore_nice) |
650 | j_dbs_info->prev_cpu_nice = | 649 | j_dbs_info->prev_cpu_nice = |
651 | kstat_cpu(j).cpustat.nice; | 650 | kcpustat_cpu(j).cpustat[CPUTIME_NICE]; |
652 | } | ||
653 | } | 651 | } |
654 | this_dbs_info->cpu = cpu; | 652 | this_dbs_info->cpu = cpu; |
655 | this_dbs_info->rate_mult = 1; | 653 | this_dbs_info->rate_mult = 1; |
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index c5072a91e848..b40ee1403be9 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c | |||
@@ -11,7 +11,6 @@ | |||
11 | 11 | ||
12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
13 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
14 | #include <linux/sysdev.h> | ||
15 | #include <linux/cpu.h> | 14 | #include <linux/cpu.h> |
16 | #include <linux/sysfs.h> | 15 | #include <linux/sysfs.h> |
17 | #include <linux/cpufreq.h> | 16 | #include <linux/cpufreq.h> |
@@ -61,9 +60,8 @@ static int cpufreq_stats_update(unsigned int cpu) | |||
61 | spin_lock(&cpufreq_stats_lock); | 60 | spin_lock(&cpufreq_stats_lock); |
62 | stat = per_cpu(cpufreq_stats_table, cpu); | 61 | stat = per_cpu(cpufreq_stats_table, cpu); |
63 | if (stat->time_in_state) | 62 | if (stat->time_in_state) |
64 | stat->time_in_state[stat->last_index] = | 63 | stat->time_in_state[stat->last_index] += |
65 | cputime64_add(stat->time_in_state[stat->last_index], | 64 | cur_time - stat->last_time; |
66 | cputime_sub(cur_time, stat->last_time)); | ||
67 | stat->last_time = cur_time; | 65 | stat->last_time = cur_time; |
68 | spin_unlock(&cpufreq_stats_lock); | 66 | spin_unlock(&cpufreq_stats_lock); |
69 | return 0; | 67 | return 0; |