Then, use it in other conf parsers.
With this change, now NUMAMask= setting accepts unit specifiers.
{{type}}.CPUSchedulingResetOnFork, config_parse_bool, 0, offsetof({{type}}, exec_context.cpu_sched_reset_on_fork)
{{type}}.CPUAffinity, config_parse_exec_cpu_affinity, 0, offsetof({{type}}, exec_context)
{{type}}.NUMAPolicy, config_parse_numa_policy, 0, offsetof({{type}}, exec_context.numa_policy.type)
-{{type}}.NUMAMask, config_parse_numa_mask, 0, offsetof({{type}}, exec_context.numa_policy)
+{{type}}.NUMAMask, config_parse_numa_mask, 0, offsetof({{type}}, exec_context.numa_policy.nodes)
{{type}}.UMask, config_parse_mode, 0, offsetof({{type}}, exec_context.umask)
{{type}}.Environment, config_parse_environ, 0, offsetof({{type}}, exec_context.environment)
{{type}}.EnvironmentFile, config_parse_unit_env_file, 0, offsetof({{type}}, exec_context.environment_files)
{%- macro CGROUP_CONTEXT_CONFIG_ITEMS(type) -%}
{{type}}.Slice, config_parse_unit_slice, 0, 0
-{{type}}.AllowedCPUs, config_parse_allowed_cpuset, 0, offsetof({{type}}, cgroup_context.cpuset_cpus)
-{{type}}.StartupAllowedCPUs, config_parse_allowed_cpuset, 0, offsetof({{type}}, cgroup_context.startup_cpuset_cpus)
-{{type}}.AllowedMemoryNodes, config_parse_allowed_cpuset, 0, offsetof({{type}}, cgroup_context.cpuset_mems)
-{{type}}.StartupAllowedMemoryNodes, config_parse_allowed_cpuset, 0, offsetof({{type}}, cgroup_context.startup_cpuset_mems)
+{{type}}.AllowedCPUs, config_parse_unit_cpu_set, 0, offsetof({{type}}, cgroup_context.cpuset_cpus)
+{{type}}.StartupAllowedCPUs, config_parse_unit_cpu_set, 0, offsetof({{type}}, cgroup_context.startup_cpuset_cpus)
+{{type}}.AllowedMemoryNodes, config_parse_unit_cpu_set, 0, offsetof({{type}}, cgroup_context.cpuset_mems)
+{{type}}.StartupAllowedMemoryNodes, config_parse_unit_cpu_set, 0, offsetof({{type}}, cgroup_context.startup_cpuset_mems)
{{type}}.CPUAccounting, config_parse_warn_compat, DISABLED_LEGACY, 0
{{type}}.CPUWeight, config_parse_cg_cpu_weight, 0, offsetof({{type}}, cgroup_context.cpu_weight)
{{type}}.StartupCPUWeight, config_parse_cg_cpu_weight, 0, offsetof({{type}}, cgroup_context.startup_cpu_weight)
return 0;
}
-int config_parse_numa_mask(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) {
+int config_parse_numa_mask(
+ 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 *cpu_set = ASSERT_PTR(data);
int r;
- NUMAPolicy *p = ASSERT_PTR(data);
assert(filename);
assert(lvalue);
assert(rvalue);
if (streq(rvalue, "all")) {
- r = numa_mask_add_all(&p->nodes);
+ _cleanup_(cpu_set_done) CPUSet c = {};
+
+ r = numa_mask_add_all(&c);
if (r < 0)
log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to create NUMA mask representing \"all\" NUMA nodes, ignoring: %m");
- } else {
- r = parse_cpu_set_extend(rvalue, &p->nodes, true, unit, filename, line, lvalue);
+
+ cpu_set_done(cpu_set);
+ *cpu_set = TAKE_STRUCT(c);
+ return 0;
+ }
+
+ /* 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 0;
+ return config_parse_unit_cpu_set(unit, filename, line, section, section_line, lvalue, ltype, rvalue, data, userdata);
}
int config_parse_exec_cpu_sched_prio(const char *unit,
void *userdata) {
ExecContext *c = ASSERT_PTR(data);
- const Unit *u = userdata;
- _cleanup_free_ char *k = NULL;
int r;
assert(filename);
if (streq(rvalue, "numa")) {
c->cpu_affinity_from_numa = true;
cpu_set_done(&c->cpu_set);
-
return 0;
}
- r = unit_full_printf(u, rvalue, &k);
- if (r < 0) {
- log_syntax(unit, LOG_WARNING, filename, line, r,
- "Failed to resolve unit specifiers in '%s', ignoring: %m",
- rvalue);
- return 0;
- }
-
- r = parse_cpu_set_extend(k, &c->cpu_set, true, unit, filename, line, lvalue);
- if (r >= 0)
+ r = config_parse_unit_cpu_set(unit, filename, line, section, section_line, lvalue, ltype, rvalue, &c->cpu_set, userdata);
+ if (r > 0)
c->cpu_affinity_from_numa = false;
return 0;
return 0;
}
-int config_parse_allowed_cpuset(
+int config_parse_unit_cpu_set(
const char *unit,
const char *filename,
unsigned line,
return 0;
}
- (void) parse_cpu_set_extend(k, c, true, unit, filename, line, lvalue);
- return 0;
+ r = parse_cpu_set_extend(k, c, true, unit, filename, line, lvalue);
+ if (r < 0)
+ return 0;
+
+ return 1;
}
int config_parse_memory_limit(
CONFIG_PARSER_PROTOTYPE(config_parse_private_pids);
CONFIG_PARSER_PROTOTYPE(config_parse_protect_control_groups);
CONFIG_PARSER_PROTOTYPE(config_parse_cpu_quota);
-CONFIG_PARSER_PROTOTYPE(config_parse_allowed_cpuset);
+CONFIG_PARSER_PROTOTYPE(config_parse_unit_cpu_set);
CONFIG_PARSER_PROTOTYPE(config_parse_protect_home);
CONFIG_PARSER_PROTOTYPE(config_parse_protect_hostname);
CONFIG_PARSER_PROTOTYPE(config_parse_protect_system);
{ "Manager", "StatusUnitFormat", config_parse_status_unit_format, 0, &arg_status_unit_format },
{ "Manager", "CPUAffinity", config_parse_cpu_affinity2, 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 },
+ { "Manager", "NUMAMask", config_parse_numa_mask, 0, &arg_numa_policy.nodes },
{ "Manager", "JoinControllers", config_parse_warn_compat, DISABLED_LEGACY, NULL },
{ "Manager", "RuntimeWatchdogSec", config_parse_watchdog_sec, 0, &arg_runtime_watchdog },
{ "Manager", "RuntimeWatchdogPreSec", config_parse_watchdog_sec, 0, &arg_pretimeout_watchdog },