diff options
| author | Len Brown <len.brown@intel.com> | 2017-02-15 17:15:11 -0500 |
|---|---|---|
| committer | Len Brown <len.brown@intel.com> | 2017-03-01 00:14:22 -0500 |
| commit | c8ade3616a1a5cf7767c0338d2b02007796f5d88 (patch) | |
| tree | 36d1c128c49aad47833a2923046ffce1915ec6bf /tools/power | |
| parent | 218f0e8d5c388767be9c78fd2c5bc0a6f416d6d0 (diff) | |
tools/power turbostat: Add --list option to show available header names
It is handy to know the list of column header names,
so that they can be used with --add and --skip
The new --list option shows them:
sudo ./turbostat --list --hide sysfs
,Core,CPU,Avg_MHz,Busy%,Bzy_MHz,TSC_MHz,IRQ,SMI,CPU%c1,CPU%c3,CPU%c6,CPU%c7,CoreTmp,PkgTmp,GFX%rc6,GFXMHz,PkgWatt,CorWatt,GFXWatt
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'tools/power')
| -rw-r--r-- | tools/power/x86/turbostat/turbostat.c | 118 |
1 files changed, 66 insertions, 52 deletions
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c index 48b540a2fe81..7b02fbb65893 100644 --- a/tools/power/x86/turbostat/turbostat.c +++ b/tools/power/x86/turbostat/turbostat.c | |||
| @@ -52,6 +52,7 @@ unsigned int debug; | |||
| 52 | unsigned int quiet; | 52 | unsigned int quiet; |
| 53 | unsigned int rapl_joules; | 53 | unsigned int rapl_joules; |
| 54 | unsigned int summary_only; | 54 | unsigned int summary_only; |
| 55 | unsigned int list_header_only; | ||
| 55 | unsigned int dump_only; | 56 | unsigned int dump_only; |
| 56 | unsigned int do_snb_cstates; | 57 | unsigned int do_snb_cstates; |
| 57 | unsigned int do_knl_cstates; | 58 | unsigned int do_knl_cstates; |
| @@ -469,133 +470,133 @@ unsigned long long bic_lookup(char *name_list) | |||
| 469 | return retval; | 470 | return retval; |
| 470 | } | 471 | } |
| 471 | 472 | ||
| 472 | void print_header(void) | 473 | void print_header(char *delim) |
| 473 | { | 474 | { |
| 474 | struct msr_counter *mp; | 475 | struct msr_counter *mp; |
| 475 | 476 | ||
| 476 | if (DO_BIC(BIC_Package)) | 477 | if (DO_BIC(BIC_Package)) |
| 477 | outp += sprintf(outp, "\tPackage"); | 478 | outp += sprintf(outp, "%sPackage", delim); |
| 478 | if (DO_BIC(BIC_Core)) | 479 | if (DO_BIC(BIC_Core)) |
| 479 | outp += sprintf(outp, "\tCore"); | 480 | outp += sprintf(outp, "%sCore", delim); |
| 480 | if (DO_BIC(BIC_CPU)) | 481 | if (DO_BIC(BIC_CPU)) |
| 481 | outp += sprintf(outp, "\tCPU"); | 482 | outp += sprintf(outp, "%sCPU", delim); |
| 482 | if (DO_BIC(BIC_Avg_MHz)) | 483 | if (DO_BIC(BIC_Avg_MHz)) |
| 483 | outp += sprintf(outp, "\tAvg_MHz"); | 484 | outp += sprintf(outp, "%sAvg_MHz", delim); |
| 484 | if (DO_BIC(BIC_Busy)) | 485 | if (DO_BIC(BIC_Busy)) |
| 485 | outp += sprintf(outp, "\tBusy%%"); | 486 | outp += sprintf(outp, "%sBusy%%", delim); |
| 486 | if (DO_BIC(BIC_Bzy_MHz)) | 487 | if (DO_BIC(BIC_Bzy_MHz)) |
| 487 | outp += sprintf(outp, "\tBzy_MHz"); | 488 | outp += sprintf(outp, "%sBzy_MHz", delim); |
| 488 | if (DO_BIC(BIC_TSC_MHz)) | 489 | if (DO_BIC(BIC_TSC_MHz)) |
| 489 | outp += sprintf(outp, "\tTSC_MHz"); | 490 | outp += sprintf(outp, "%sTSC_MHz", delim); |
| 490 | 491 | ||
| 491 | if (DO_BIC(BIC_IRQ)) | 492 | if (DO_BIC(BIC_IRQ)) |
| 492 | outp += sprintf(outp, "\tIRQ"); | 493 | outp += sprintf(outp, "%sIRQ", delim); |
| 493 | if (DO_BIC(BIC_SMI)) | 494 | if (DO_BIC(BIC_SMI)) |
| 494 | outp += sprintf(outp, "\tSMI"); | 495 | outp += sprintf(outp, "%sSMI", delim); |
| 495 | 496 | ||
| 496 | for (mp = sys.tp; mp; mp = mp->next) { | 497 | for (mp = sys.tp; mp; mp = mp->next) { |
| 497 | if (mp->format == FORMAT_RAW) { | 498 | if (mp->format == FORMAT_RAW) { |
| 498 | if (mp->width == 64) | 499 | if (mp->width == 64) |
| 499 | outp += sprintf(outp, "\t%18.18s", mp->name); | 500 | outp += sprintf(outp, "%s%18.18s", delim, mp->name); |
| 500 | else | 501 | else |
| 501 | outp += sprintf(outp, "\t%10.10s", mp->name); | 502 | outp += sprintf(outp, "%s%10.10s", delim, mp->name); |
| 502 | } else { | 503 | } else { |
| 503 | outp += sprintf(outp, "\t%s", mp->name); | 504 | outp += sprintf(outp, "%s%s", delim, mp->name); |
| 504 | } | 505 | } |
| 505 | } | 506 | } |
| 506 | 507 | ||
| 507 | if (DO_BIC(BIC_CPU_c1)) | 508 | if (DO_BIC(BIC_CPU_c1)) |
| 508 | outp += sprintf(outp, "\tCPU%%c1"); | 509 | outp += sprintf(outp, "%sCPU%%c1", delim); |
| 509 | if (DO_BIC(BIC_CPU_c3) && !do_slm_cstates && !do_knl_cstates) | 510 | if (DO_BIC(BIC_CPU_c3) && !do_slm_cstates && !do_knl_cstates) |
| 510 | outp += sprintf(outp, "\tCPU%%c3"); | 511 | outp += sprintf(outp, "%sCPU%%c3", delim); |
| 511 | if (DO_BIC(BIC_CPU_c6)) | 512 | if (DO_BIC(BIC_CPU_c6)) |
| 512 | outp += sprintf(outp, "\tCPU%%c6"); | 513 | outp += sprintf(outp, "%sCPU%%c6", delim); |
| 513 | if (DO_BIC(BIC_CPU_c7)) | 514 | if (DO_BIC(BIC_CPU_c7)) |
| 514 | outp += sprintf(outp, "\tCPU%%c7"); | 515 | outp += sprintf(outp, "%sCPU%%c7", delim); |
| 515 | 516 | ||
| 516 | if (DO_BIC(BIC_Mod_c6)) | 517 | if (DO_BIC(BIC_Mod_c6)) |
| 517 | outp += sprintf(outp, "\tMod%%c6"); | 518 | outp += sprintf(outp, "%sMod%%c6", delim); |
| 518 | 519 | ||
| 519 | if (DO_BIC(BIC_CoreTmp)) | 520 | if (DO_BIC(BIC_CoreTmp)) |
| 520 | outp += sprintf(outp, "\tCoreTmp"); | 521 | outp += sprintf(outp, "%sCoreTmp", delim); |
| 521 | 522 | ||
| 522 | for (mp = sys.cp; mp; mp = mp->next) { | 523 | for (mp = sys.cp; mp; mp = mp->next) { |
| 523 | if (mp->format == FORMAT_RAW) { | 524 | if (mp->format == FORMAT_RAW) { |
| 524 | if (mp->width == 64) | 525 | if (mp->width == 64) |
| 525 | outp += sprintf(outp, "\t%18.18s", mp->name); | 526 | outp += sprintf(outp, "%s%18.18s", delim, mp->name); |
| 526 | else | 527 | else |
| 527 | outp += sprintf(outp, "\t%10.10s", mp->name); | 528 | outp += sprintf(outp, "%s%10.10s", delim, mp->name); |
| 528 | } else { | 529 | } else { |
| 529 | outp += sprintf(outp, "\t%s", mp->name); | 530 | outp += sprintf(outp, "%s%s", delim, mp->name); |
| 530 | } | 531 | } |
| 531 | } | 532 | } |
| 532 | 533 | ||
| 533 | if (DO_BIC(BIC_PkgTmp)) | 534 | if (DO_BIC(BIC_PkgTmp)) |
| 534 | outp += sprintf(outp, "\tPkgTmp"); | 535 | outp += sprintf(outp, "%sPkgTmp", delim); |
| 535 | 536 | ||
| 536 | if (DO_BIC(BIC_GFX_rc6)) | 537 | if (DO_BIC(BIC_GFX_rc6)) |
| 537 | outp += sprintf(outp, "\tGFX%%rc6"); | 538 | outp += sprintf(outp, "%sGFX%%rc6", delim); |
| 538 | 539 | ||
| 539 | if (DO_BIC(BIC_GFXMHz)) | 540 | if (DO_BIC(BIC_GFXMHz)) |
| 540 | outp += sprintf(outp, "\tGFXMHz"); | 541 | outp += sprintf(outp, "%sGFXMHz", delim); |
| 541 | 542 | ||
| 542 | if (do_skl_residency) { | 543 | if (do_skl_residency) { |
| 543 | outp += sprintf(outp, "\tTotl%%C0"); | 544 | outp += sprintf(outp, "%sTotl%%C0", delim); |
| 544 | outp += sprintf(outp, "\tAny%%C0"); | 545 | outp += sprintf(outp, "%sAny%%C0", delim); |
| 545 | outp += sprintf(outp, "\tGFX%%C0"); | 546 | outp += sprintf(outp, "%sGFX%%C0", delim); |
| 546 | outp += sprintf(outp, "\tCPUGFX%%"); | 547 | outp += sprintf(outp, "%sCPUGFX%%", delim); |
| 547 | } | 548 | } |
| 548 | 549 | ||
| 549 | if (DO_BIC(BIC_Pkgpc2)) | 550 | if (DO_BIC(BIC_Pkgpc2)) |
| 550 | outp += sprintf(outp, "\tPkg%%pc2"); | 551 | outp += sprintf(outp, "%sPkg%%pc2", delim); |
| 551 | if (DO_BIC(BIC_Pkgpc3)) | 552 | if (DO_BIC(BIC_Pkgpc3)) |
| 552 | outp += sprintf(outp, "\tPkg%%pc3"); | 553 | outp += sprintf(outp, "%sPkg%%pc3", delim); |
| 553 | if (DO_BIC(BIC_Pkgpc6)) | 554 | if (DO_BIC(BIC_Pkgpc6)) |
| 554 | outp += sprintf(outp, "\tPkg%%pc6"); | 555 | outp += sprintf(outp, "%sPkg%%pc6", delim); |
| 555 | if (DO_BIC(BIC_Pkgpc7)) | 556 | if (DO_BIC(BIC_Pkgpc7)) |
| 556 | outp += sprintf(outp, "\tPkg%%pc7"); | 557 | outp += sprintf(outp, "%sPkg%%pc7", delim); |
| 557 | if (DO_BIC(BIC_Pkgpc8)) | 558 | if (DO_BIC(BIC_Pkgpc8)) |
| 558 | outp += sprintf(outp, "\tPkg%%pc8"); | 559 | outp += sprintf(outp, "%sPkg%%pc8", delim); |
| 559 | if (DO_BIC(BIC_Pkgpc9)) | 560 | if (DO_BIC(BIC_Pkgpc9)) |
| 560 | outp += sprintf(outp, "\tPkg%%pc9"); | 561 | outp += sprintf(outp, "%sPkg%%pc9", delim); |
| 561 | if (DO_BIC(BIC_Pkgpc10)) | 562 | if (DO_BIC(BIC_Pkgpc10)) |
| 562 | outp += sprintf(outp, "\tPk%%pc10"); | 563 | outp += sprintf(outp, "%sPk%%pc10", delim); |
| 563 | 564 | ||
| 564 | if (do_rapl && !rapl_joules) { | 565 | if (do_rapl && !rapl_joules) { |
| 565 | if (DO_BIC(BIC_PkgWatt)) | 566 | if (DO_BIC(BIC_PkgWatt)) |
| 566 | outp += sprintf(outp, "\tPkgWatt"); | 567 | outp += sprintf(outp, "%sPkgWatt", delim); |
| 567 | if (DO_BIC(BIC_CorWatt)) | 568 | if (DO_BIC(BIC_CorWatt)) |
| 568 | outp += sprintf(outp, "\tCorWatt"); | 569 | outp += sprintf(outp, "%sCorWatt", delim); |
| 569 | if (DO_BIC(BIC_GFXWatt)) | 570 | if (DO_BIC(BIC_GFXWatt)) |
| 570 | outp += sprintf(outp, "\tGFXWatt"); | 571 | outp += sprintf(outp, "%sGFXWatt", delim); |
| 571 | if (DO_BIC(BIC_RAMWatt)) | 572 | if (DO_BIC(BIC_RAMWatt)) |
| 572 | outp += sprintf(outp, "\tRAMWatt"); | 573 | outp += sprintf(outp, "%sRAMWatt", delim); |
| 573 | if (DO_BIC(BIC_PKG__)) | 574 | if (DO_BIC(BIC_PKG__)) |
| 574 | outp += sprintf(outp, "\tPKG_%%"); | 575 | outp += sprintf(outp, "%sPKG_%%", delim); |
| 575 | if (DO_BIC(BIC_RAM__)) | 576 | if (DO_BIC(BIC_RAM__)) |
| 576 | outp += sprintf(outp, "\tRAM_%%"); | 577 | outp += sprintf(outp, "%sRAM_%%", delim); |
| 577 | } else if (do_rapl && rapl_joules) { | 578 | } else if (do_rapl && rapl_joules) { |
| 578 | if (DO_BIC(BIC_Pkg_J)) | 579 | if (DO_BIC(BIC_Pkg_J)) |
| 579 | outp += sprintf(outp, "\tPkg_J"); | 580 | outp += sprintf(outp, "%sPkg_J", delim); |
| 580 | if (DO_BIC(BIC_Cor_J)) | 581 | if (DO_BIC(BIC_Cor_J)) |
| 581 | outp += sprintf(outp, "\tCor_J"); | 582 | outp += sprintf(outp, "%sCor_J", delim); |
| 582 | if (DO_BIC(BIC_GFX_J)) | 583 | if (DO_BIC(BIC_GFX_J)) |
| 583 | outp += sprintf(outp, "\tGFX_J"); | 584 | outp += sprintf(outp, "%sGFX_J", delim); |
| 584 | if (DO_BIC(BIC_RAM_J)) | 585 | if (DO_BIC(BIC_RAM_J)) |
| 585 | outp += sprintf(outp, "\tRAM_J"); | 586 | outp += sprintf(outp, "%sRAM_J", delim); |
| 586 | if (DO_BIC(BIC_PKG__)) | 587 | if (DO_BIC(BIC_PKG__)) |
| 587 | outp += sprintf(outp, "\tPKG_%%"); | 588 | outp += sprintf(outp, "%sPKG_%%", delim); |
| 588 | if (DO_BIC(BIC_RAM__)) | 589 | if (DO_BIC(BIC_RAM__)) |
| 589 | outp += sprintf(outp, "\tRAM_%%"); | 590 | outp += sprintf(outp, "%sRAM_%%", delim); |
| 590 | } | 591 | } |
| 591 | for (mp = sys.pp; mp; mp = mp->next) { | 592 | for (mp = sys.pp; mp; mp = mp->next) { |
| 592 | if (mp->format == FORMAT_RAW) { | 593 | if (mp->format == FORMAT_RAW) { |
| 593 | if (mp->width == 64) | 594 | if (mp->width == 64) |
| 594 | outp += sprintf(outp, "\t%18.18s", mp->name); | 595 | outp += sprintf(outp, "%s%18.18s", delim, mp->name); |
| 595 | else | 596 | else |
| 596 | outp += sprintf(outp, "\t%10.10s", mp->name); | 597 | outp += sprintf(outp, "%s%10.10s", delim, mp->name); |
| 597 | } else { | 598 | } else { |
| 598 | outp += sprintf(outp, "\t%s", mp->name); | 599 | outp += sprintf(outp, "%s%s", delim, mp->name); |
| 599 | } | 600 | } |
| 600 | } | 601 | } |
| 601 | 602 | ||
| @@ -933,7 +934,7 @@ void format_all_counters(struct thread_data *t, struct core_data *c, struct pkg_ | |||
| 933 | static int printed; | 934 | static int printed; |
| 934 | 935 | ||
| 935 | if (!printed || !summary_only) | 936 | if (!printed || !summary_only) |
| 936 | print_header(); | 937 | print_header("\t"); |
| 937 | 938 | ||
| 938 | if (topo.num_cpus > 1) | 939 | if (topo.num_cpus > 1) |
| 939 | format_counters(&average.threads, &average.cores, | 940 | format_counters(&average.threads, &average.cores, |
| @@ -4107,6 +4108,7 @@ void help() | |||
| 4107 | "--quiet skip decoding system configuration header\n" | 4108 | "--quiet skip decoding system configuration header\n" |
| 4108 | "--interval sec Override default 5-second measurement interval\n" | 4109 | "--interval sec Override default 5-second measurement interval\n" |
| 4109 | "--help print this help message\n" | 4110 | "--help print this help message\n" |
| 4111 | "--list list column headers only\n" | ||
| 4110 | "--out file create or truncate \"file\" for all output\n" | 4112 | "--out file create or truncate \"file\" for all output\n" |
| 4111 | "--version print version information\n" | 4113 | "--version print version information\n" |
| 4112 | "\n" | 4114 | "\n" |
| @@ -4814,6 +4816,7 @@ void cmdline(int argc, char **argv) | |||
| 4814 | {"help", no_argument, 0, 'h'}, | 4816 | {"help", no_argument, 0, 'h'}, |
| 4815 | {"hide", required_argument, 0, 'H'}, // meh, -h taken by --help | 4817 | {"hide", required_argument, 0, 'H'}, // meh, -h taken by --help |
| 4816 | {"Joules", no_argument, 0, 'J'}, | 4818 | {"Joules", no_argument, 0, 'J'}, |
| 4819 | {"list", no_argument, 0, 'l'}, | ||
| 4817 | {"out", required_argument, 0, 'o'}, | 4820 | {"out", required_argument, 0, 'o'}, |
| 4818 | {"Package", no_argument, 0, 'p'}, | 4821 | {"Package", no_argument, 0, 'p'}, |
| 4819 | {"processor", no_argument, 0, 'p'}, | 4822 | {"processor", no_argument, 0, 'p'}, |
| @@ -4866,6 +4869,10 @@ void cmdline(int argc, char **argv) | |||
| 4866 | case 'J': | 4869 | case 'J': |
| 4867 | rapl_joules++; | 4870 | rapl_joules++; |
| 4868 | break; | 4871 | break; |
| 4872 | case 'l': | ||
| 4873 | list_header_only++; | ||
| 4874 | quiet++; | ||
| 4875 | break; | ||
| 4869 | case 'o': | 4876 | case 'o': |
| 4870 | outf = fopen_or_die(optarg, "w"); | 4877 | outf = fopen_or_die(optarg, "w"); |
| 4871 | break; | 4878 | break; |
| @@ -4912,6 +4919,13 @@ int main(int argc, char **argv) | |||
| 4912 | if (dump_only) | 4919 | if (dump_only) |
| 4913 | return get_and_dump_counters(); | 4920 | return get_and_dump_counters(); |
| 4914 | 4921 | ||
| 4922 | /* list header and exit */ | ||
| 4923 | if (list_header_only) { | ||
| 4924 | print_header(","); | ||
| 4925 | flush_output_stdout(); | ||
| 4926 | return 0; | ||
| 4927 | } | ||
| 4928 | |||
| 4915 | /* | 4929 | /* |
| 4916 | * if any params left, it must be a command to fork | 4930 | * if any params left, it must be a command to fork |
| 4917 | */ | 4931 | */ |
