/* * Copyright (C) 2006, Intel Corporation * Copyright (C) 2012, Neil Horman * * This file is part of irqbalance * * This program file is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; version 2 of the License. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License * along with this program in a file named COPYING; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA */ #include "config.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_GETOPT_LONG #include #endif #ifdef HAVE_LIBCAP_NG #include #endif #ifdef HAVE_IRQBALANCEUI #include #include #endif #include "irqbalance.h" #include "thermal.h" volatile int keep_going = 1; int one_shot_mode; int debug_mode; int foreground_mode; int numa_avail; int journal_logging = 0; int need_rescan; int need_rebuild; unsigned int log_mask = TO_ALL; const char *log_indent; unsigned long power_thresh = ULONG_MAX; unsigned long deepest_cache = 2; unsigned long long cycle_count = 0; char *pidfile = NULL; char *polscript = NULL; long HZ; int sleep_interval = SLEEP_INTERVAL; int last_interval; GMainLoop *main_loop; char *cpu_ban_string = NULL; unsigned long migrate_ratio = 0; #ifdef HAVE_IRQBALANCEUI int socket_fd; char socket_name[64]; char *banned_cpumask_from_ui = NULL; #endif static void sleep_approx(int seconds) { struct timespec ts; struct timeval tv; gettimeofday(&tv, NULL); ts.tv_sec = seconds; ts.tv_nsec = -tv.tv_usec*1000; while (ts.tv_nsec < 0) { ts.tv_sec--; ts.tv_nsec += 1000000000; } nanosleep(&ts, NULL); } #ifdef HAVE_GETOPT_LONG struct option lopts[] = { {"oneshot", 0, NULL, 'o'}, {"debug", 0, NULL, 'd'}, {"foreground", 0, NULL, 'f'}, {"powerthresh", 1, NULL, 'p'}, {"banirq", 1 , NULL, 'i'}, {"deepestcache", 1, NULL, 'c'}, {"policyscript", 1, NULL, 'l'}, {"pid", 1, NULL, 's'}, {"journal", 0, NULL, 'j'}, {"banmod", 1 , NULL, 'm'}, {"interval", 1 , NULL, 't'}, {"version", 0, NULL, 'V'}, {"migrateval", 1, NULL, 'e'}, {0, 0, 0, 0} }; static void usage(void) { log(TO_CONSOLE, LOG_INFO, "irqbalance [--oneshot | -o] [--debug | -d] [--foreground | -f] [--journal | -j]\n"); log(TO_CONSOLE, LOG_INFO, " [--powerthresh= | -p | ] [--banirq= | -i ] [--banmod= | -m ] [--policyscript= | -l