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

Merge tag 'pm+acpi-3.20-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull more ACPI and power management updates from Rafael Wysocki:
"These are two reverts related to system suspend breakage by one of a
recent commits, a fix for a recently introduced bug in devfreq and a
bunch of other things that didn't make it into my previous pull
request, but otherwise are ready to go.

Specifics:

- Revert two ACPI EC driver commits, one that broke system suspend on
Acer Aspire S5 and one that depends on it (Rafael J Wysocki).

- Fix a typo leading to an incorrect check in the exynos-ppmu devfreq
driver (Dan Carpenter).

- Add support for one more Broadwell CPU model to intel_idle (Len Brown).

- Fix an obscure problem with state transitions related to interrupts
in the speedstep-smi cpufreq driver (Mikulas Patocka).

- Remove some unnecessary messages related to the "out of memory"
condition from the core PM code (Quentin Lambert).

- Update turbostat parameters and documentation, add support for one
more Broadwell CPU model to it and modify it to skip printing
disabled package C-states (Len Brown)"

* tag 'pm+acpi-3.20-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
PM / devfreq: event: testing the wrong variable
cpufreq: speedstep-smi: enable interrupts when waiting
PM / OPP / clk: Remove unnecessary OOM message
Revert "ACPI / EC: Add query flushing support"
Revert "ACPI / EC: Add GPE reference counting debugging messages"
tools/power turbostat: support additional Broadwell model
intel_idle: support additional Broadwell model
tools/power turbostat: update parameters, documentation
tools/power turbostat: Skip printing disabled package C-states

