Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[CPUFREQ] Use global sysfs cpufreq structure for conservative governor tunings

Same adustments that have been added to the ondemand recently.

Signed-off-by: Thomas Renninger <trenn@suse.de>
Signed-off-by: Dave Jones <davej@redhat.com>

authored by

Thomas Renninger and committed by
Dave Jones
49b015ce 0cda8b91

+110 -19
+110 -19
drivers/cpufreq/cpufreq_conservative.c
··· 164 164 }; 165 165 166 166 /************************** sysfs interface ************************/ 167 - static ssize_t show_sampling_rate_max(struct cpufreq_policy *policy, char *buf) 167 + static ssize_t show_sampling_rate_max(struct kobject *kobj, 168 + struct attribute *attr, char *buf) 168 169 { 169 170 printk_once(KERN_INFO "CPUFREQ: conservative sampling_rate_max " 170 171 "sysfs file is deprecated - used by: %s\n", current->comm); 171 172 return sprintf(buf, "%u\n", -1U); 172 173 } 173 174 174 - static ssize_t show_sampling_rate_min(struct cpufreq_policy *policy, char *buf) 175 + static ssize_t show_sampling_rate_min(struct kobject *kobj, 176 + struct attribute *attr, char *buf) 175 177 { 176 178 return sprintf(buf, "%u\n", min_sampling_rate); 177 179 } 178 180 179 181 #define define_one_ro(_name) \ 180 - static struct freq_attr _name = \ 182 + static struct global_attr _name = \ 181 183 __ATTR(_name, 0444, show_##_name, NULL) 182 184 183 185 define_one_ro(sampling_rate_max); ··· 188 186 /* cpufreq_conservative Governor Tunables */ 189 187 #define show_one(file_name, object) \ 190 188 static ssize_t show_##file_name \ 191 - (struct cpufreq_policy *unused, char *buf) \ 189 + (struct kobject *kobj, struct attribute *attr, char *buf) \ 192 190 { \ 193 191 return sprintf(buf, "%u\n", dbs_tuners_ins.object); \ 194 192 } ··· 199 197 show_one(ignore_nice_load, ignore_nice); 200 198 show_one(freq_step, freq_step); 201 199 202 - static ssize_t store_sampling_down_factor(struct cpufreq_policy *unused, 203 - const char *buf, size_t count) 200 + /*** delete after deprecation time ***/ 201 + #define DEPRECATION_MSG(file_name) \ 202 + printk_once(KERN_INFO "CPUFREQ: Per core conservative sysfs " \ 203 + "interface is deprecated - " #file_name "\n"); 204 + 205 + #define show_one_old(file_name) \ 206 + static ssize_t show_##file_name##_old \ 207 + (struct cpufreq_policy *unused, char *buf) \ 208 + { \ 209 + printk_once(KERN_INFO "CPUFREQ: Per core conservative sysfs " \ 210 + "interface is deprecated - " #file_name "\n"); \ 211 + return show_##file_name(NULL, NULL, buf); \ 212 + } 213 + show_one_old(sampling_rate); 214 + show_one_old(sampling_down_factor); 215 + show_one_old(up_threshold); 216 + show_one_old(down_threshold); 217 + show_one_old(ignore_nice_load); 218 + show_one_old(freq_step); 219 + show_one_old(sampling_rate_min); 220 + show_one_old(sampling_rate_max); 221 + 222 + #define define_one_ro_old(object, _name) \ 223 + static struct freq_attr object = \ 224 + __ATTR(_name, 0444, show_##_name##_old, NULL) 225 + 226 + define_one_ro_old(sampling_rate_min_old, sampling_rate_min); 227 + define_one_ro_old(sampling_rate_max_old, sampling_rate_max); 228 + 229 + /*** delete after deprecation time ***/ 230 + 231 + static ssize_t store_sampling_down_factor(struct kobject *a, 232 + struct attribute *b, 233 + const char *buf, size_t count) 204 234 { 205 235 unsigned int input; 206 236 int ret; ··· 248 214 return count; 249 215 } 250 216 251 - static ssize_t store_sampling_rate(struct cpufreq_policy *unused, 252 - const char *buf, size_t count) 217 + static ssize_t store_sampling_rate(struct kobject *a, struct attribute *b, 218 + const char *buf, size_t count) 253 219 { 254 220 unsigned int input; 255 221 int ret; ··· 265 231 return count; 266 232 } 267 233 268 - static ssize_t store_up_threshold(struct cpufreq_policy *unused, 269 - const char *buf, size_t count) 234 + static ssize_t store_up_threshold(struct kobject *a, struct attribute *b, 235 + const char *buf, size_t count) 270 236 { 271 237 unsigned int input; 272 238 int ret; ··· 285 251 return count; 286 252 } 287 253 288 - static ssize_t store_down_threshold(struct cpufreq_policy *unused, 289 - const char *buf, size_t count) 254 + static ssize_t store_down_threshold(struct kobject *a, struct attribute *b, 255 + const char *buf, size_t count) 290 256 { 291 257 unsigned int input; 292 258 int ret; ··· 306 272 return count; 307 273 } 308 274 309 - static ssize_t store_ignore_nice_load(struct cpufreq_policy *policy, 310 - const char *buf, size_t count) 275 + static ssize_t store_ignore_nice_load(struct kobject *a, struct attribute *b, 276 + const char *buf, size_t count) 311 277 { 312 278 unsigned int input; 313 279 int ret; ··· 342 308 return count; 343 309 } 344 310 345 - static ssize_t store_freq_step(struct cpufreq_policy *policy, 346 - const char *buf, size_t count) 311 + static ssize_t store_freq_step(struct kobject *a, struct attribute *b, 312 + const char *buf, size_t count) 347 313 { 348 314 unsigned int input; 349 315 int ret; ··· 365 331 } 366 332 367 333 #define define_one_rw(_name) \ 368 - static struct freq_attr _name = \ 334 + static struct global_attr _name = \ 369 335 __ATTR(_name, 0644, show_##_name, store_##_name) 370 336 371 337 define_one_rw(sampling_rate); ··· 391 357 .attrs = dbs_attributes, 392 358 .name = "conservative", 393 359 }; 360 + 361 + /*** delete after deprecation time ***/ 362 + 363 + #define write_one_old(file_name) \ 364 + static ssize_t store_##file_name##_old \ 365 + (struct cpufreq_policy *unused, const char *buf, size_t count) \ 366 + { \ 367 + printk_once(KERN_INFO "CPUFREQ: Per core conservative sysfs " \ 368 + "interface is deprecated - " #file_name "\n"); \ 369 + return store_##file_name(NULL, NULL, buf, count); \ 370 + } 371 + write_one_old(sampling_rate); 372 + write_one_old(sampling_down_factor); 373 + write_one_old(up_threshold); 374 + write_one_old(down_threshold); 375 + write_one_old(ignore_nice_load); 376 + write_one_old(freq_step); 377 + 378 + #define define_one_rw_old(object, _name) \ 379 + static struct freq_attr object = \ 380 + __ATTR(_name, 0644, show_##_name##_old, store_##_name##_old) 381 + 382 + define_one_rw_old(sampling_rate_old, sampling_rate); 383 + define_one_rw_old(sampling_down_factor_old, sampling_down_factor); 384 + define_one_rw_old(up_threshold_old, up_threshold); 385 + define_one_rw_old(down_threshold_old, down_threshold); 386 + define_one_rw_old(ignore_nice_load_old, ignore_nice_load); 387 + define_one_rw_old(freq_step_old, freq_step); 388 + 389 + static struct attribute *dbs_attributes_old[] = { 390 + &sampling_rate_max_old.attr, 391 + &sampling_rate_min_old.attr, 392 + &sampling_rate_old.attr, 393 + &sampling_down_factor_old.attr, 394 + &up_threshold_old.attr, 395 + &down_threshold_old.attr, 396 + &ignore_nice_load_old.attr, 397 + &freq_step_old.attr, 398 + NULL 399 + }; 400 + 401 + static struct attribute_group dbs_attr_group_old = { 402 + .attrs = dbs_attributes_old, 403 + .name = "conservative", 404 + }; 405 + 406 + /*** delete after deprecation time ***/ 394 407 395 408 /************************** sysfs end ************************/ 396 409 ··· 611 530 612 531 mutex_lock(&dbs_mutex); 613 532 614 - rc = sysfs_create_group(&policy->kobj, &dbs_attr_group); 533 + rc = sysfs_create_group(&policy->kobj, &dbs_attr_group_old); 615 534 if (rc) { 616 535 mutex_unlock(&dbs_mutex); 617 536 return rc; ··· 645 564 if (latency == 0) 646 565 latency = 1; 647 566 567 + rc = sysfs_create_group(cpufreq_global_kobject, 568 + &dbs_attr_group); 569 + if (rc) { 570 + mutex_unlock(&dbs_mutex); 571 + return rc; 572 + } 573 + 648 574 /* 649 575 * conservative does not implement micro like ondemand 650 576 * governor, thus we are bound to jiffes/HZ ··· 679 591 dbs_timer_exit(this_dbs_info); 680 592 681 593 mutex_lock(&dbs_mutex); 682 - sysfs_remove_group(&policy->kobj, &dbs_attr_group); 594 + sysfs_remove_group(&policy->kobj, &dbs_attr_group_old); 683 595 dbs_enable--; 684 596 mutex_destroy(&this_dbs_info->timer_mutex); 685 597 ··· 693 605 CPUFREQ_TRANSITION_NOTIFIER); 694 606 695 607 mutex_unlock(&dbs_mutex); 608 + if (!dbs_enable) 609 + sysfs_remove_group(cpufreq_global_kobject, 610 + &dbs_attr_group); 696 611 697 612 break; 698 613