~ubuntu-branches/ubuntu/vivid/irqbalance/vivid-proposed

« back to all changes in this revision

Viewing changes to irqbalance.c

  • Committer: Package Import Robot
  • Author(s): Anibal Monsalve Salazar
  • Date: 2012-11-12 14:30:07 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20121112143007-431eb30o2vpm7v2v
* New upstream release 1.0.5
  - consolidate logging
  - Implement user policy script callout
  - Replace fscanf(%as) by getline
  - manpage: Improve the readability of the --banirq text
  - glib-local: ad call for g_list_remove
* Adjust irqbalance stop runlevel arguments
  Closes: #663725
* Ship upstream irqbalance.1
* Update debian/watch

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
int foreground_mode;
48
48
int numa_avail;
49
49
int need_rescan;
 
50
unsigned int log_mask = TO_SYSLOG;
50
51
extern cpumask_t banned_cpus;
51
52
enum hp_e hint_policy = HINT_POLICY_SUBSET;
52
53
unsigned long power_thresh = ULONG_MAX;
53
54
unsigned long long cycle_count = 0;
54
55
char *pidfile = NULL;
55
56
char *banscript = NULL;
 
57
char *polscript = NULL;
56
58
 
57
59
void sleep_approx(int seconds)
58
60
{
77
79
        {"powerthresh", 1, NULL, 'p'},
78
80
        {"banirq", 1 , NULL, 'i'},
79
81
        {"banscript", 1, NULL, 'b'},
 
82
        {"policyscript", 1, NULL, 'l'},
80
83
        {"pid", 1, NULL, 's'},
81
84
        {0, 0, 0, 0}
82
85
};
84
87
static void usage(void)
85
88
{
86
89
        printf("irqbalance [--oneshot | -o] [--debug | -d] [--foreground | -f] [--hintpolicy= | -h [exact|subset|ignore]]\n");
87
 
        printf("        [--powerthresh= | -p <off> | <n>] [--banirq= | -i <n>]\n");
 
90
        printf("        [--powerthresh= | -p <off> | <n>] [--banirq= | -i <n>] [--policyscript=<script>]\n");
88
91
}
89
92
 
90
93
static void parse_command_line(int argc, char **argv)
94
97
        unsigned long val;
95
98
 
96
99
        while ((opt = getopt_long(argc, argv,
97
 
                "odfh:i:p:s:b:",
 
100
                "odfh:i:p:s:b:l:",
98
101
                lopts, &longind)) != -1) {
99
102
 
100
103
                switch(opt) {
132
135
                                }
133
136
                                add_banned_irq((int)val);
134
137
                                break;
 
138
                        case 'l':
 
139
                                polscript = strdup(optarg);
 
140
                                break;
135
141
                        case 'p':
136
142
                                if (!strncmp(optarg, "off", strlen(optarg)))
137
143
                                        power_thresh = ULONG_MAX;
242
248
        if (getenv("IRQBALANCE_DEBUG")) 
243
249
                debug_mode=1;
244
250
 
 
251
        if (debug_mode)
 
252
                log_mask |= TO_CONSOLE;
 
253
 
245
254
        if (numa_available() > -1) {
246
255
                numa_avail = 1;
247
 
        } else {
248
 
                if (debug_mode)
249
 
                        printf("This machine seems not NUMA capable.\n");
 
256
        } else 
 
257
                log(TO_CONSOLE, LOG_INFO, "This machine seems not NUMA capable.\n");
 
258
 
 
259
        if (banscript) {
 
260
                char *note = "Please note that --banscript is deprecated, please use --policyscript instead";
 
261
                log(TO_ALL, LOG_WARNING, "%s\n", note);
250
262
        }
251
263
 
252
264
        action.sa_handler = handler;
264
276
                char *msg = "Balaincing is ineffective on systems with a "
265
277
                            "single cache domain.  Shutting down\n";
266
278
 
267
 
                if (debug_mode)
268
 
                        printf("%s", msg);
269
 
                else
270
 
                        syslog(LOG_INFO, "%s", msg);
 
279
                log(TO_ALL, LOG_WARNING, "%s", msg);
271
280
                exit(EXIT_SUCCESS);
272
281
        }
273
282
        /* On dual core/hyperthreading shared cache systems just do a one shot setup */
309
318
 
310
319
        while (keep_going) {
311
320
                sleep_approx(SLEEP_INTERVAL);
312
 
                if (debug_mode)
313
 
                        printf("\n\n\n-----------------------------------------------------------------------------\n");
 
321
                log(TO_CONSOLE, LOG_INFO, "\n\n\n-----------------------------------------------------------------------------\n");
314
322
 
315
323
 
316
324
                clear_work_stats();
322
330
                        need_rescan = 0;
323
331
                        /* if there's a hotplug event we better turn off power mode for a bit until things settle */
324
332
                        power_mode = 0;
325
 
                        if (debug_mode)
326
 
                                printf("Rescanning cpu topology \n");
 
333
                        log(TO_CONSOLE, LOG_INFO, "Rescanning cpu topology \n");
327
334
                        reset_counts();
328
335
                        clear_work_stats();
329
336