+302 -286
+18 -107
drivers/acpi/ec.c
··· 31 31 32 32 /* Uncomment next line to get verbose printout */ 33 33 /* #define DEBUG */ 34 - #define DEBUG_REF 0 35 34 #define pr_fmt(fmt) "ACPI : EC: " fmt 36 35 37 36 #include <linux/kernel.h> ··· 76 77 * when trying to clear the EC */ 77 78 78 79 enum { 79 - EC_FLAGS_EVENT_ENABLED, /* Event is enabled */ 80 - EC_FLAGS_EVENT_PENDING, /* Event is pending */ 81 - EC_FLAGS_EVENT_DETECTED, /* Event is detected */ 80 + EC_FLAGS_QUERY_PENDING, /* Query is pending */ 82 81 EC_FLAGS_HANDLERS_INSTALLED, /* Handlers for GPE and 83 82 * OpReg are installed */ 84 83 EC_FLAGS_STARTED, /* Driver is started */ ··· 87 90 88 91 #define ACPI_EC_COMMAND_POLL 0x01 /* Available for command byte */ 89 92 #define ACPI_EC_COMMAND_COMPLETE 0x02 /* Completed last byte */ 90 - 91 - #define ec_debug_ref(ec, fmt, ...) \ 92 - do { \ 93 - if (DEBUG_REF) \ 94 - pr_debug("%lu: " fmt, ec->reference_count, \ 95 - ## __VA_ARGS__); \ 96 - } while (0) 97 93 98 94 /* ec.c is compiled in acpi namespace so this shows up as acpi.ec_delay param */ 99 95 static unsigned int ec_delay __read_mostly = ACPI_EC_DELAY; ··· 149 159 static bool acpi_ec_flushed(struct acpi_ec *ec) 150 160 { 151 161 return ec->reference_count == 1; 152 - } 153 - 154 - static bool acpi_ec_has_pending_event(struct acpi_ec *ec) 155 - { 156 - return test_bit(EC_FLAGS_EVENT_DETECTED, &ec->flags) || 157 - test_bit(EC_FLAGS_EVENT_PENDING, &ec->flags); 158 162 } 159 163 160 164 /* -------------------------------------------------------------------------- ··· 318 334 * the flush operation is not in 319 335 * progress 320 336 * @ec: the EC device 321 - * @allow_event: whether event should be handled 322 337 * 323 338 * This function must be used before taking a new action that should hold 324 339 * the reference count. If this function returns false, then the action 325 340 * must be discarded or it will prevent the flush operation from being 326 341 * completed. 327 - * 328 - * During flushing, QR_EC command need to pass this check when there is a 329 - * pending event, so that the reference count held for the pending event 330 - * can be decreased by the completion of the QR_EC command. 331 342 */ 332 - static bool acpi_ec_submit_flushable_request(struct acpi_ec *ec, 333 - bool allow_event) 343 + static bool acpi_ec_submit_flushable_request(struct acpi_ec *ec) 334 344 { 335 - if (!acpi_ec_started(ec)) { 336 - if (!allow_event || !acpi_ec_has_pending_event(ec)) 337 - return false; 338 - } 345 + if (!acpi_ec_started(ec)) 346 + return false; 339 347 acpi_ec_submit_request(ec); 340 348 return true; 341 349 } 342 350 343 - static void acpi_ec_submit_event(struct acpi_ec *ec) 351 + static void acpi_ec_submit_query(struct acpi_ec *ec) 344 352 { 345 - if (!test_bit(EC_FLAGS_EVENT_DETECTED, &ec->flags) || 346 - !test_bit(EC_FLAGS_EVENT_ENABLED, &ec->flags)) 347 - return; 348 - /* Hold reference for pending event */ 349 - if (!acpi_ec_submit_flushable_request(ec, true)) 350 - return; 351 - ec_debug_ref(ec, "Increase event\n"); 352 - if (!test_and_set_bit(EC_FLAGS_EVENT_PENDING, &ec->flags)) { 353 - pr_debug("***** Event query started *****\n"); 353 + if (!test_and_set_bit(EC_FLAGS_QUERY_PENDING, &ec->flags)) { 354 + pr_debug("***** Event started *****\n"); 354 355 schedule_work(&ec->work); 355 - return; 356 356 } 357 - acpi_ec_complete_request(ec); 358 - ec_debug_ref(ec, "Decrease event\n"); 359 357 } 360 358 361 - static void acpi_ec_complete_event(struct acpi_ec *ec) 359 + static void acpi_ec_complete_query(struct acpi_ec *ec) 362 360 { 363 361 if (ec->curr->command == ACPI_EC_COMMAND_QUERY) { 364 - clear_bit(EC_FLAGS_EVENT_PENDING, &ec->flags); 365 - pr_debug("***** Event query stopped *****\n"); 366 - /* Unhold reference for pending event */ 367 - acpi_ec_complete_request(ec); 368 - ec_debug_ref(ec, "Decrease event\n"); 369 - /* Check if there is another SCI_EVT detected */ 370 - acpi_ec_submit_event(ec); 362 + clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); 363 + pr_debug("***** Event stopped *****\n"); 371 364 } 372 - } 373 - 374 - static void acpi_ec_submit_detection(struct acpi_ec *ec) 375 - { 376 - /* Hold reference for query submission */ 377 - if (!acpi_ec_submit_flushable_request(ec, false)) 378 - return; 379 - ec_debug_ref(ec, "Increase query\n"); 380 - if (!test_and_set_bit(EC_FLAGS_EVENT_DETECTED, &ec->flags)) { 381 - pr_debug("***** Event detection blocked *****\n"); 382 - acpi_ec_submit_event(ec); 383 - return; 384 - } 385 - acpi_ec_complete_request(ec); 386 - ec_debug_ref(ec, "Decrease query\n"); 387 - } 388 - 389 - static void acpi_ec_complete_detection(struct acpi_ec *ec) 390 - { 391 - if (ec->curr->command == ACPI_EC_COMMAND_QUERY) { 392 - clear_bit(EC_FLAGS_EVENT_DETECTED, &ec->flags); 393 - pr_debug("***** Event detetion unblocked *****\n"); 394 - /* Unhold reference for query submission */ 395 - acpi_ec_complete_request(ec); 396 - ec_debug_ref(ec, "Decrease query\n"); 397 - } 398 - } 399 - 400 - static void acpi_ec_enable_event(struct acpi_ec *ec) 401 - { 402 - unsigned long flags; 403 - 404 - spin_lock_irqsave(&ec->lock, flags); 405 - set_bit(EC_FLAGS_EVENT_ENABLED, &ec->flags); 406 - /* 407 - * An event may be pending even with SCI_EVT=0, so QR_EC should 408 - * always be issued right after started. 409 - */ 410 - acpi_ec_submit_detection(ec); 411 - spin_unlock_irqrestore(&ec->lock, flags); 412 365 } 413 366 414 367 static int ec_transaction_completed(struct acpi_ec *ec) ··· 389 468 t->rdata[t->ri++] = acpi_ec_read_data(ec); 390 469 if (t->rlen == t->ri) { 391 470 t->flags |= ACPI_EC_COMMAND_COMPLETE; 392 - acpi_ec_complete_event(ec); 393 471 if (t->command == ACPI_EC_COMMAND_QUERY) 394 472 pr_debug("***** Command(%s) hardware completion *****\n", 395 473 acpi_ec_cmd_string(t->command)); ··· 399 479 } else if (t->wlen == t->wi && 400 480 (status & ACPI_EC_FLAG_IBF) == 0) { 401 481 t->flags |= ACPI_EC_COMMAND_COMPLETE; 402 - acpi_ec_complete_event(ec); 403 482 wakeup = true; 404 483 } 405 484 goto out; ··· 407 488 !(status & ACPI_EC_FLAG_SCI) && 408 489 (t->command == ACPI_EC_COMMAND_QUERY)) { 409 490 t->flags |= ACPI_EC_COMMAND_POLL; 410 - acpi_ec_complete_detection(ec); 491 + acpi_ec_complete_query(ec); 411 492 t->rdata[t->ri++] = 0x00; 412 493 t->flags |= ACPI_EC_COMMAND_COMPLETE; 413 - acpi_ec_complete_event(ec); 414 494 pr_debug("***** Command(%s) software completion *****\n", 415 495 acpi_ec_cmd_string(t->command)); 416 496 wakeup = true; 417 497 } else if ((status & ACPI_EC_FLAG_IBF) == 0) { 418 498 acpi_ec_write_cmd(ec, t->command); 419 499 t->flags |= ACPI_EC_COMMAND_POLL; 420 - acpi_ec_complete_detection(ec); 500 + acpi_ec_complete_query(ec); 421 501 } else 422 502 goto err; 423 503 goto out; ··· 437 519 } 438 520 out: 439 521 if (status & ACPI_EC_FLAG_SCI) 440 - acpi_ec_submit_detection(ec); 522 + acpi_ec_submit_query(ec); 441 523 if (wakeup && in_interrupt()) 442 524 wake_up(&ec->wait); 443 525 } ··· 498 580 /* start transaction */ 499 581 spin_lock_irqsave(&ec->lock, tmp); 500 582 /* Enable GPE for command processing (IBF=0/OBF=1) */ 501 - if (!acpi_ec_submit_flushable_request(ec, true)) { 583 + if (!acpi_ec_submit_flushable_request(ec)) { 502 584 ret = -EINVAL; 503 585 goto unlock; 504 586 } 505 - ec_debug_ref(ec, "Increase command\n"); 506 587 /* following two actions should be kept atomic */ 507 588 ec->curr = t; 508 589 pr_debug("***** Command(%s) started *****\n", ··· 517 600 ec->curr = NULL; 518 601 /* Disable GPE for command processing (IBF=0/OBF=1) */ 519 602 acpi_ec_complete_request(ec); 520 - ec_debug_ref(ec, "Decrease command\n"); 521 603 unlock: 522 604 spin_unlock_irqrestore(&ec->lock, tmp); 523 605 return ret; ··· 678 762 if (!test_and_set_bit(EC_FLAGS_STARTED, &ec->flags)) { 679 763 pr_debug("+++++ Starting EC +++++\n"); 680 764 /* Enable GPE for event processing (SCI_EVT=1) */ 681 - if (!resuming) { 765 + if (!resuming) 682 766 acpi_ec_submit_request(ec); 683 - ec_debug_ref(ec, "Increase driver\n"); 684 - } 685 767 pr_info("+++++ EC started +++++\n"); 686 768 } 687 769 spin_unlock_irqrestore(&ec->lock, flags); ··· 708 794 wait_event(ec->wait, acpi_ec_stopped(ec)); 709 795 spin_lock_irqsave(&ec->lock, flags); 710 796 /* Disable GPE for event processing (SCI_EVT=1) */ 711 - if (!suspending) { 797 + if (!suspending) 712 798 acpi_ec_complete_request(ec); 713 - ec_debug_ref(ec, "Decrease driver\n"); 714 - } 715 799 clear_bit(EC_FLAGS_STARTED, &ec->flags); 716 800 clear_bit(EC_FLAGS_STOPPED, &ec->flags); 717 801 pr_info("+++++ EC stopped +++++\n"); ··· 879 967 { 880 968 struct acpi_ec *ec = container_of(work, struct acpi_ec, work); 881 969 882 - pr_debug("***** Event poller started *****\n"); 883 970 acpi_ec_query(ec, NULL); 884 - pr_debug("***** Event poller stopped *****\n"); 885 971 } 886 972 887 973 static u32 acpi_ec_gpe_handler(acpi_handle gpe_device, ··· 949 1039 950 1040 if (!ec) 951 1041 return NULL; 1042 + ec->flags = 1 << EC_FLAGS_QUERY_PENDING; 952 1043 mutex_init(&ec->mutex); 953 1044 init_waitqueue_head(&ec->wait); 954 1045 INIT_LIST_HEAD(&ec->list); ··· 1100 1189 ret = ec_install_handlers(ec); 1101 1190 1102 1191 /* EC is fully operational, allow queries */ 1103 - acpi_ec_enable_event(ec); 1192 + clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags); 1104 1193 1105 1194 /* Clear stale _Q events if hardware might require that */ 1106 1195 if (EC_FLAGS_CLEAR_ON_RESUME)
-1
drivers/base/firmware_class.c
··· 855 855 856 856 fw_priv = kzalloc(sizeof(*fw_priv), GFP_KERNEL); 857 857 if (!fw_priv) { 858 - dev_err(device, "%s: kmalloc failed\n", __func__); 859 858 fw_priv = ERR_PTR(-ENOMEM); 860 859 goto exit; 861 860 }
+1 -3
drivers/base/power/clock_ops.c
··· 81 81 return -EINVAL; 82 82 83 83 ce = kzalloc(sizeof(*ce), GFP_KERNEL); 84 - if (!ce) { 85 - dev_err(dev, "Not enough memory for clock entry.\n"); 84 + if (!ce) 86 85 return -ENOMEM; 87 - } 88 86 89 87 if (con_id) { 90 88 ce->con_id = kstrdup(con_id, GFP_KERNEL);
+2 -6
drivers/base/power/opp.c
··· 474 474 475 475 /* allocate new OPP node */ 476 476 new_opp = kzalloc(sizeof(*new_opp), GFP_KERNEL); 477 - if (!new_opp) { 478 - dev_warn(dev, "%s: Unable to create new OPP node\n", __func__); 477 + if (!new_opp) 479 478 return -ENOMEM; 480 - } 481 479 482 480 /* Hold our list modification lock here */ 483 481 mutex_lock(&dev_opp_list_lock); ··· 693 695 694 696 /* keep the node allocated */ 695 697 new_opp = kmalloc(sizeof(*new_opp), GFP_KERNEL); 696 - if (!new_opp) { 697 - dev_warn(dev, "%s: Unable to create OPP\n", __func__); 698 + if (!new_opp) 698 699 return -ENOMEM; 699 - } 700 700 701 701 mutex_lock(&dev_opp_list_lock); 702 702
+3
drivers/cpufreq/speedstep-lib.c
··· 400 400 401 401 pr_debug("previous speed is %u\n", prev_speed); 402 402 403 + preempt_disable(); 403 404 local_irq_save(flags); 404 405 405 406 /* switch to low state */ ··· 465 464 466 465 out: 467 466 local_irq_restore(flags); 467 + preempt_enable(); 468 + 468 469 return ret; 469 470 } 470 471 EXPORT_SYMBOL_GPL(speedstep_get_freqs);
+12
drivers/cpufreq/speedstep-smi.c
··· 156 156 return; 157 157 158 158 /* Disable IRQs */ 159 + preempt_disable(); 159 160 local_irq_save(flags); 160 161 161 162 command = (smi_sig & 0xffffff00) | (smi_cmd & 0xff); ··· 167 166 168 167 do { 169 168 if (retry) { 169 + /* 170 + * We need to enable interrupts, otherwise the blockage 171 + * won't resolve. 172 + * 173 + * We disable preemption so that other processes don't 174 + * run. If other processes were running, they could 175 + * submit more DMA requests, making the blockage worse. 176 + */ 170 177 pr_debug("retry %u, previous result %u, waiting...\n", 171 178 retry, result); 179 + local_irq_enable(); 172 180 mdelay(retry * 50); 181 + local_irq_disable(); 173 182 } 174 183 retry++; 175 184 __asm__ __volatile__( ··· 196 185 197 186 /* enable IRQs */ 198 187 local_irq_restore(flags); 188 + preempt_enable(); 199 189 200 190 if (new_state == state) 201 191 pr_debug("change to %u MHz succeeded after %u tries "
+2 -2
drivers/devfreq/event/exynos-ppmu.c
··· 327 327 328 328 for (i = 0; i < info->num_events; i++) { 329 329 edev[i] = devm_devfreq_event_add_edev(&pdev->dev, &desc[i]); 330 - if (IS_ERR(edev)) { 331 - ret = PTR_ERR(edev); 330 + if (IS_ERR(edev[i])) { 331 + ret = PTR_ERR(edev[i]); 332 332 dev_err(&pdev->dev, 333 333 "failed to add devfreq-event device\n"); 334 334 goto err;
+1
drivers/idle/intel_idle.c
··· 727 727 ICPU(0x46, idle_cpu_hsw), 728 728 ICPU(0x4d, idle_cpu_avn), 729 729 ICPU(0x3d, idle_cpu_bdw), 730 + ICPU(0x47, idle_cpu_bdw), 730 731 ICPU(0x4f, idle_cpu_bdw), 731 732 ICPU(0x56, idle_cpu_bdw), 732 733 {}
+39 -29
tools/power/x86/turbostat/turbostat.8
··· 9 9 .br 10 10 .B turbostat 11 11 .RB [ Options ] 12 - .RB [ "\-i interval_sec" ] 12 + .RB [ "\--interval seconds" ] 13 13 .SH DESCRIPTION 14 14 \fBturbostat \fP reports processor topology, frequency, 15 15 idle power-state statistics, temperature and power on X86 processors. ··· 18 18 \fBcommand\fP, which is forked and statistics are printed 19 19 upon its completion. 20 20 The second method is to omit the command, 21 - and turbodstat will print statistics every 5 seconds. 22 - The 5-second interval can changed using the -i option. 21 + and turbostat displays statistics every 5 seconds. 22 + The 5-second interval can be changed using the --interval option. 23 23 24 - Some information is not availalbe on older processors. 24 + Some information is not available on older processors. 25 25 .SS Options 26 - The \fB-p\fP option limits output to the 1st thread in 1st core of each package. 26 + \fB--Counter MSR#\fP shows the delta of the specified 64-bit MSR counter. 27 27 .PP 28 - The \fB-P\fP option limits output to the 1st thread in each Package. 28 + \fB--counter MSR#\fP shows the delta of the specified 32-bit MSR counter. 29 29 .PP 30 - The \fB-S\fP option limits output to a 1-line System Summary for each interval. 30 + \fB--Dump\fP displays the raw counter values. 31 31 .PP 32 - The \fB-v\fP option increases verbosity. 32 + \fB--debug\fP displays additional system configuration information. Invoking this parameter 33 + more than once may also enable internal turbostat debug information. 33 34 .PP 34 - The \fB-c MSR#\fP option includes the delta of the specified 32-bit MSR counter. 35 + \fB--interval seconds\fP overrides the default 5-second measurement interval. 35 36 .PP 36 - The \fB-C MSR#\fP option includes the delta of the specified 64-bit MSR counter. 37 + \fB--help\fP displays usage for the most common parameters. 37 38 .PP 38 - The \fB-m MSR#\fP option includes the the specified 32-bit MSR value. 39 + \fB--Joules\fP displays energy in Joules, rather than dividing Joules by time to print power in Watts. 39 40 .PP 40 - The \fB-M MSR#\fP option includes the the specified 64-bit MSR value. 41 + \fB--MSR MSR#\fP shows the specified 64-bit MSR value. 41 42 .PP 42 - The \fB-i interval_sec\fP option prints statistics every \fiinterval_sec\fP seconds. 43 - The default is 5 seconds. 43 + \fB--msr MSR#\fP shows the specified 32-bit MSR value. 44 44 .PP 45 - The \fBcommand\fP parameter forks \fBcommand\fP and upon its exit, 45 + \fB--Package\fP limits output to the system summary plus the 1st thread in each Package. 46 + .PP 47 + \fB--processor\fP limits output to the system summary plus the 1st thread in each processor of each package. Ie. it skips hyper-threaded siblings. 48 + .PP 49 + \fB--Summary\fP limits output to a 1-line System Summary for each interval. 50 + .PP 51 + \fB--TCC temperature\fP sets the Thermal Control Circuit temperature for systems which do not export that value. This is used for making sense of the Digital Thermal Sensor outputs, as they return degrees Celsius below the TCC activation temperature. 52 + .PP 53 + \fB--version\fP displays the version. 54 + .PP 55 + The \fBcommand\fP parameter forks \fBcommand\fP, and upon its exit, 46 56 displays the statistics gathered since it was forked. 47 57 .PP 48 58 .SH FIELD DESCRIPTIONS ··· 62 52 \fBCPU\fP Linux CPU (logical processor) number. 63 53 Note that multiple CPUs per core indicate support for Intel(R) Hyper-Threading Technology. 64 54 \fBAVG_MHz\fP number of cycles executed divided by time elapsed. 65 - \fB%Buzy\fP percent of the interval that the CPU retired instructions, aka. % of time in "C0" state. 55 + \fB%Busy\fP percent of the interval that the CPU retired instructions, aka. % of time in "C0" state. 66 56 \fBBzy_MHz\fP average clock rate while the CPU was busy (in "c0" state). 67 57 \fBTSC_MHz\fP average MHz that the TSC ran during the entire interval. 68 58 \fBCPU%c1, CPU%c3, CPU%c6, CPU%c7\fP show the percentage residency in hardware core idle states. ··· 78 68 .fi 79 69 .PP 80 70 .SH EXAMPLE 81 - Without any parameters, turbostat prints out counters ever 5 seconds. 71 + Without any parameters, turbostat displays statistics ever 5 seconds. 82 72 (override interval with "-i sec" option, or specify a command 83 73 for turbostat to fork). 84 74 ··· 101 91 3 3 3 0.20 1596 3492 0 0.44 0.00 99.37 0.00 23 102 92 3 7 5 0.31 1596 3492 0 0.33 103 93 .fi 104 - .SH VERBOSE EXAMPLE 105 - The "-v" option adds verbosity to the output: 94 + .SH DEBUG EXAMPLE 95 + The "--debug" option prints additional system information before measurements: 106 96 107 97 .nf 108 - [root@ivy]# turbostat -v 109 - turbostat v3.0 November 23, 2012 - Len Brown <lenb@kernel.org> 98 + turbostat version 4.0 10-Feb, 2015 - Len Brown <lenb@kernel.org> 110 99 CPUID(0): GenuineIntel 13 CPUID levels; family:model:stepping 0x6:3a:9 (6:58:9) 111 100 CPUID(6): APERF, DTS, PTM, EPB 112 - RAPL: 851 sec. Joule Counter Range 101 + RAPL: 851 sec. Joule Counter Range, at 77 Watts 113 102 cpu0: MSR_NHM_PLATFORM_INFO: 0x81010f0012300 114 103 16 * 100 = 1600 MHz max efficiency 115 104 35 * 100 = 3500 MHz TSC frequency 116 - cpu0: MSR_NHM_SNB_PKG_CST_CFG_CTL: 0x1e008402 (UNdemote-C3, UNdemote-C1, demote-C3, demote-C1, locked: pkg-cstate-limit=2: pc6-noret) 105 + cpu0: MSR_IA32_POWER_CTL: 0x0014005d (C1E auto-promotion: DISabled) 106 + cpu0: MSR_NHM_SNB_PKG_CST_CFG_CTL: 0x1e008402 (UNdemote-C3, UNdemote-C1, demote-C3, demote-C1, locked: pkg-cstate-limit=2: pc6n) 117 107 cpu0: MSR_NHM_TURBO_RATIO_LIMIT: 0x25262727 118 108 37 * 100 = 3700 MHz max turbo 4 active cores 119 109 38 * 100 = 3800 MHz max turbo 3 active cores ··· 122 112 cpu0: MSR_IA32_ENERGY_PERF_BIAS: 0x00000006 (balanced) 123 113 cpu0: MSR_RAPL_POWER_UNIT: 0x000a1003 (0.125000 Watts, 0.000015 Joules, 0.000977 sec.) 124 114 cpu0: MSR_PKG_POWER_INFO: 0x01e00268 (77 W TDP, RAPL 60 - 0 W, 0.000000 sec.) 125 - cpu0: MSR_PKG_POWER_LIMIT: 0x830000148268 (UNlocked) 115 + cpu0: MSR_PKG_POWER_LIMIT: 0x30000148268 (UNlocked) 126 116 cpu0: PKG Limit #1: ENabled (77.000000 Watts, 1.000000 sec, clamp DISabled) 127 - cpu0: PKG Limit #2: ENabled (96.000000 Watts, 0.000977* sec, clamp DISabled) 117 + cpu0: PKG Limit #2: DISabled (96.000000 Watts, 0.000977* sec, clamp DISabled) 128 118 cpu0: MSR_PP0_POLICY: 0 129 119 cpu0: MSR_PP0_POWER_LIMIT: 0x00000000 (UNlocked) 130 120 cpu0: Cores Limit: DISabled (0.000000 Watts, 0.000977 sec, clamp DISabled) ··· 133 123 cpu0: GFX Limit: DISabled (0.000000 Watts, 0.000977 sec, clamp DISabled) 134 124 cpu0: MSR_IA32_TEMPERATURE_TARGET: 0x00691400 (105 C) 135 125 cpu0: MSR_IA32_PACKAGE_THERM_STATUS: 0x884e0000 (27 C) 136 - cpu0: MSR_IA32_THERM_STATUS: 0x88560000 (19 C +/- 1) 137 - cpu1: MSR_IA32_THERM_STATUS: 0x88560000 (19 C +/- 1) 138 - cpu2: MSR_IA32_THERM_STATUS: 0x88540000 (21 C +/- 1) 126 + cpu0: MSR_IA32_THERM_STATUS: 0x88580000 (17 C +/- 1) 127 + cpu1: MSR_IA32_THERM_STATUS: 0x885a0000 (15 C +/- 1) 128 + cpu2: MSR_IA32_THERM_STATUS: 0x88570000 (18 C +/- 1) 139 129 cpu3: MSR_IA32_THERM_STATUS: 0x884e0000 (27 C +/- 1) 140 130 ... 141 131 .fi ··· 205 195 206 196 AVG_MHz = APERF_delta/measurement_interval. This is the actual 207 197 number of elapsed cycles divided by the entire sample interval -- 208 - including idle time. Note that this calculation is resiliant 198 + including idle time. Note that this calculation is resilient 209 199 to systems lacking a non-stop TSC. 210 200 211 201 TSC_MHz = TSC_delta/measurement_interval.
+224 -138
tools/power/x86/turbostat/turbostat.c
··· 33 33 #include <signal.h> 34 34 #include <sys/time.h> 35 35 #include <stdlib.h> 36 + #include <getopt.h> 36 37 #include <dirent.h> 37 38 #include <string.h> 38 39 #include <ctype.h> ··· 43 42 #include <errno.h> 44 43 45 44 char *proc_stat = "/proc/stat"; 46 - unsigned int interval_sec = 5; /* set with -i interval_sec */ 47 - unsigned int verbose; /* set with -v */ 48 - unsigned int rapl_verbose; /* set with -R */ 49 - unsigned int rapl_joules; /* set with -J */ 50 - unsigned int thermal_verbose; /* set with -T */ 51 - unsigned int summary_only; /* set with -S */ 52 - unsigned int dump_only; /* set with -s */ 45 + unsigned int interval_sec = 5; 46 + unsigned int debug; 47 + unsigned int rapl_joules; 48 + unsigned int summary_only; 49 + unsigned int dump_only; 53 50 unsigned int skip_c0; 54 51 unsigned int skip_c1; 55 52 unsigned int do_nhm_cstates; 56 53 unsigned int do_snb_cstates; 54 + unsigned int do_pc2; 55 + unsigned int do_pc3; 56 + unsigned int do_pc6; 57 + unsigned int do_pc7; 57 58 unsigned int do_c8_c9_c10; 58 59 unsigned int do_slm_cstates; 59 60 unsigned int use_c1_residency_msr; ··· 316 313 if (do_ptm) 317 314 outp += sprintf(outp, " PkgTmp"); 318 315 319 - if (do_snb_cstates) 316 + if (do_pc2) 320 317 outp += sprintf(outp, " Pkg%%pc2"); 321 - if (do_nhm_cstates && !do_slm_cstates) 318 + if (do_pc3) 322 319 outp += sprintf(outp, " Pkg%%pc3"); 323 - if (do_nhm_cstates && !do_slm_cstates) 320 + if (do_pc6) 324 321 outp += sprintf(outp, " Pkg%%pc6"); 325 - if (do_snb_cstates) 322 + if (do_pc7) 326 323 outp += sprintf(outp, " Pkg%%pc7"); 327 324 if (do_c8_c9_c10) { 328 325 outp += sprintf(outp, " Pkg%%pc8"); ··· 397 394 if (p) { 398 395 outp += sprintf(outp, "package: %d\n", p->package_id); 399 396 outp += sprintf(outp, "pc2: %016llX\n", p->pc2); 400 - outp += sprintf(outp, "pc3: %016llX\n", p->pc3); 401 - outp += sprintf(outp, "pc6: %016llX\n", p->pc6); 402 - outp += sprintf(outp, "pc7: %016llX\n", p->pc7); 397 + if (do_pc3) 398 + outp += sprintf(outp, "pc3: %016llX\n", p->pc3); 399 + if (do_pc6) 400 + outp += sprintf(outp, "pc6: %016llX\n", p->pc6); 401 + if (do_pc7) 402 + outp += sprintf(outp, "pc7: %016llX\n", p->pc7); 403 403 outp += sprintf(outp, "pc8: %016llX\n", p->pc8); 404 404 outp += sprintf(outp, "pc9: %016llX\n", p->pc9); 405 405 outp += sprintf(outp, "pc10: %016llX\n", p->pc10); ··· 534 528 if (do_ptm) 535 529 outp += sprintf(outp, "%8d", p->pkg_temp_c); 536 530 537 - if (do_snb_cstates) 531 + if (do_pc2) 538 532 outp += sprintf(outp, "%8.2f", 100.0 * p->pc2/t->tsc); 539 - if (do_nhm_cstates && !do_slm_cstates) 533 + if (do_pc3) 540 534 outp += sprintf(outp, "%8.2f", 100.0 * p->pc3/t->tsc); 541 - if (do_nhm_cstates && !do_slm_cstates) 535 + if (do_pc6) 542 536 outp += sprintf(outp, "%8.2f", 100.0 * p->pc6/t->tsc); 543 - if (do_snb_cstates) 537 + if (do_pc7) 544 538 outp += sprintf(outp, "%8.2f", 100.0 * p->pc7/t->tsc); 545 539 if (do_c8_c9_c10) { 546 540 outp += sprintf(outp, "%8.2f", 100.0 * p->pc8/t->tsc); ··· 637 631 delta_package(struct pkg_data *new, struct pkg_data *old) 638 632 { 639 633 old->pc2 = new->pc2 - old->pc2; 640 - old->pc3 = new->pc3 - old->pc3; 641 - old->pc6 = new->pc6 - old->pc6; 642 - old->pc7 = new->pc7 - old->pc7; 634 + if (do_pc3) 635 + old->pc3 = new->pc3 - old->pc3; 636 + if (do_pc6) 637 + old->pc6 = new->pc6 - old->pc6; 638 + if (do_pc7) 639 + old->pc7 = new->pc7 - old->pc7; 643 640 old->pc8 = new->pc8 - old->pc8; 644 641 old->pc9 = new->pc9 - old->pc9; 645 642 old->pc10 = new->pc10 - old->pc10; ··· 726 717 } 727 718 728 719 if (old->mperf == 0) { 729 - if (verbose > 1) fprintf(stderr, "cpu%d MPERF 0!\n", old->cpu_id); 720 + if (debug > 1) fprintf(stderr, "cpu%d MPERF 0!\n", old->cpu_id); 730 721 old->mperf = 1; /* divide by 0 protection */ 731 722 } 732 723 ··· 783 774 c->core_temp_c = 0; 784 775 785 776 p->pc2 = 0; 786 - p->pc3 = 0; 787 - p->pc6 = 0; 788 - p->pc7 = 0; 777 + if (do_pc3) 778 + p->pc3 = 0; 779 + if (do_pc6) 780 + p->pc6 = 0; 781 + if (do_pc7) 782 + p->pc7 = 0; 789 783 p->pc8 = 0; 790 784 p->pc9 = 0; 791 785 p->pc10 = 0; ··· 827 815 return 0; 828 816 829 817 average.packages.pc2 += p->pc2; 830 - average.packages.pc3 += p->pc3; 831 - average.packages.pc6 += p->pc6; 832 - average.packages.pc7 += p->pc7; 818 + if (do_pc3) 819 + average.packages.pc3 += p->pc3; 820 + if (do_pc6) 821 + average.packages.pc6 += p->pc6; 822 + if (do_pc7) 823 + average.packages.pc7 += p->pc7; 833 824 average.packages.pc8 += p->pc8; 834 825 average.packages.pc9 += p->pc9; 835 826 average.packages.pc10 += p->pc10; ··· 874 859 average.cores.c7 /= topo.num_cores; 875 860 876 861 average.packages.pc2 /= topo.num_packages; 877 - average.packages.pc3 /= topo.num_packages; 878 - average.packages.pc6 /= topo.num_packages; 879 - average.packages.pc7 /= topo.num_packages; 862 + if (do_pc3) 863 + average.packages.pc3 /= topo.num_packages; 864 + if (do_pc6) 865 + average.packages.pc6 /= topo.num_packages; 866 + if (do_pc7) 867 + average.packages.pc7 /= topo.num_packages; 880 868 881 869 average.packages.pc8 /= topo.num_packages; 882 870 average.packages.pc9 /= topo.num_packages; ··· 979 961 if (!(t->flags & CPU_IS_FIRST_CORE_IN_PACKAGE)) 980 962 return 0; 981 963 982 - if (do_nhm_cstates && !do_slm_cstates) { 964 + if (do_pc3) 983 965 if (get_msr(cpu, MSR_PKG_C3_RESIDENCY, &p->pc3)) 984 966 return -9; 967 + if (do_pc6) 985 968 if (get_msr(cpu, MSR_PKG_C6_RESIDENCY, &p->pc6)) 986 969 return -10; 987 - } 988 - if (do_snb_cstates) { 970 + if (do_pc2) 989 971 if (get_msr(cpu, MSR_PKG_C2_RESIDENCY, &p->pc2)) 990 972 return -11; 973 + if (do_pc7) 991 974 if (get_msr(cpu, MSR_PKG_C7_RESIDENCY, &p->pc7)) 992 975 return -12; 993 - } 994 976 if (do_c8_c9_c10) { 995 977 if (get_msr(cpu, MSR_PKG_C8_RESIDENCY, &p->pc8)) 996 978 return -13; ··· 1036 1018 } 1037 1019 return 0; 1038 1020 } 1021 + 1022 + /* 1023 + * MSR_PKG_CST_CONFIG_CONTROL decoding for pkg_cstate_limit: 1024 + * If you change the values, note they are used both in comparisons 1025 + * (>= PCL__7) and to index pkg_cstate_limit_strings[]. 1026 + */ 1027 + 1028 + #define PCLUKN 0 /* Unknown */ 1029 + #define PCLRSV 1 /* Reserved */ 1030 + #define PCL__0 2 /* PC0 */ 1031 + #define PCL__1 3 /* PC1 */ 1032 + #define PCL__2 4 /* PC2 */ 1033 + #define PCL__3 5 /* PC3 */ 1034 + #define PCL__4 6 /* PC4 */ 1035 + #define PCL__6 7 /* PC6 */ 1036 + #define PCL_6N 8 /* PC6 No Retention */ 1037 + #define PCL_6R 9 /* PC6 Retention */ 1038 + #define PCL__7 10 /* PC7 */ 1039 + #define PCL_7S 11 /* PC7 Shrink */ 1040 + #define PCLUNL 12 /* Unlimited */ 1041 + 1042 + int pkg_cstate_limit = PCLUKN; 1043 + char *pkg_cstate_limit_strings[] = { "reserved", "unknown", "pc0", "pc1", "pc2", 1044 + "pc3", "pc4", "pc6", "pc6n", "pc6r", "pc7", "pc7s", "unlimited"}; 1045 + 1046 + int nhm_pkg_cstate_limits[8] = {PCL__0, PCL__1, PCL__3, PCL__6, PCL__7, PCLRSV, PCLRSV, PCLUNL}; 1047 + int snb_pkg_cstate_limits[8] = {PCL__0, PCL__2, PCL_6N, PCL_6R, PCL__7, PCL_7S, PCLRSV, PCLUNL}; 1048 + int hsw_pkg_cstate_limits[8] = {PCL__0, PCL__2, PCL__3, PCL__6, PCL__7, PCL_7S, PCLRSV, PCLUNL}; 1049 + int slv_pkg_cstate_limits[8] = {PCL__0, PCL__1, PCLRSV, PCLRSV, PCL__4, PCLRSV, PCL__6, PCL__7}; 1050 + int amt_pkg_cstate_limits[8] = {PCL__0, PCL__1, PCL__2, PCLRSV, PCLRSV, PCLRSV, PCL__6, PCL__7}; 1051 + int phi_pkg_cstate_limits[8] = {PCL__0, PCL__2, PCL_6N, PCL_6R, PCLRSV, PCLRSV, PCLRSV, PCLUNL}; 1039 1052 1040 1053 void print_verbose_header(void) 1041 1054 { ··· 1147 1098 1148 1099 fprintf(stderr, "cpu0: MSR_NHM_SNB_PKG_CST_CFG_CTL: 0x%08llx", msr); 1149 1100 1150 - fprintf(stderr, " (%s%s%s%s%slocked: pkg-cstate-limit=%d: ", 1101 + fprintf(stderr, " (%s%s%s%s%slocked: pkg-cstate-limit=%d: %s)\n", 1151 1102 (msr & SNB_C3_AUTO_UNDEMOTE) ? "UNdemote-C3, " : "", 1152 1103 (msr & SNB_C1_AUTO_UNDEMOTE) ? "UNdemote-C1, " : "", 1153 1104 (msr & NHM_C3_AUTO_DEMOTE) ? "demote-C3, " : "", 1154 1105 (msr & NHM_C1_AUTO_DEMOTE) ? "demote-C1, " : "", 1155 1106 (msr & (1 << 15)) ? "" : "UN", 1156 - (unsigned int)msr & 7); 1157 - 1158 - 1159 - switch(msr & 0x7) { 1160 - case 0: 1161 - fprintf(stderr, do_slm_cstates ? "no pkg states" : "pc0"); 1162 - break; 1163 - case 1: 1164 - fprintf(stderr, do_slm_cstates ? "no pkg states" : do_snb_cstates ? "pc2" : "pc0"); 1165 - break; 1166 - case 2: 1167 - fprintf(stderr, do_slm_cstates ? "invalid" : do_snb_cstates ? "pc6-noret" : "pc3"); 1168 - break; 1169 - case 3: 1170 - fprintf(stderr, do_slm_cstates ? "invalid" : "pc6"); 1171 - break; 1172 - case 4: 1173 - fprintf(stderr, do_slm_cstates ? "pc4" : "pc7"); 1174 - break; 1175 - case 5: 1176 - fprintf(stderr, do_slm_cstates ? "invalid" : do_snb_cstates ? "pc7s" : "invalid"); 1177 - break; 1178 - case 6: 1179 - fprintf(stderr, do_slm_cstates ? "pc6" : "invalid"); 1180 - break; 1181 - case 7: 1182 - fprintf(stderr, do_slm_cstates ? "pc7" : "unlimited"); 1183 - break; 1184 - default: 1185 - fprintf(stderr, "invalid"); 1186 - } 1187 - fprintf(stderr, ")\n"); 1107 + (unsigned int)msr & 7, 1108 + pkg_cstate_limit_strings[pkg_cstate_limit]); 1188 1109 1189 1110 if (!do_nhm_turbo_ratio_limit) 1190 1111 return; ··· 1535 1516 * MSR_CORE_C3_RESIDENCY 0x000003fc 1536 1517 * MSR_CORE_C6_RESIDENCY 0x000003fd 1537 1518 * 1519 + * Side effect: 1520 + * sets global pkg_cstate_limit to decode MSR_NHM_SNB_PKG_CST_CFG_CTL 1538 1521 */ 1539 - int has_nhm_msrs(unsigned int family, unsigned int model) 1522 + int probe_nhm_msrs(unsigned int family, unsigned int model) 1540 1523 { 1524 + unsigned long long msr; 1525 + int *pkg_cstate_limits; 1526 + 1541 1527 if (!genuine_intel) 1542 1528 return 0; 1543 1529 ··· 1555 1531 case 0x1F: /* Core i7 and i5 Processor - Nehalem */ 1556 1532 case 0x25: /* Westmere Client - Clarkdale, Arrandale */ 1557 1533 case 0x2C: /* Westmere EP - Gulftown */ 1534 + case 0x2E: /* Nehalem-EX Xeon - Beckton */ 1535 + case 0x2F: /* Westmere-EX Xeon - Eagleton */ 1536 + pkg_cstate_limits = nhm_pkg_cstate_limits; 1537 + break; 1558 1538 case 0x2A: /* SNB */ 1559 1539 case 0x2D: /* SNB Xeon */ 1560 1540 case 0x3A: /* IVB */ 1561 1541 case 0x3E: /* IVB Xeon */ 1542 + pkg_cstate_limits = snb_pkg_cstate_limits; 1543 + break; 1562 1544 case 0x3C: /* HSW */ 1563 1545 case 0x3F: /* HSX */ 1564 1546 case 0x45: /* HSW */ 1565 1547 case 0x46: /* HSW */ 1566 - case 0x37: /* BYT */ 1567 - case 0x4D: /* AVN */ 1568 1548 case 0x3D: /* BDW */ 1549 + case 0x47: /* BDW */ 1569 1550 case 0x4F: /* BDX */ 1570 1551 case 0x56: /* BDX-DE */ 1571 - case 0x2E: /* Nehalem-EX Xeon - Beckton */ 1572 - case 0x2F: /* Westmere-EX Xeon - Eagleton */ 1573 - return 1; 1552 + pkg_cstate_limits = hsw_pkg_cstate_limits; 1553 + break; 1554 + case 0x37: /* BYT */ 1555 + case 0x4D: /* AVN */ 1556 + pkg_cstate_limits = slv_pkg_cstate_limits; 1557 + break; 1558 + case 0x4C: /* AMT */ 1559 + pkg_cstate_limits = amt_pkg_cstate_limits; 1560 + break; 1561 + case 0x57: /* PHI */ 1562 + pkg_cstate_limits = phi_pkg_cstate_limits; 1563 + break; 1574 1564 default: 1575 1565 return 0; 1576 1566 } 1567 + get_msr(0, MSR_NHM_SNB_PKG_CST_CFG_CTL, &msr); 1568 + 1569 + pkg_cstate_limit = pkg_cstate_limits[msr & 0x7]; 1570 + 1571 + return 1; 1577 1572 } 1578 1573 int has_nhm_turbo_ratio_limit(unsigned int family, unsigned int model) 1579 1574 { 1580 - if (!has_nhm_msrs(family, model)) 1581 - return 0; 1582 - 1583 1575 switch (model) { 1584 1576 /* Nehalem compatible, but do not include turbo-ratio limit support */ 1585 1577 case 0x2E: /* Nehalem-EX Xeon - Beckton */ ··· 1809 1769 case 0x45: /* HSW */ 1810 1770 case 0x46: /* HSW */ 1811 1771 case 0x3D: /* BDW */ 1772 + case 0x47: /* BDW */ 1812 1773 do_rapl = RAPL_PKG | RAPL_CORES | RAPL_CORE_POLICY | RAPL_GFX | RAPL_PKG_POWER_INFO; 1813 1774 break; 1814 1775 case 0x3F: /* HSX */ ··· 1848 1807 tdp = get_tdp(model); 1849 1808 1850 1809 rapl_joule_counter_range = 0xFFFFFFFF * rapl_energy_units / tdp; 1851 - if (verbose) 1810 + if (debug) 1852 1811 fprintf(stderr, "RAPL: %.0f sec. Joule Counter Range, at %.0f Watts\n", rapl_joule_counter_range, tdp); 1853 1812 1854 1813 return; ··· 1973 1932 if (get_msr(cpu, MSR_RAPL_POWER_UNIT, &msr)) 1974 1933 return -1; 1975 1934 1976 - if (verbose) { 1935 + if (debug) { 1977 1936 fprintf(stderr, "cpu%d: MSR_RAPL_POWER_UNIT: 0x%08llx " 1978 1937 "(%f Watts, %f Joules, %f sec.)\n", cpu, msr, 1979 1938 rapl_power_units, rapl_energy_units, rapl_time_units); ··· 2030 1989 print_power_limit_msr(cpu, msr, "DRAM Limit"); 2031 1990 } 2032 1991 if (do_rapl & RAPL_CORE_POLICY) { 2033 - if (verbose) { 1992 + if (debug) { 2034 1993 if (get_msr(cpu, MSR_PP0_POLICY, &msr)) 2035 1994 return -7; 2036 1995 ··· 2038 1997 } 2039 1998 } 2040 1999 if (do_rapl & RAPL_CORES) { 2041 - if (verbose) { 2000 + if (debug) { 2042 2001 2043 2002 if (get_msr(cpu, MSR_PP0_POWER_LIMIT, &msr)) 2044 2003 return -9; ··· 2048 2007 } 2049 2008 } 2050 2009 if (do_rapl & RAPL_GFX) { 2051 - if (verbose) { 2010 + if (debug) { 2052 2011 if (get_msr(cpu, MSR_PP1_POLICY, &msr)) 2053 2012 return -8; 2054 2013 ··· 2087 2046 case 0x45: /* HSW */ 2088 2047 case 0x46: /* HSW */ 2089 2048 case 0x3D: /* BDW */ 2049 + case 0x47: /* BDW */ 2090 2050 case 0x4F: /* BDX */ 2091 2051 case 0x56: /* BDX-DE */ 2092 2052 return 1; ··· 2210 2168 2211 2169 target_c_local = (msr >> 16) & 0xFF; 2212 2170 2213 - if (verbose) 2171 + if (debug) 2214 2172 fprintf(stderr, "cpu%d: MSR_IA32_TEMPERATURE_TARGET: 0x%08llx (%d C)\n", 2215 2173 cpu, msr, target_c_local); 2216 2174 ··· 2240 2198 if (ebx == 0x756e6547 && edx == 0x49656e69 && ecx == 0x6c65746e) 2241 2199 genuine_intel = 1; 2242 2200 2243 - if (verbose) 2201 + if (debug) 2244 2202 fprintf(stderr, "CPUID(0): %.4s%.4s%.4s ", 2245 2203 (char *)&ebx, (char *)&edx, (char *)&ecx); 2246 2204 ··· 2251 2209 if (family == 6 || family == 0xf) 2252 2210 model += ((fms >> 16) & 0xf) << 4; 2253 2211 2254 - if (verbose) 2212 + if (debug) 2255 2213 fprintf(stderr, "%d CPUID levels; family:model:stepping 0x%x:%x:%x (%d:%d:%d)\n", 2256 2214 max_level, family, model, stepping, family, model, stepping); 2257 2215 ··· 2287 2245 do_ptm = eax & (1 << 6); 2288 2246 has_epb = ecx & (1 << 3); 2289 2247 2290 - if (verbose) 2248 + if (debug) 2291 2249 fprintf(stderr, "CPUID(6): %sAPERF, %sDTS, %sPTM, %sEPB\n", 2292 2250 has_aperf ? "" : "No ", 2293 2251 do_dts ? "" : "No ", 2294 2252 do_ptm ? "" : "No ", 2295 2253 has_epb ? "" : "No "); 2296 2254 2297 - do_nhm_platform_info = do_nhm_cstates = do_smi = has_nhm_msrs(family, model); 2255 + do_nhm_platform_info = do_nhm_cstates = do_smi = probe_nhm_msrs(family, model); 2298 2256 do_snb_cstates = has_snb_msrs(family, model); 2257 + do_pc2 = do_snb_cstates && (pkg_cstate_limit >= PCL__2); 2258 + do_pc3 = (pkg_cstate_limit >= PCL__3); 2259 + do_pc6 = (pkg_cstate_limit >= PCL__6); 2260 + do_pc7 = do_snb_cstates && (pkg_cstate_limit >= PCL__7); 2299 2261 do_c8_c9_c10 = has_hsw_msrs(family, model); 2300 2262 do_slm_cstates = is_slm(family, model); 2301 2263 bclk = discover_bclk(family, model); 2302 2264 2303 - do_nhm_turbo_ratio_limit = has_nhm_turbo_ratio_limit(family, model); 2265 + do_nhm_turbo_ratio_limit = do_nhm_platform_info && has_nhm_turbo_ratio_limit(family, model); 2304 2266 do_ivt_turbo_ratio_limit = has_ivt_turbo_ratio_limit(family, model); 2305 2267 rapl_probe(family, model); 2306 2268 perf_limit_reasons_probe(family, model); ··· 2313 2267 } 2314 2268 2315 2269 2316 - void usage() 2270 + void help() 2317 2271 { 2318 - errx(1, "%s: [-v][-R][-T][-p|-P|-S][-c MSR#][-C MSR#][-m MSR#][-M MSR#][-i interval_sec | command ...]\n", 2319 - progname); 2272 + fprintf(stderr, 2273 + "Usage: turbostat [OPTIONS][(--interval seconds) | COMMAND ...]\n" 2274 + "\n" 2275 + "Turbostat forks the specified COMMAND and prints statistics\n" 2276 + "when COMMAND completes.\n" 2277 + "If no COMMAND is specified, turbostat wakes every 5-seconds\n" 2278 + "to print statistics, until interrupted.\n" 2279 + "--debug run in \"debug\" mode\n" 2280 + "--interval sec Override default 5-second measurement interval\n" 2281 + "--help print this help message\n" 2282 + "--counter msr print 32-bit counter at address \"msr\"\n" 2283 + "--Counter msr print 64-bit Counter at address \"msr\"\n" 2284 + "--msr msr print 32-bit value at address \"msr\"\n" 2285 + "--MSR msr print 64-bit Value at address \"msr\"\n" 2286 + "--version print version information\n" 2287 + "\n" 2288 + "For more help, run \"man turbostat\"\n"); 2320 2289 } 2321 2290 2322 2291 ··· 2370 2309 if (!summary_only && topo.num_cpus > 1) 2371 2310 show_cpu = 1; 2372 2311 2373 - if (verbose > 1) 2312 + if (debug > 1) 2374 2313 fprintf(stderr, "num_cpus %d max_cpu_num %d\n", topo.num_cpus, topo.max_cpu_num); 2375 2314 2376 2315 cpus = calloc(1, (topo.max_cpu_num + 1) * sizeof(struct cpu_topology)); ··· 2405 2344 int siblings; 2406 2345 2407 2346 if (cpu_is_not_present(i)) { 2408 - if (verbose > 1) 2347 + if (debug > 1) 2409 2348 fprintf(stderr, "cpu%d NOT PRESENT\n", i); 2410 2349 continue; 2411 2350 } ··· 2420 2359 siblings = get_num_ht_siblings(i); 2421 2360 if (siblings > max_siblings) 2422 2361 max_siblings = siblings; 2423 - if (verbose > 1) 2362 + if (debug > 1) 2424 2363 fprintf(stderr, "cpu %d pkg %d core %d\n", 2425 2364 i, cpus[i].physical_package_id, cpus[i].core_id); 2426 2365 } 2427 2366 topo.num_cores_per_pkg = max_core_id + 1; 2428 - if (verbose > 1) 2367 + if (debug > 1) 2429 2368 fprintf(stderr, "max_core_id %d, sizing for %d cores per package\n", 2430 2369 max_core_id, topo.num_cores_per_pkg); 2431 2370 if (!summary_only && topo.num_cores_per_pkg > 1) 2432 2371 show_core = 1; 2433 2372 2434 2373 topo.num_packages = max_package_id + 1; 2435 - if (verbose > 1) 2374 + if (debug > 1) 2436 2375 fprintf(stderr, "max_package_id %d, sizing for %d packages\n", 2437 2376 max_package_id, topo.num_packages); 2438 2377 if (!summary_only && topo.num_packages > 1) 2439 2378 show_pkg = 1; 2440 2379 2441 2380 topo.num_threads_per_core = max_siblings; 2442 - if (verbose > 1) 2381 + if (debug > 1) 2443 2382 fprintf(stderr, "max_siblings %d\n", max_siblings); 2444 2383 2445 2384 free(cpus); ··· 2554 2493 2555 2494 setup_all_buffers(); 2556 2495 2557 - if (verbose) 2496 + if (debug) 2558 2497 print_verbose_header(); 2559 2498 2560 - if (verbose) 2499 + if (debug) 2561 2500 for_all_cpus(print_epb, ODD_COUNTERS); 2562 2501 2563 - if (verbose) 2502 + if (debug) 2564 2503 for_all_cpus(print_perf_limit, ODD_COUNTERS); 2565 2504 2566 - if (verbose) 2505 + if (debug) 2567 2506 for_all_cpus(print_rapl, ODD_COUNTERS); 2568 2507 2569 2508 for_all_cpus(set_temperature_target, ODD_COUNTERS); 2570 2509 2571 - if (verbose) 2510 + if (debug) 2572 2511 for_all_cpus(print_thermal, ODD_COUNTERS); 2573 2512 } 2574 2513 ··· 2633 2572 return status; 2634 2573 } 2635 2574 2575 + void print_version() { 2576 + fprintf(stderr, "turbostat version 4.1 10-Feb, 2015" 2577 + " - Len Brown <lenb@kernel.org>\n"); 2578 + } 2579 + 2636 2580 void cmdline(int argc, char **argv) 2637 2581 { 2638 2582 int opt; 2583 + int option_index = 0; 2584 + static struct option long_options[] = { 2585 + {"Counter", required_argument, 0, 'C'}, 2586 + {"counter", required_argument, 0, 'c'}, 2587 + {"Dump", no_argument, 0, 'D'}, 2588 + {"debug", no_argument, 0, 'd'}, 2589 + {"interval", required_argument, 0, 'i'}, 2590 + {"help", no_argument, 0, 'h'}, 2591 + {"Joules", no_argument, 0, 'J'}, 2592 + {"MSR", required_argument, 0, 'M'}, 2593 + {"msr", required_argument, 0, 'm'}, 2594 + {"Package", no_argument, 0, 'p'}, 2595 + {"processor", no_argument, 0, 'p'}, 2596 + {"Summary", no_argument, 0, 'S'}, 2597 + {"TCC", required_argument, 0, 'T'}, 2598 + {"version", no_argument, 0, 'v' }, 2599 + {0, 0, 0, 0 } 2600 + }; 2639 2601 2640 2602 progname = argv[0]; 2641 2603 2642 - while ((opt = getopt(argc, argv, "+pPsSvi:c:C:m:M:RJT:")) != -1) { 2604 + while ((opt = getopt_long_only(argc, argv, "C:c:Ddhi:JM:m:PpST:v", 2605 + long_options, &option_index)) != -1) { 2643 2606 switch (opt) { 2644 - case 'p': 2645 - show_core_only++; 2646 - break; 2647 - case 'P': 2648 - show_pkg_only++; 2649 - break; 2650 - case 's': 2651 - dump_only++; 2652 - break; 2653 - case 'S': 2654 - summary_only++; 2655 - break; 2656 - case 'v': 2657 - verbose++; 2658 - break; 2659 - case 'i': 2660 - interval_sec = atoi(optarg); 2607 + case 'C': 2608 + sscanf(optarg, "%x", &extra_delta_offset64); 2661 2609 break; 2662 2610 case 'c': 2663 2611 sscanf(optarg, "%x", &extra_delta_offset32); 2664 2612 break; 2665 - case 'C': 2666 - sscanf(optarg, "%x", &extra_delta_offset64); 2613 + case 'D': 2614 + dump_only++; 2667 2615 break; 2668 - case 'm': 2669 - sscanf(optarg, "%x", &extra_msr_offset32); 2616 + case 'd': 2617 + debug++; 2670 2618 break; 2671 - case 'M': 2672 - sscanf(optarg, "%x", &extra_msr_offset64); 2673 - break; 2674 - case 'R': 2675 - rapl_verbose++; 2676 - break; 2677 - case 'T': 2678 - tcc_activation_temp_override = atoi(optarg); 2619 + case 'h': 2620 + default: 2621 + help(); 2622 + exit(1); 2623 + case 'i': 2624 + interval_sec = atoi(optarg); 2679 2625 break; 2680 2626 case 'J': 2681 2627 rapl_joules++; 2682 2628 break; 2683 - 2684 - default: 2685 - usage(); 2629 + case 'M': 2630 + sscanf(optarg, "%x", &extra_msr_offset64); 2631 + break; 2632 + case 'm': 2633 + sscanf(optarg, "%x", &extra_msr_offset32); 2634 + break; 2635 + case 'P': 2636 + show_pkg_only++; 2637 + break; 2638 + case 'p': 2639 + show_core_only++; 2640 + break; 2641 + case 'S': 2642 + summary_only++; 2643 + break; 2644 + case 'T': 2645 + tcc_activation_temp_override = atoi(optarg); 2646 + break; 2647 + case 'v': 2648 + print_version(); 2649 + exit(0); 2650 + break; 2686 2651 } 2687 2652 } 2688 2653 } ··· 2717 2630 { 2718 2631 cmdline(argc, argv); 2719 2632 2720 - if (verbose) 2721 - fprintf(stderr, "turbostat v3.9 23-Jan, 2015" 2722 - " - Len Brown <lenb@kernel.org>\n"); 2633 + if (debug) 2634 + print_version(); 2723 2635 2724 2636 turbostat_init(); 2725 2637