~ubuntu-branches/ubuntu/wily/idlestat/wily-proposed

« back to all changes in this revision

Viewing changes to .pc/0020-Add-Wunused-parameter-to-CFLAGS.patch/default_report.c

  • Committer: Package Import Robot
  • Author(s): Colin King
  • Date: 2015-05-12 10:14:00 UTC
  • Revision ID: package-import@ubuntu.com-20150512101400-kz3j82evqrclq896
Tags: 0.5-2
* Topology: Fix loop bound
* Energy model: Check for error from idlestat_load correctly
* Energy model: Do not exit() with a negative status code
* Utils: Add missing va_start macros
* Idlestat: Suppress static analysis false positives
* Idlestat: Check return value in cpuidle_get_target_residency
* Idlestat: Fix core/cluster cstates
* Idlestat: Add command line options for managing trace buffer
* Idlestat: P-state calculations for cores and clusters
* Energy_model: Don't add phony frequency to template
* Energy_model: Add cluster P-state calculation based on trace data
* Energy model: Make energy file parsing work for TC2
* Energy model: Take out the wakeup energy from the energy calculation
* Idlestat: Add energy model for arm TC2
* Fix alignment for verbose energy model data
* Fix P-state calculations
* Energy model: Remove unused parameter options
* Remove unused parameter cpu from write_cstate_info
* Simplify event counting while loading a trace
* Add -Wunused-parameter to CFLAGS
* Re-enable compile and run on Android platform
* Utils: Add missing va_end macros to verbose_(f)printf
* Energy_model: calculate number of cap and C states correctly
* Topology: Match cpu names only if they begin with "cpu"
* Make read_cpu_topo_info more robust
* Topology: Remove unused structure member
* Handle offline cpus gracefully
* Fix merge_pstates
* Add idlestat manual page (LP: #1334758)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  default_report.c
 
3
 *
 
4
 *  Copyright (C) 2014, Linaro Limited.
 
5
 *
 
6
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
7
 *  This program is free software; you can redistribute it and/or modify
 
8
 *  it under the terms of the GNU General Public License as published by
 
9
 *  the Free Software Foundation; version 2 of the License.
 
10
 *
 
11
 *  This program is distributed in the hope that it will be useful, but
 
12
 *  WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
 *  General Public License for more details.
 
15
 *
 
16
 *  You should have received a copy of the GNU General Public License along
 
17
 *  with this program; if not, write to the Free Software Foundation, Inc.,
 
18
 *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
 
19
 *
 
20
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
21
 *
 
22
 * Contributors:
 
23
 *     Tuukka Tikkanen <tuukka.tikkanen@linaro.org>
 
24
 *
 
25
 */
 
26
#include <float.h>
 
27
#include <stdbool.h>
 
28
#include <stdio.h>
 
29
#include <string.h>
 
30
#include <unistd.h>
 
31
#include <sys/ioctl.h>
 
32
#include "report_ops.h"
 
33
#include "idlestat.h"
 
34
#include "utils.h"
 
35
 
 
36
 
 
37
static void charrep(char c, int count)
 
38
{
 
39
        int i;
 
40
        for (i = 0; i < count; i++)
 
41
                printf("%c", c);
 
42
}
 
43
 
 
44
static int default_check_output(struct program_options *options, void *report_data)
 
45
{
 
46
        if (check_window_size() && !options->outfilename) {
 
47
                fprintf(stderr, "The terminal must be at least "
 
48
                        "80 columns wide\n");
 
49
                return 1;
 
50
        }
 
51
        return 0;
 
52
}
 
53
 
 
54
static int default_open_report_file(char *path, void *report_data)
 
55
{
 
56
        return redirect_stdout_to_file(path);
 
57
}
 
58
 
 
59
static int default_close_report_file(void *report_data)
 
60
{
 
61
        return (fclose(stdout) == EOF) ? -1 : 0;
 
62
}
 
63
 
 
64
 
 
65
/* Topology headers for all tables (C-state/P-state/Wakeups) */
 
66
 
 
67
static void boxless_cpu_header(const char *cpu, void *report_data)
 
68
{
 
69
        /* No pipe characters and less aggressive indentions */
 
70
        if (strstr(cpu, "cluster"))
 
71
                printf("  %s\n", cpu);
 
72
        else if (strstr(cpu, "core"))
 
73
                printf("    %s\n", cpu);
 
74
        else printf("       %s\n", cpu);
 
75
}
 
76
 
 
77
static void default_cpu_header(const char *cpu, int len)
 
78
{
 
79
        charrep('-', len);
 
80
        printf("\n");
 
81
 
 
82
        if (strstr(cpu, "cluster"))
 
83
                printf("| %-*s |\n", len - 4, cpu);
 
84
        else if (strstr(cpu, "core"))
 
85
                printf("|      %-*s |\n", len - 9, cpu);
 
86
        else printf("|             %-*s |\n", len - 16, cpu);
 
87
 
 
88
        charrep('-', len);
 
89
        printf("\n");
 
90
}
 
91
 
 
92
static void default_end_cpu(void *report_data)
 
93
{
 
94
}
 
95
 
 
96
static void boxless_end_cpu(void *report_data)
 
97
{
 
98
        printf("\n");
 
99
}
 
100
 
 
101
 
 
102
/* C-states */
 
103
 
 
104
static void boxless_cstate_table_header(void *report_data)
 
105
{
 
106
        /* Note: Data is right-aligned, so boxless headers are too */
 
107
        printf("   C-state        min        max        avg      total    hits    over   under\n");
 
108
}
 
109
 
 
110
static void default_cstate_table_header(void *report_data)
 
111
{
 
112
        /* Note: Boxed header columns appear centered */
 
113
        charrep('-', 80);
 
114
        printf("\n| C-state  |   min    |   max    |   avg    |   total  | hits  |  over | under |\n");
 
115
}
 
116
 
 
117
static void default_cstate_cpu_header(const char *cpu, void *report_data)
 
118
{
 
119
        default_cpu_header(cpu, 80);
 
120
}
 
121
 
 
122
static void boxless_cstate_single_state(struct cpuidle_cstate *c, void *report_data)
 
123
{
 
124
        printf("  %8s   ", c->name);
 
125
        display_factored_time(c->min_time == DBL_MAX ? 0. :
 
126
                                      c->min_time, 8);
 
127
        printf("   ");
 
128
        display_factored_time(c->max_time, 8);
 
129
        printf("   ");
 
130
        display_factored_time(c->avg_time, 8);
 
131
        printf("   ");
 
132
        display_factored_time(c->duration, 8);
 
133
        printf("   ");
 
134
        printf("%5d   %5d   %5d\n", c->nrdata, c->early_wakings, c->late_wakings);
 
135
}
 
136
 
 
137
static void default_cstate_single_state(struct cpuidle_cstate *c, void *report_data)
 
138
{
 
139
        printf("| %8s | ", c->name);
 
140
        display_factored_time(c->min_time == DBL_MAX ? 0. :
 
141
                                      c->min_time, 8);
 
142
        printf(" | ");
 
143
        display_factored_time(c->max_time, 8);
 
144
        printf(" | ");
 
145
        display_factored_time(c->avg_time, 8);
 
146
        printf(" | ");
 
147
        display_factored_time(c->duration, 8);
 
148
        printf(" | ");
 
149
        printf("%5d | %5d | %5d |\n", c->nrdata, c->early_wakings, c->late_wakings);
 
150
}
 
151
 
 
152
static void boxless_cstate_table_footer(void *report_data)
 
153
{
 
154
        printf("\n");
 
155
}
 
156
 
 
157
static void default_cstate_table_footer(void *report_data)
 
158
{
 
159
        charrep('-', 80);
 
160
        printf("\n\n");
 
161
}
 
162
 
 
163
 
 
164
/* P-states */
 
165
 
 
166
static void boxless_pstate_table_header(void *report_data)
 
167
{
 
168
        /* Note: Data is right-aligned, so boxless headers are too */
 
169
        printf("   P-state        min        max        avg      total    hits\n");
 
170
}
 
171
 
 
172
static void default_pstate_table_header(void *report_data)
 
173
{
 
174
        charrep('-', 64);
 
175
        printf("\n");
 
176
 
 
177
        /* Note: Boxed header columns appear centered */
 
178
        printf("| P-state  |   min    |   max    |   avg    |   total  | hits  |\n");
 
179
}
 
180
 
 
181
static void default_pstate_cpu_header(const char *cpu, void *report_data)
 
182
{
 
183
        default_cpu_header(cpu, 64);
 
184
}
 
185
 
 
186
static void boxless_pstate_single_freq(struct cpufreq_pstate *p, void *report_data)
 
187
{
 
188
        printf("  ");
 
189
        display_factored_freq(p->freq, 8);
 
190
        printf("   ");
 
191
        display_factored_time(p->min_time == DBL_MAX ? 0. : p->min_time, 8);
 
192
        printf("   ");
 
193
        display_factored_time(p->max_time, 8);
 
194
        printf("   ");
 
195
        display_factored_time(p->avg_time, 8);
 
196
        printf("   ");
 
197
        display_factored_time(p->duration, 8);
 
198
        printf("   %5d\n", p->count);
 
199
}
 
200
 
 
201
static void default_pstate_single_freq(struct cpufreq_pstate *p, void *report_data)
 
202
{
 
203
        printf("| ");
 
204
        display_factored_freq(p->freq, 8);
 
205
        printf(" | ");
 
206
        display_factored_time(p->min_time == DBL_MAX ? 0. : p->min_time, 8);
 
207
        printf(" | ");
 
208
        display_factored_time(p->max_time, 8);
 
209
        printf(" | ");
 
210
        display_factored_time(p->avg_time, 8);
 
211
        printf(" | ");
 
212
        display_factored_time(p->duration, 8);
 
213
        printf(" | %5d |\n", p->count);
 
214
}
 
215
 
 
216
static void boxless_pstate_table_footer(void *report_data)
 
217
{
 
218
        printf("\n");
 
219
}
 
220
 
 
221
static void default_pstate_table_footer(void *report_data)
 
222
{
 
223
        charrep('-', 64);
 
224
        printf("\n\n");
 
225
}
 
226
 
 
227
 
 
228
/* Wakeups */
 
229
 
 
230
static void boxless_wakeup_table_header(void *report_data)
 
231
{
 
232
        /*
 
233
         * Note: Columns 1 and 2 are left-aligned, others are right-aligned.
 
234
         * Boxless headers follow the data convention
 
235
         */
 
236
        printf("  IRQ   Name                Count     early      late\n");
 
237
}
 
238
 
 
239
static void default_wakeup_table_header(void *report_data)
 
240
{
 
241
        charrep('-', 55);
 
242
        printf("\n");
 
243
 
 
244
        /* Note: Boxed header columns appear centered */
 
245
        printf("| IRQ |       Name      |  Count  |  early  |  late   |\n");
 
246
}
 
247
 
 
248
static void default_wakeup_cpu_header(const char *cpu, void *report_data)
 
249
{
 
250
        default_cpu_header(cpu, 55);
 
251
}
 
252
 
 
253
static void boxless_wakeup_single_irq(struct wakeup_irq *irqinfo, void *report_data)
 
254
{
 
255
        if (irqinfo->id != -1) {
 
256
                printf("  %-3d   %-15.15s   %7d   %7d   %7d\n",
 
257
                       irqinfo->id, irqinfo->name, irqinfo->count,
 
258
                       irqinfo->early_triggers, irqinfo->late_triggers);
 
259
        } else {
 
260
                printf("  IPI   %-15.15s   %7d   %7d   %7d\n",
 
261
                       irqinfo->name, irqinfo->count,
 
262
                       irqinfo->early_triggers, irqinfo->late_triggers);
 
263
        }
 
264
}
 
265
 
 
266
static void default_wakeup_single_irq(struct wakeup_irq *irqinfo, void *report_data)
 
267
{
 
268
        if (irqinfo->id != -1) {
 
269
                printf("| %-3d | %-15.15s | %7d | %7d | %7d |\n",
 
270
                       irqinfo->id, irqinfo->name, irqinfo->count,
 
271
                       irqinfo->early_triggers, irqinfo->late_triggers);
 
272
        } else {
 
273
                printf("| IPI | %-15.15s | %7d | %7d | %7d |\n",
 
274
                       irqinfo->name, irqinfo->count,
 
275
                       irqinfo->early_triggers, irqinfo->late_triggers);
 
276
        }
 
277
}
 
278
 
 
279
static void boxless_wakeup_table_footer(void *report_data)
 
280
{
 
281
        printf("\n");
 
282
}
 
283
 
 
284
static void default_wakeup_table_footer(void *report_data)
 
285
{
 
286
        charrep('-', 55);
 
287
        printf("\n\n");
 
288
}
 
289
 
 
290
 
 
291
static struct report_ops default_report_ops = {
 
292
        .name = "default",
 
293
        .check_output = default_check_output, /* Shared */
 
294
 
 
295
        .open_report_file = default_open_report_file, /* Shared */
 
296
        .close_report_file = default_close_report_file, /* Shared */
 
297
 
 
298
        .cstate_table_header = default_cstate_table_header,
 
299
        .cstate_table_footer = default_cstate_table_footer,
 
300
        .cstate_cpu_header = default_cstate_cpu_header,
 
301
        .cstate_single_state = default_cstate_single_state,
 
302
        .cstate_end_cpu = default_end_cpu,
 
303
 
 
304
        .pstate_table_header = default_pstate_table_header,
 
305
        .pstate_table_footer = default_pstate_table_footer,
 
306
        .pstate_cpu_header = default_pstate_cpu_header,
 
307
        .pstate_single_freq = default_pstate_single_freq,
 
308
        .pstate_end_cpu = default_end_cpu,
 
309
 
 
310
        .wakeup_table_header = default_wakeup_table_header,
 
311
        .wakeup_table_footer = default_wakeup_table_footer,
 
312
        .wakeup_cpu_header = default_wakeup_cpu_header,
 
313
        .wakeup_single_irq = default_wakeup_single_irq,
 
314
        .wakeup_end_cpu = default_end_cpu,
 
315
};
 
316
 
 
317
EXPORT_REPORT_OPS(default);
 
318
 
 
319
static struct report_ops boxless_report_ops = {
 
320
        .name = "boxless",
 
321
        .check_output = default_check_output,
 
322
 
 
323
        .open_report_file = default_open_report_file,
 
324
        .close_report_file = default_close_report_file,
 
325
 
 
326
        .cstate_table_header = boxless_cstate_table_header,
 
327
        .cstate_table_footer = boxless_cstate_table_footer,
 
328
        .cstate_cpu_header = boxless_cpu_header,
 
329
        .cstate_single_state = boxless_cstate_single_state,
 
330
        .cstate_end_cpu = boxless_end_cpu,
 
331
 
 
332
        .pstate_table_header = boxless_pstate_table_header,
 
333
        .pstate_table_footer = boxless_pstate_table_footer,
 
334
        .pstate_cpu_header = boxless_cpu_header,
 
335
        .pstate_single_freq = boxless_pstate_single_freq,
 
336
        .pstate_end_cpu = boxless_end_cpu,
 
337
 
 
338
        .wakeup_table_header = boxless_wakeup_table_header,
 
339
        .wakeup_table_footer = boxless_wakeup_table_footer,
 
340
        .wakeup_cpu_header = boxless_cpu_header,
 
341
        .wakeup_single_irq = boxless_wakeup_single_irq,
 
342
        .wakeup_end_cpu = boxless_end_cpu,
 
343
};
 
344
 
 
345
EXPORT_REPORT_OPS(boxless);