aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2014-01-23 10:13:15 -0500
committerLen Brown <len.brown@intel.com>2014-02-01 15:24:28 -0500
commit3b4d5c7fec0a0b1bbf56d3b8337770fa30f4d1ad (patch)
tree474ee44f8e008c66bf46d3357d9adfaf40f072b9
parentf591c38b917fed99ac9cdfada84c3117ce4e0a1b (diff)
tools/power turbostat: introduce -s to dump counters
The new option allows just run turbostat and get dump of counter values. It's useful when we have something more than one program to test. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
-rw-r--r--tools/power/x86/turbostat/turbostat.c98
1 files changed, 65 insertions, 33 deletions
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index e92c614b8ad4..77eb130168da 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -46,6 +46,7 @@ unsigned int rapl_verbose; /* set with -R */
46unsigned int rapl_joules; /* set with -J */ 46unsigned int rapl_joules; /* set with -J */
47unsigned int thermal_verbose; /* set with -T */ 47unsigned int thermal_verbose; /* set with -T */
48unsigned int summary_only; /* set with -S */ 48unsigned int summary_only; /* set with -S */
49unsigned int dump_only; /* set with -s */
49unsigned int skip_c0; 50unsigned int skip_c0;
50unsigned int skip_c1; 51unsigned int skip_c1;
51unsigned int do_nhm_cstates; 52unsigned int do_nhm_cstates;
@@ -353,51 +354,57 @@ void print_header(void)
353int dump_counters(struct thread_data *t, struct core_data *c, 354int dump_counters(struct thread_data *t, struct core_data *c,
354 struct pkg_data *p) 355 struct pkg_data *p)
355{ 356{
356 fprintf(stderr, "t %p, c %p, p %p\n", t, c, p); 357 outp += sprintf(outp, "t %p, c %p, p %p\n", t, c, p);
357 358
358 if (t) { 359 if (t) {
359 fprintf(stderr, "CPU: %d flags 0x%x\n", t->cpu_id, t->flags); 360 outp += sprintf(outp, "CPU: %d flags 0x%x\n",
360 fprintf(stderr, "TSC: %016llX\n", t->tsc); 361 t->cpu_id, t->flags);
361 fprintf(stderr, "aperf: %016llX\n", t->aperf); 362 outp += sprintf(outp, "TSC: %016llX\n", t->tsc);
362 fprintf(stderr, "mperf: %016llX\n", t->mperf); 363 outp += sprintf(outp, "aperf: %016llX\n", t->aperf);
363 fprintf(stderr, "c1: %016llX\n", t->c1); 364 outp += sprintf(outp, "mperf: %016llX\n", t->mperf);
364 fprintf(stderr, "msr0x%x: %08llX\n", 365 outp += sprintf(outp, "c1: %016llX\n", t->c1);
366 outp += sprintf(outp, "msr0x%x: %08llX\n",
365 extra_delta_offset32, t->extra_delta32); 367 extra_delta_offset32, t->extra_delta32);
366 fprintf(stderr, "msr0x%x: %016llX\n", 368 outp += sprintf(outp, "msr0x%x: %016llX\n",
367 extra_delta_offset64, t->extra_delta64); 369 extra_delta_offset64, t->extra_delta64);
368 fprintf(stderr, "msr0x%x: %08llX\n", 370 outp += sprintf(outp, "msr0x%x: %08llX\n",
369 extra_msr_offset32, t->extra_msr32); 371 extra_msr_offset32, t->extra_msr32);
370 fprintf(stderr, "msr0x%x: %016llX\n", 372 outp += sprintf(outp, "msr0x%x: %016llX\n",
371 extra_msr_offset64, t->extra_msr64); 373 extra_msr_offset64, t->extra_msr64);
372 if (do_smi) 374 if (do_smi)
373 fprintf(stderr, "SMI: %08X\n", t->smi_count); 375 outp += sprintf(outp, "SMI: %08X\n", t->smi_count);
374 } 376 }
375 377
376 if (c) { 378 if (c) {
377 fprintf(stderr, "core: %d\n", c->core_id); 379 outp += sprintf(outp, "core: %d\n", c->core_id);
378 fprintf(stderr, "c3: %016llX\n", c->c3); 380 outp += sprintf(outp, "c3: %016llX\n", c->c3);
379 fprintf(stderr, "c6: %016llX\n", c->c6); 381 outp += sprintf(outp, "c6: %016llX\n", c->c6);
380 fprintf(stderr, "c7: %016llX\n", c->c7); 382 outp += sprintf(outp, "c7: %016llX\n", c->c7);
381 fprintf(stderr, "DTS: %dC\n", c->core_temp_c); 383 outp += sprintf(outp, "DTS: %dC\n", c->core_temp_c);
382 } 384 }
383 385
384 if (p) { 386 if (p) {
385 fprintf(stderr, "package: %d\n", p->package_id); 387 outp += sprintf(outp, "package: %d\n", p->package_id);
386 fprintf(stderr, "pc2: %016llX\n", p->pc2); 388 outp += sprintf(outp, "pc2: %016llX\n", p->pc2);
387 fprintf(stderr, "pc3: %016llX\n", p->pc3); 389 outp += sprintf(outp, "pc3: %016llX\n", p->pc3);
388 fprintf(stderr, "pc6: %016llX\n", p->pc6); 390 outp += sprintf(outp, "pc6: %016llX\n", p->pc6);
389 fprintf(stderr, "pc7: %016llX\n", p->pc7); 391 outp += sprintf(outp, "pc7: %016llX\n", p->pc7);
390 fprintf(stderr, "pc8: %016llX\n", p->pc8); 392 outp += sprintf(outp, "pc8: %016llX\n", p->pc8);
391 fprintf(stderr, "pc9: %016llX\n", p->pc9); 393 outp += sprintf(outp, "pc9: %016llX\n", p->pc9);
392 fprintf(stderr, "pc10: %016llX\n", p->pc10); 394 outp += sprintf(outp, "pc10: %016llX\n", p->pc10);
393 fprintf(stderr, "Joules PKG: %0X\n", p->energy_pkg); 395 outp += sprintf(outp, "Joules PKG: %0X\n", p->energy_pkg);
394 fprintf(stderr, "Joules COR: %0X\n", p->energy_cores); 396 outp += sprintf(outp, "Joules COR: %0X\n", p->energy_cores);
395 fprintf(stderr, "Joules GFX: %0X\n", p->energy_gfx); 397 outp += sprintf(outp, "Joules GFX: %0X\n", p->energy_gfx);
396 fprintf(stderr, "Joules RAM: %0X\n", p->energy_dram); 398 outp += sprintf(outp, "Joules RAM: %0X\n", p->energy_dram);
397 fprintf(stderr, "Throttle PKG: %0X\n", p->rapl_pkg_perf_status); 399 outp += sprintf(outp, "Throttle PKG: %0X\n",
398 fprintf(stderr, "Throttle RAM: %0X\n", p->rapl_dram_perf_status); 400 p->rapl_pkg_perf_status);
399 fprintf(stderr, "PTM: %dC\n", p->pkg_temp_c); 401 outp += sprintf(outp, "Throttle RAM: %0X\n",
402 p->rapl_dram_perf_status);
403 outp += sprintf(outp, "PTM: %dC\n", p->pkg_temp_c);
400 } 404 }
405
406 outp += sprintf(outp, "\n");
407
401 return 0; 408 return 0;
402} 409}
403 410
@@ -2289,7 +2296,7 @@ int initialize_counters(int cpu_id)
2289 2296
2290void allocate_output_buffer() 2297void allocate_output_buffer()
2291{ 2298{
2292 output_buffer = calloc(1, (1 + topo.num_cpus) * 256); 2299 output_buffer = calloc(1, (1 + topo.num_cpus) * 1024);
2293 outp = output_buffer; 2300 outp = output_buffer;
2294 if (outp == NULL) 2301 if (outp == NULL)
2295 err(-1, "calloc output buffer"); 2302 err(-1, "calloc output buffer");
@@ -2303,6 +2310,7 @@ void setup_all_buffers(void)
2303 allocate_output_buffer(); 2310 allocate_output_buffer();
2304 for_all_proc_cpus(initialize_counters); 2311 for_all_proc_cpus(initialize_counters);
2305} 2312}
2313
2306void turbostat_init() 2314void turbostat_init()
2307{ 2315{
2308 check_cpuid(); 2316 check_cpuid();
@@ -2371,13 +2379,30 @@ int fork_it(char **argv)
2371 return status; 2379 return status;
2372} 2380}
2373 2381
2382int get_and_dump_counters(void)
2383{
2384 int status;
2385
2386 status = for_all_cpus(get_counters, ODD_COUNTERS);
2387 if (status)
2388 return status;
2389
2390 status = for_all_cpus(dump_counters, ODD_COUNTERS);
2391 if (status)
2392 return status;
2393
2394 flush_stdout();
2395
2396 return status;
2397}
2398
2374void cmdline(int argc, char **argv) 2399void cmdline(int argc, char **argv)
2375{ 2400{
2376 int opt; 2401 int opt;
2377 2402
2378 progname = argv[0]; 2403 progname = argv[0];
2379 2404
2380 while ((opt = getopt(argc, argv, "+pPSvi:c:C:m:M:RJT:")) != -1) { 2405 while ((opt = getopt(argc, argv, "+pPsSvi:c:C:m:M:RJT:")) != -1) {
2381 switch (opt) { 2406 switch (opt) {
2382 case 'p': 2407 case 'p':
2383 show_core_only++; 2408 show_core_only++;
@@ -2385,6 +2410,9 @@ void cmdline(int argc, char **argv)
2385 case 'P': 2410 case 'P':
2386 show_pkg_only++; 2411 show_pkg_only++;
2387 break; 2412 break;
2413 case 's':
2414 dump_only++;
2415 break;
2388 case 'S': 2416 case 'S':
2389 summary_only++; 2417 summary_only++;
2390 break; 2418 break;
@@ -2432,6 +2460,10 @@ int main(int argc, char **argv)
2432 2460
2433 turbostat_init(); 2461 turbostat_init();
2434 2462
2463 /* dump counters and exit */
2464 if (dump_only)
2465 return get_and_dump_counters();
2466
2435 /* 2467 /*
2436 * if any params left, it must be a command to fork 2468 * if any params left, it must be a command to fork
2437 */ 2469 */