/* * 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 #ifdef HAVE_GETOPT_LONG #include #endif #ifdef HAVE_LIBCAP_NG #include #endif #include "irqbalance.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; unsigned int log_mask = TO_ALL; char * log_indent; enum hp_e global_hint_policy = HINT_POLICY_IGNORE; unsigned long power_thresh = ULONG_MAX; unsigned long deepest_cache = 2; unsigned long long cycle_count = 0; char *pidfile = NULL; char *banscript = NULL; char *polscript = NULL; long HZ; 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'}, {"hintpolicy", 1, NULL, 'h'}, {"powerthresh", 1, NULL, 'p'}, {"banirq", 1 , NULL, 'i'}, {"banscript", 1, NULL, 'b'}, {"deepestcache", 1, NULL, 'c'}, {"policyscript", 1, NULL, 'l'}, {"pid", 1, NULL, 's'}, {"journal", 0, NULL, 'j'}, {0, 0, 0, 0} }; static void usage(void) { log(TO_CONSOLE, LOG_INFO, "irqbalance [--oneshot | -o] [--debug | -d] [--foreground | -f] [--journal | -j] [--hintpolicy= | -h [exact|subset|ignore]]\n"); log(TO_CONSOLE, LOG_INFO, " [--powerthresh= | -p | ] [--banirq= | -i ] [--policyscript=