cpu-set-util: rename cpu_set_reset() -> cpu_set_done()
This also introduces cpu_set_done_and_replace(). No functional change, just refactoring.
This commit is contained in:
+4
-4
@@ -267,10 +267,10 @@ void cgroup_context_done(CGroupContext *c) {
|
||||
|
||||
c->restrict_network_interfaces = set_free(c->restrict_network_interfaces);
|
||||
|
||||
cpu_set_reset(&c->cpuset_cpus);
|
||||
cpu_set_reset(&c->startup_cpuset_cpus);
|
||||
cpu_set_reset(&c->cpuset_mems);
|
||||
cpu_set_reset(&c->startup_cpuset_mems);
|
||||
cpu_set_done(&c->cpuset_cpus);
|
||||
cpu_set_done(&c->startup_cpuset_cpus);
|
||||
cpu_set_done(&c->cpuset_mems);
|
||||
cpu_set_done(&c->startup_cpuset_mems);
|
||||
|
||||
c->delegate_subgroup = mfree(c->delegate_subgroup);
|
||||
|
||||
|
||||
@@ -1241,7 +1241,7 @@ int bus_cgroup_set_property(
|
||||
} else if (STR_IN_SET(name, "AllowedCPUs", "StartupAllowedCPUs", "AllowedMemoryNodes", "StartupAllowedMemoryNodes")) {
|
||||
const void *a;
|
||||
size_t n;
|
||||
_cleanup_(cpu_set_reset) CPUSet new_set = {};
|
||||
_cleanup_(cpu_set_done) CPUSet new_set = {};
|
||||
|
||||
r = sd_bus_message_read_array(message, 'y', &a, &n);
|
||||
if (r < 0)
|
||||
@@ -1267,12 +1267,10 @@ int bus_cgroup_set_property(
|
||||
set = &c->cpuset_mems;
|
||||
else if (streq(name, "StartupAllowedMemoryNodes"))
|
||||
set = &c->startup_cpuset_mems;
|
||||
else
|
||||
assert_not_reached();
|
||||
|
||||
assert(set);
|
||||
|
||||
cpu_set_reset(set);
|
||||
*set = new_set;
|
||||
new_set = (CPUSet) {};
|
||||
cpu_set_done_and_replace(*set, new_set);
|
||||
|
||||
unit_invalidate_cgroup(u, CGROUP_MASK_CPUSET);
|
||||
unit_write_settingf(u, flags, name, "%s=\n%s=%s", name, name, setstr);
|
||||
|
||||
@@ -115,7 +115,7 @@ static int property_get_cpu_affinity(
|
||||
sd_bus_error *error) {
|
||||
|
||||
ExecContext *c = ASSERT_PTR(userdata);
|
||||
_cleanup_(cpu_set_reset) CPUSet s = {};
|
||||
_cleanup_(cpu_set_done) CPUSet s = {};
|
||||
_cleanup_free_ uint8_t *array = NULL;
|
||||
size_t allocated;
|
||||
|
||||
@@ -2876,10 +2876,9 @@ int bus_exec_context_set_transient_property(
|
||||
}
|
||||
#endif
|
||||
if (STR_IN_SET(name, "CPUAffinity", "NUMAMask")) {
|
||||
_cleanup_(cpu_set_done) CPUSet set = {};
|
||||
const void *a;
|
||||
size_t n;
|
||||
bool affinity = streq(name, "CPUAffinity");
|
||||
_cleanup_(cpu_set_reset) CPUSet set = {};
|
||||
|
||||
r = sd_bus_message_read_array(message, 'y', &a, &n);
|
||||
if (r < 0)
|
||||
@@ -2890,8 +2889,10 @@ int bus_exec_context_set_transient_property(
|
||||
return r;
|
||||
|
||||
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {
|
||||
CPUSet *cpuset = streq(name, "CPUAffinity") ? &c->cpu_set : &c->numa_policy.nodes;
|
||||
|
||||
if (n == 0) {
|
||||
cpu_set_reset(affinity ? &c->cpu_set : &c->numa_policy.nodes);
|
||||
cpu_set_done(cpuset);
|
||||
unit_write_settingf(u, flags, name, "%s=", name);
|
||||
} else {
|
||||
_cleanup_free_ char *str = NULL;
|
||||
@@ -2903,7 +2904,7 @@ int bus_exec_context_set_transient_property(
|
||||
/* We forego any optimizations here, and always create the structure using
|
||||
* cpu_set_add_set(), because we don't want to care if the existing size we
|
||||
* got over dbus is appropriate. */
|
||||
r = cpu_set_add_set(affinity ? &c->cpu_set : &c->numa_policy.nodes, &set);
|
||||
r = cpu_set_add_set(cpuset, &set);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
||||
@@ -1154,7 +1154,7 @@ static int property_get_cpuset_cpus(
|
||||
sd_bus_error *error) {
|
||||
|
||||
Unit *u = ASSERT_PTR(userdata);
|
||||
_cleanup_(cpu_set_reset) CPUSet cpus = {};
|
||||
_cleanup_(cpu_set_done) CPUSet cpus = {};
|
||||
_cleanup_free_ uint8_t *array = NULL;
|
||||
size_t allocated;
|
||||
|
||||
@@ -1176,7 +1176,7 @@ static int property_get_cpuset_mems(
|
||||
sd_bus_error *error) {
|
||||
|
||||
Unit *u = ASSERT_PTR(userdata);
|
||||
_cleanup_(cpu_set_reset) CPUSet mems = {};
|
||||
_cleanup_(cpu_set_done) CPUSet mems = {};
|
||||
_cleanup_free_ uint8_t *array = NULL;
|
||||
size_t allocated;
|
||||
|
||||
|
||||
@@ -3990,7 +3990,7 @@ static int exec_context_cpu_affinity_from_numa(const ExecContext *c, CPUSet *ret
|
||||
return 0;
|
||||
}
|
||||
|
||||
_cleanup_(cpu_set_reset) CPUSet s = {};
|
||||
_cleanup_(cpu_set_done) CPUSet s = {};
|
||||
r = numa_to_cpu_set(&c->numa_policy, &s);
|
||||
if (r < 0)
|
||||
return r;
|
||||
@@ -5107,7 +5107,7 @@ int exec_invoke(
|
||||
}
|
||||
|
||||
if (context->cpu_affinity_from_numa || context->cpu_set.set) {
|
||||
_cleanup_(cpu_set_reset) CPUSet converted_cpu_set = {};
|
||||
_cleanup_(cpu_set_done) CPUSet converted_cpu_set = {};
|
||||
const CPUSet *cpu_set;
|
||||
|
||||
if (context->cpu_affinity_from_numa) {
|
||||
|
||||
+1
-1
@@ -720,7 +720,7 @@ void exec_context_done(ExecContext *c) {
|
||||
c->n_temporary_filesystems = 0;
|
||||
c->mount_images = mount_image_free_many(c->mount_images, &c->n_mount_images);
|
||||
|
||||
cpu_set_reset(&c->cpu_set);
|
||||
cpu_set_done(&c->cpu_set);
|
||||
numa_policy_reset(&c->numa_policy);
|
||||
|
||||
c->utmp_id = mfree(c->utmp_id);
|
||||
|
||||
@@ -1834,7 +1834,7 @@ int config_parse_exec_cpu_affinity(
|
||||
|
||||
if (streq(rvalue, "numa")) {
|
||||
c->cpu_affinity_from_numa = true;
|
||||
cpu_set_reset(&c->cpu_set);
|
||||
cpu_set_done(&c->cpu_set);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+1
-1
@@ -2787,7 +2787,7 @@ static void reset_arguments(void) {
|
||||
arg_machine_id = (sd_id128_t) {};
|
||||
arg_cad_burst_action = EMERGENCY_ACTION_REBOOT_FORCE;
|
||||
|
||||
cpu_set_reset(&arg_cpu_affinity);
|
||||
cpu_set_done(&arg_cpu_affinity);
|
||||
numa_policy_reset(&arg_numa_policy);
|
||||
|
||||
arg_random_seed = mfree(arg_random_seed);
|
||||
|
||||
@@ -455,7 +455,7 @@ empty:
|
||||
|
||||
static int effective_cpuset_build_json(sd_json_variant **ret, const char *name, void *userdata, const char *cpuset_name) {
|
||||
Unit *u = ASSERT_PTR(userdata);
|
||||
_cleanup_(cpu_set_reset) CPUSet cpus = {};
|
||||
_cleanup_(cpu_set_done) CPUSet cpus = {};
|
||||
int r;
|
||||
|
||||
assert(ret);
|
||||
|
||||
Reference in New Issue
Block a user