1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-22 13:33:56 +03:00

Merge pull request #20199 from ddstreet/unit_cgroup_catchup

cgroup: do 'catchup' for unit cgroup inotify watch files
This commit is contained in:
Lennart Poettering 2021-08-12 16:04:40 +02:00 committed by GitHub
commit ced10d4838
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 2 deletions

View File

@ -3031,6 +3031,9 @@ static int unit_check_cgroup_events(Unit *u) {
assert(u);
if (!u->cgroup_path)
return 0;
r = cg_get_keyed_attribute_graceful(SYSTEMD_CGROUP_CONTROLLER, u->cgroup_path, "cgroup.events",
STRV_MAKE("populated", "frozen"), values);
if (r < 0)
@ -3863,6 +3866,21 @@ void unit_invalidate_cgroup_bpf(Unit *u) {
}
}
void unit_cgroup_catchup(Unit *u) {
assert(u);
if (!UNIT_HAS_CGROUP_CONTEXT(u))
return;
/* We dropped the inotify watch during reexec/reload, so we need to
* check these as they may have changed.
* Note that (currently) the kernel doesn't actually update cgroup
* file modification times, so we can't just serialize and then check
* the mtime for file(s) we are interested in. */
(void) unit_check_cgroup_events(u);
unit_add_to_cgroup_oom_queue(u);
}
bool unit_cgroup_delegate(Unit *u) {
CGroupContext *c;

View File

@ -313,6 +313,8 @@ void manager_invalidate_startup_units(Manager *m);
const char* cgroup_device_policy_to_string(CGroupDevicePolicy i) _const_;
CGroupDevicePolicy cgroup_device_policy_from_string(const char *s) _pure_;
void unit_cgroup_catchup(Unit *u);
bool unit_cgroup_delegate(Unit *u);
int compare_job_priority(const void *a, const void *b);

View File

@ -1437,6 +1437,10 @@ static void manager_clear_jobs_and_units(Manager *m) {
assert(!m->cleanup_queue);
assert(!m->gc_unit_queue);
assert(!m->gc_job_queue);
assert(!m->cgroup_realize_queue);
assert(!m->cgroup_empty_queue);
assert(!m->cgroup_oom_queue);
assert(!m->target_deps_queue);
assert(!m->stop_when_unneeded_queue);
assert(!m->start_when_upheld_queue);
assert(!m->stop_when_bound_queue);

View File

@ -733,6 +733,9 @@ Unit* unit_free(Unit *u) {
if (u->in_dbus_queue)
LIST_REMOVE(dbus_queue, u->manager->dbus_unit_queue, u);
if (u->in_cleanup_queue)
LIST_REMOVE(cleanup_queue, u->manager->cleanup_queue, u);
if (u->in_gc_queue)
LIST_REMOVE(gc_queue, u->manager->gc_unit_queue, u);
@ -742,8 +745,8 @@ Unit* unit_free(Unit *u) {
if (u->in_cgroup_empty_queue)
LIST_REMOVE(cgroup_empty_queue, u->manager->cgroup_empty_queue, u);
if (u->in_cleanup_queue)
LIST_REMOVE(cleanup_queue, u->manager->cleanup_queue, u);
if (u->in_cgroup_oom_queue)
LIST_REMOVE(cgroup_oom_queue, u->manager->cgroup_oom_queue, u);
if (u->in_target_deps_queue)
LIST_REMOVE(target_deps_queue, u->manager->target_deps_queue, u);
@ -3611,6 +3614,8 @@ void unit_catchup(Unit *u) {
if (UNIT_VTABLE(u)->catchup)
UNIT_VTABLE(u)->catchup(u);
unit_cgroup_catchup(u);
}
static bool fragment_mtime_newer(const char *path, usec_t mtime, bool path_masked) {