turbostat.c (3d109de23c93e9196c370fd729fbd7ecf7371701) turbostat.c (01a67adfc5d73d24e999d9cf65b5b8a6687187b8)
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

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

1613 fprintf(outf, "%svalid, %lld ns)\n", msr & (1 << 15) ? "" : "NOT",
1614 (msr & 0x3FF) * irtl_time_units[(msr >> 10) & 0x3]);
1615
1616}
1617void free_fd_percpu(void)
1618{
1619 int i;
1620
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

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

1613 fprintf(outf, "%svalid, %lld ns)\n", msr & (1 << 15) ? "" : "NOT",
1614 (msr & 0x3FF) * irtl_time_units[(msr >> 10) & 0x3]);
1615
1616}
1617void free_fd_percpu(void)
1618{
1619 int i;
1620
1621 for (i = 0; i < topo.max_cpu_num; ++i) {
1621 for (i = 0; i < topo.max_cpu_num + 1; ++i) {
1622 if (fd_percpu[i] != 0)
1623 close(fd_percpu[i]);
1624 }
1625
1626 free(fd_percpu);
1627}
1628
1629void free_all_buffers(void)

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

3579{
3580 output_buffer = calloc(1, (1 + topo.num_cpus) * 1024);
3581 outp = output_buffer;
3582 if (outp == NULL)
3583 err(-1, "calloc output buffer");
3584}
3585void allocate_fd_percpu(void)
3586{
1622 if (fd_percpu[i] != 0)
1623 close(fd_percpu[i]);
1624 }
1625
1626 free(fd_percpu);
1627}
1628
1629void free_all_buffers(void)

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

3579{
3580 output_buffer = calloc(1, (1 + topo.num_cpus) * 1024);
3581 outp = output_buffer;
3582 if (outp == NULL)
3583 err(-1, "calloc output buffer");
3584}
3585void allocate_fd_percpu(void)
3586{
3587 fd_percpu = calloc(topo.max_cpu_num, sizeof(int));
3587 fd_percpu = calloc(topo.max_cpu_num + 1, sizeof(int));
3588 if (fd_percpu == NULL)
3589 err(-1, "calloc fd_percpu");
3590}
3591void allocate_irq_buffers(void)
3592{
3593 irq_column_2_cpu = calloc(topo.num_cpus, sizeof(int));
3594 if (irq_column_2_cpu == NULL)
3595 err(-1, "calloc %d", topo.num_cpus);
3596
3588 if (fd_percpu == NULL)
3589 err(-1, "calloc fd_percpu");
3590}
3591void allocate_irq_buffers(void)
3592{
3593 irq_column_2_cpu = calloc(topo.num_cpus, sizeof(int));
3594 if (irq_column_2_cpu == NULL)
3595 err(-1, "calloc %d", topo.num_cpus);
3596
3597 irqs_per_cpu = calloc(topo.max_cpu_num, sizeof(int));
3597 irqs_per_cpu = calloc(topo.max_cpu_num + 1, sizeof(int));
3598 if (irqs_per_cpu == NULL)
3598 if (irqs_per_cpu == NULL)
3599 err(-1, "calloc %d", topo.max_cpu_num);
3599 err(-1, "calloc %d", topo.max_cpu_num + 1);
3600}
3601void setup_all_buffers(void)
3602{
3603 topology_probe();
3604 allocate_irq_buffers();
3605 allocate_fd_percpu();
3606 allocate_counters(&thread_even, &core_even, &package_even);
3607 allocate_counters(&thread_odd, &core_odd, &package_odd);

--- 229 unchanged lines hidden ---
3600}
3601void setup_all_buffers(void)
3602{
3603 topology_probe();
3604 allocate_irq_buffers();
3605 allocate_fd_percpu();
3606 allocate_counters(&thread_even, &core_even, &package_even);
3607 allocate_counters(&thread_odd, &core_odd, &package_odd);

--- 229 unchanged lines hidden ---