turbostat.c (023fe0ac975e4dff592ce90bbd12747dedf7c598) turbostat.c (843c57916dde0e260e500e4ae1a443a7d7fbe962)
1/*
2 * turbostat -- show CPU frequency and C-state residency
3 * on modern Intel turbo-capable processors.
4 *
5 * Copyright (c) 2013 Intel Corporation.
6 * Len Brown <len.brown@intel.com>
7 *
8 * This program is free software; you can redistribute it and/or modify it

--- 2482 unchanged lines hidden (view full) ---

2491
2492void re_initialize(void)
2493{
2494 free_all_buffers();
2495 setup_all_buffers();
2496 printf("turbostat: re-initialized with num_cpus %d\n", topo.num_cpus);
2497}
2498
1/*
2 * turbostat -- show CPU frequency and C-state residency
3 * on modern Intel turbo-capable processors.
4 *
5 * Copyright (c) 2013 Intel Corporation.
6 * Len Brown <len.brown@intel.com>
7 *
8 * This program is free software; you can redistribute it and/or modify it

--- 2482 unchanged lines hidden (view full) ---

2491
2492void re_initialize(void)
2493{
2494 free_all_buffers();
2495 setup_all_buffers();
2496 printf("turbostat: re-initialized with num_cpus %d\n", topo.num_cpus);
2497}
2498
2499void set_max_cpu_num(void)
2500{
2501 FILE *filep;
2502 unsigned long dummy;
2499
2503
2504 topo.max_cpu_num = 0;
2505 filep = fopen_or_die(
2506 "/sys/devices/system/cpu/cpu0/topology/thread_siblings",
2507 "r");
2508 while (fscanf(filep, "%lx,", &dummy) == 1)
2509 topo.max_cpu_num += 32;
2510 fclose(filep);
2511 topo.max_cpu_num--; /* 0 based */
2512}
2513
2500/*
2501 * count_cpus()
2502 * remember the last one seen, it will be the max
2503 */
2504int count_cpus(int cpu)
2505{
2514/*
2515 * count_cpus()
2516 * remember the last one seen, it will be the max
2517 */
2518int count_cpus(int cpu)
2519{
2506 if (topo.max_cpu_num < cpu)
2507 topo.max_cpu_num = cpu;
2508
2509 topo.num_cpus += 1;
2520 topo.num_cpus++;
2510 return 0;
2511}
2512int mark_cpu_present(int cpu)
2513{
2514 CPU_SET_S(cpu, cpu_present_setsize, cpu_present_set);
2515 return 0;
2516}
2517

--- 2041 unchanged lines hidden (view full) ---

4559 int max_package_id = 0;
4560 int max_siblings = 0;
4561 struct cpu_topology {
4562 int core_id;
4563 int physical_package_id;
4564 } *cpus;
4565
4566 /* Initialize num_cpus, max_cpu_num */
2521 return 0;
2522}
2523int mark_cpu_present(int cpu)
2524{
2525 CPU_SET_S(cpu, cpu_present_setsize, cpu_present_set);
2526 return 0;
2527}
2528

--- 2041 unchanged lines hidden (view full) ---

4570 int max_package_id = 0;
4571 int max_siblings = 0;
4572 struct cpu_topology {
4573 int core_id;
4574 int physical_package_id;
4575 } *cpus;
4576
4577 /* Initialize num_cpus, max_cpu_num */
4578 set_max_cpu_num();
4567 topo.num_cpus = 0;
4579 topo.num_cpus = 0;
4568 topo.max_cpu_num = 0;
4569 for_all_proc_cpus(count_cpus);
4570 if (!summary_only && topo.num_cpus > 1)
4571 BIC_PRESENT(BIC_CPU);
4572
4573 if (debug > 1)
4574 fprintf(outf, "num_cpus %d max_cpu_num %d\n", topo.num_cpus, topo.max_cpu_num);
4575
4576 cpus = calloc(1, (topo.max_cpu_num + 1) * sizeof(struct cpu_topology));

--- 791 unchanged lines hidden ---
4580 for_all_proc_cpus(count_cpus);
4581 if (!summary_only && topo.num_cpus > 1)
4582 BIC_PRESENT(BIC_CPU);
4583
4584 if (debug > 1)
4585 fprintf(outf, "num_cpus %d max_cpu_num %d\n", topo.num_cpus, topo.max_cpu_num);
4586
4587 cpus = calloc(1, (topo.max_cpu_num + 1) * sizeof(struct cpu_topology));

--- 791 unchanged lines hidden ---