diff --git a/config.h b/config.h index abde0bc3e..736a30920 100644 --- a/config.h +++ b/config.h @@ -18,10 +18,7 @@ #endif /** The version number of VILLASnode */ -#define VERSION "v0.5-" _GIT_REV - -#define DEFAULT_PRIORITY 80 -#define DEFAULT_AFFINITY -1 +#define VERSION "v0.6-" _GIT_REV /** Default number of values in a sample */ #define DEFAULT_VALUES 64 @@ -54,18 +51,7 @@ #define BENCH_WARMUP 100 #define BENCH_DM_EXP_MIN 0 #define BENCH_DM_EXP_MAX 20 - -/** Coefficients for simple FIR-LowPass: - * F_s = 1kHz, F_pass = 100 Hz, F_block = 300 - * - * Tip: Use MATLAB's filter design tool and export coefficients - * with the integrated C-Header export - */ -#define HOOK_FIR_COEFFS { -0.003658148158728, -0.008882653268281, 0.008001024183003, \ - 0.08090485991761, 0.2035239551043, 0.3040703593515, \ - 0.3040703593515, 0.2035239551043, 0.08090485991761, \ - 0.008001024183003, -0.008882653268281,-0.003658148158728 } - + /** Global configuration */ struct settings { int priority; /**< Process priority (lower is better) */ diff --git a/lib/cfg.c b/lib/cfg.c index ec3715441..8376a5c85 100644 --- a/lib/cfg.c +++ b/lib/cfg.c @@ -79,38 +79,46 @@ int config_parse(const char *filename, config_t *cfg, struct settings *set, return 0; } +int config_parse_plugins(config_setting_t *cfg) +{ + if (!config_setting_is_array(cfg)) + cerror(cfg, "Setting 'plugins' must be a list of strings"); + + for (int i = 0; i < config_setting_length(cfg); i++) { + void *handle; + const char *path; + + path = config_setting_get_string_elem(cfg, i); + if (!path) + cerror(cfg, "Setting 'plugins' must be a list of strings"); + + handle = dlopen(path, RTLD_NOW); + if (!handle) + error("Failed to load plugin %s", dlerror()); + } + + return 0; +} + int config_parse_global(config_setting_t *cfg, struct settings *set) { config_setting_t *cfg_plugins; if (!config_setting_lookup_int(cfg, "affinity", &set->affinity)) - set->affinity = DEFAULT_AFFINITY; + set->affinity = 0; if (!config_setting_lookup_int(cfg, "priority", &set->priority)) - set->priority = DEFAULT_PRIORITY; + set->priority = 0; - config_setting_lookup_int(cfg, "debug", &set->debug); - config_setting_lookup_float(cfg, "stats", &set->stats); + if (!config_setting_lookup_int(cfg, "debug", &set->debug)) + set->debug = V; + + if (!config_setting_lookup_float(cfg, "stats", &set->stats)) + set->stats = 0; - /* Load plugins */ cfg_plugins = config_setting_get_member(cfg, "plugins"); - if (cfg) { - if (!config_setting_is_array(cfg_plugins)) - cerror(cfg_plugins, "Setting 'plugings' must be a list of strings"); - - for (int i = 0; i < config_setting_length(cfg_plugins); i++) { - void *handle; - const char *path; - - path = config_setting_get_string_elem(cfg_plugins, i); - if (!path) - cerror(cfg_plugins, "Setting 'plugings' must be a list of strings"); - - handle = dlopen(path, RTLD_NOW); - if (!handle) - error("Failed to load plugin %s", dlerror()); - } - } + if (cfg_plugins) + config_parse_plugins(cfg_plugins); log_setlevel(set->debug, -1); diff --git a/lib/fpga/intc.c b/lib/fpga/intc.c index bab5304ac..853e7175c 100644 --- a/lib/fpga/intc.c +++ b/lib/fpga/intc.c @@ -39,7 +39,7 @@ int intc_init(struct ip *c) /* For each IRQ */ for (int i = 0; i < intc->num_irqs; i++) { /* Pin to core */ - ret = kernel_irq_setaffinity(intc->nos[i], DEFAULT_AFFINITY, NULL); + ret = kernel_irq_setaffinity(intc->nos[i], f->affinity, NULL); if (ret) serror("Failed to change affinity of VFIO-MSI interrupt"); diff --git a/lib/kernel/rt.c b/lib/kernel/rt.c index 1343d36b7..4c0607b24 100644 --- a/lib/kernel/rt.c +++ b/lib/kernel/rt.c @@ -26,45 +26,53 @@ int rt_init(int affinity, int priority) .sched_priority = priority }; - if (sched_setscheduler(0, SCHED_FIFO, ¶m)) - serror("Failed to set real time priority"); - - debug(3, "Task priority set to %u", priority); - - /* Pin threads to CPUs by setting the affinity */ - cpu_set_t cset_pin, cset_isol, cset_non_isol; - - is_isol = kernel_get_cmdline_param("isolcpus", isolcpus, sizeof(isolcpus)); - if (is_isol) { - warn("You should reserve some cores for the server (see 'isolcpus')"); - - CPU_ZERO(&cset_isol); - } - else { - ret = cpulist_parse(isolcpus, &cset_isol, 0); + if (priority) { + ret = sched_setscheduler(0, SCHED_FIFO, ¶m); if (ret) - error("Invalid isolcpus cmdline parameter: %s", isolcpus); + serror("Failed to set real time priority"); + + debug(3, "Task priority set to %u", priority); } - cpuset_from_integer(affinity, &cset_pin); + if (affinity) { + /* Pin threads to CPUs by setting the affinity */ + cpu_set_t cset_pin, cset_isol, cset_non_isol; - CPU_XOR(&cset_non_isol, &cset_isol, &cset_pin); - if (CPU_COUNT(&cset_non_isol) > 0) { - char isol[128], pin[128]; + is_isol = kernel_get_cmdline_param("isolcpus", isolcpus, sizeof(isolcpus)); + if (is_isol) { + warn("You should reserve some cores for the server (see 'isolcpus')"); + + CPU_ZERO(&cset_isol); + } + else { + ret = cpulist_parse(isolcpus, &cset_isol, 0); + if (ret) + error("Invalid isolcpus cmdline parameter: %s", isolcpus); + } + + cpuset_from_integer(affinity, &cset_pin); + + CPU_XOR(&cset_non_isol, &cset_isol, &cset_pin); + if (CPU_COUNT(&cset_non_isol) > 0) { + char isol[128], pin[128]; - cpulist_create(isol, sizeof(isol), &cset_isol); - cpulist_create(pin, sizeof(pin), &cset_pin); + cpulist_create(isol, sizeof(isol), &cset_isol); + cpulist_create(pin, sizeof(pin), &cset_pin); - warn("Affinity setting includes cores which are not isolated: affinity=%s isolcpus=%s", pin, isol); + warn("Affinity setting includes cores which are not isolated: affinity=%s isolcpus=%s", pin, isol); + } + + char list[128]; + cpulist_create(list, sizeof(list), &cset_pin); + + ret = sched_setaffinity(0, sizeof(cpu_set_t), &cset_pin); + if (ret) + serror("Failed to set CPU affinity to %s", list); + + debug(3, "Set affinity to %s", list); } - - char list[128]; - cpulist_create(list, sizeof(list), &cset_pin); - - if (sched_setaffinity(0, sizeof(cpu_set_t), &cset_pin)) - serror("Failed to set CPU affinity to %s", list); - - debug(3, "Set affinity to %s", list); + else + warn("You should use the 'affinity' setting to pin VILLASnode to dedicate CPU cores"); return 0; } \ No newline at end of file