cpu-set-util: introduce config_parse_cpu_set()
Then, make parse_cpu_set() as a tiny wrapper of it. Note, previously when an invalid CPU range, e.g. "3-0", is specified, we ignore the range but allocate an empty set. But, with this commit, now the conf parser simply ignore it without no side effect. This potentially changes behavior of a system with such invalid setting, but the change should be favorable for consistency with other parsers.
This commit is contained in:
@@ -1572,15 +1572,9 @@ int config_parse_numa_mask(
|
||||
}
|
||||
|
||||
/* When parsing system.conf or user.conf, rather than unit files, userdata is NULL. */
|
||||
if (!userdata) {
|
||||
r = parse_cpu_set_extend(rvalue, cpu_set, true, unit, filename, line, lvalue);
|
||||
if (r < 0)
|
||||
log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse NUMA node mask, ignoring: %s", rvalue);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return config_parse_unit_cpu_set(unit, filename, line, section, section_line, lvalue, ltype, rvalue, data, userdata);
|
||||
return userdata ?
|
||||
config_parse_unit_cpu_set(unit, filename, line, section, section_line, lvalue, ltype, rvalue, data, userdata) :
|
||||
config_parse_cpu_set(unit, filename, line, section, section_line, lvalue, ltype, rvalue, data, userdata);
|
||||
}
|
||||
|
||||
int config_parse_exec_cpu_sched_prio(const char *unit,
|
||||
@@ -3783,8 +3777,7 @@ int config_parse_unit_cpu_set(
|
||||
void *data,
|
||||
void *userdata) {
|
||||
|
||||
CPUSet *c = data;
|
||||
const Unit *u = userdata;
|
||||
const Unit *u = ASSERT_PTR(userdata);
|
||||
_cleanup_free_ char *k = NULL;
|
||||
int r;
|
||||
|
||||
@@ -3800,11 +3793,7 @@ int config_parse_unit_cpu_set(
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = parse_cpu_set_extend(k, c, true, unit, filename, line, lvalue);
|
||||
if (r < 0)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
return config_parse_cpu_set(unit, filename, line, section, section_line, lvalue, ltype, k, data, userdata);
|
||||
}
|
||||
|
||||
int config_parse_memory_limit(
|
||||
@@ -6274,25 +6263,6 @@ void unit_dump_config_items(FILE *f) {
|
||||
}
|
||||
}
|
||||
|
||||
int config_parse_cpu_affinity2(
|
||||
const char *unit,
|
||||
const char *filename,
|
||||
unsigned line,
|
||||
const char *section,
|
||||
unsigned section_line,
|
||||
const char *lvalue,
|
||||
int ltype,
|
||||
const char *rvalue,
|
||||
void *data,
|
||||
void *userdata) {
|
||||
|
||||
CPUSet *affinity = ASSERT_PTR(data);
|
||||
|
||||
(void) parse_cpu_set_extend(rvalue, affinity, true, unit, filename, line, lvalue);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int config_parse_show_status(
|
||||
const char* unit,
|
||||
const char *filename,
|
||||
|
||||
@@ -140,7 +140,6 @@ CONFIG_PARSER_PROTOTYPE(config_parse_oom_policy);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_numa_policy);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_numa_mask);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_ip_filter_bpf_progs);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_cpu_affinity2);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_show_status);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_status_unit_format);
|
||||
CONFIG_PARSER_PROTOTYPE(config_parse_output_restricted);
|
||||
|
||||
+1
-1
@@ -741,7 +741,7 @@ static int parse_config_file(void) {
|
||||
{ "Manager", "CrashAction", config_parse_crash_action, 0, &arg_crash_action },
|
||||
{ "Manager", "ShowStatus", config_parse_show_status, 0, &arg_show_status },
|
||||
{ "Manager", "StatusUnitFormat", config_parse_status_unit_format, 0, &arg_status_unit_format },
|
||||
{ "Manager", "CPUAffinity", config_parse_cpu_affinity2, 0, &arg_cpu_affinity },
|
||||
{ "Manager", "CPUAffinity", config_parse_cpu_set, 0, &arg_cpu_affinity },
|
||||
{ "Manager", "NUMAPolicy", config_parse_numa_policy, 0, &arg_numa_policy.type },
|
||||
{ "Manager", "NUMAMask", config_parse_numa_mask, 0, &arg_numa_policy.nodes },
|
||||
{ "Manager", "JoinControllers", config_parse_warn_compat, DISABLED_LEGACY, NULL },
|
||||
|
||||
Reference in New Issue
Block a user