^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * cgroup_freezer.c - control group freezer subsystem
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright IBM Corporation, 2007
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Author : Cedric Le Goater <clg@fr.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * This program is free software; you can redistribute it and/or modify it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * under the terms of version 2.1 of the GNU Lesser General Public License
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * as published by the Free Software Foundation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * This program is distributed in the hope that it would be useful, but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * WITHOUT ANY WARRANTY; without even the implied warranty of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/cgroup.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/freezer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/seq_file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * A cgroup is freezing if any FREEZING flags are set. FREEZING_SELF is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * set if "FROZEN" is written to freezer.state cgroupfs file, and cleared
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * for "THAWED". FREEZING_PARENT is set if the parent freezer is FREEZING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * for whatever reason. IOW, a cgroup has FREEZING_PARENT set if one of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * its ancestors has FREEZING_SELF set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) enum freezer_state_flags {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) CGROUP_FREEZER_ONLINE = (1 << 0), /* freezer is fully online */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) CGROUP_FREEZING_SELF = (1 << 1), /* this freezer is freezing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) CGROUP_FREEZING_PARENT = (1 << 2), /* the parent freezer is freezing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) CGROUP_FROZEN = (1 << 3), /* this and its descendants frozen */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) /* mask for all FREEZING flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) CGROUP_FREEZING = CGROUP_FREEZING_SELF | CGROUP_FREEZING_PARENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) struct freezer {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) struct cgroup_subsys_state css;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) unsigned int state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) static DEFINE_MUTEX(freezer_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) static inline struct freezer *css_freezer(struct cgroup_subsys_state *css)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) return css ? container_of(css, struct freezer, css) : NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) static inline struct freezer *task_freezer(struct task_struct *task)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) return css_freezer(task_css(task, freezer_cgrp_id));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) static struct freezer *parent_freezer(struct freezer *freezer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) return css_freezer(freezer->css.parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) bool cgroup_freezing(struct task_struct *task)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) bool ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) ret = task_freezer(task)->state & CGROUP_FREEZING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) static const char *freezer_state_strs(unsigned int state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) if (state & CGROUP_FROZEN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) return "FROZEN";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) if (state & CGROUP_FREEZING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) return "FREEZING";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) return "THAWED";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) static struct cgroup_subsys_state *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) freezer_css_alloc(struct cgroup_subsys_state *parent_css)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) struct freezer *freezer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) freezer = kzalloc(sizeof(struct freezer), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) if (!freezer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) return ERR_PTR(-ENOMEM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) return &freezer->css;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) * freezer_css_online - commit creation of a freezer css
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) * @css: css being created
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) * We're committing to creation of @css. Mark it online and inherit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) * parent's freezing state while holding both parent's and our
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) * freezer->lock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) static int freezer_css_online(struct cgroup_subsys_state *css)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) struct freezer *freezer = css_freezer(css);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) struct freezer *parent = parent_freezer(freezer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) mutex_lock(&freezer_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) freezer->state |= CGROUP_FREEZER_ONLINE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) if (parent && (parent->state & CGROUP_FREEZING)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) freezer->state |= CGROUP_FREEZING_PARENT | CGROUP_FROZEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) atomic_inc(&system_freezing_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) mutex_unlock(&freezer_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) * freezer_css_offline - initiate destruction of a freezer css
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) * @css: css being destroyed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) * @css is going away. Mark it dead and decrement system_freezing_count if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) * it was holding one.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) static void freezer_css_offline(struct cgroup_subsys_state *css)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) struct freezer *freezer = css_freezer(css);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) mutex_lock(&freezer_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) if (freezer->state & CGROUP_FREEZING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) atomic_dec(&system_freezing_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) freezer->state = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) mutex_unlock(&freezer_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) static void freezer_css_free(struct cgroup_subsys_state *css)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) kfree(css_freezer(css));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) * Tasks can be migrated into a different freezer anytime regardless of its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) * current state. freezer_attach() is responsible for making new tasks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) * conform to the current state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) * Freezer state changes and task migration are synchronized via
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) * @freezer->lock. freezer_attach() makes the new tasks conform to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) * current state and all following state changes can see the new tasks.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) static void freezer_attach(struct cgroup_taskset *tset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) struct task_struct *task;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) struct cgroup_subsys_state *new_css;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) mutex_lock(&freezer_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) * Make the new tasks conform to the current state of @new_css.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) * For simplicity, when migrating any task to a FROZEN cgroup, we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) * revert it to FREEZING and let update_if_frozen() determine the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) * correct state later.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) * Tasks in @tset are on @new_css but may not conform to its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) * current state before executing the following - !frozen tasks may
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) * be visible in a FROZEN cgroup and frozen tasks in a THAWED one.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) cgroup_taskset_for_each(task, new_css, tset) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) struct freezer *freezer = css_freezer(new_css);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) if (!(freezer->state & CGROUP_FREEZING)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) __thaw_task(task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) freeze_task(task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) /* clear FROZEN and propagate upwards */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) while (freezer && (freezer->state & CGROUP_FROZEN)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) freezer->state &= ~CGROUP_FROZEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) freezer = parent_freezer(freezer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) mutex_unlock(&freezer_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) * freezer_fork - cgroup post fork callback
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) * @task: a task which has just been forked
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) * @task has just been created and should conform to the current state of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) * the cgroup_freezer it belongs to. This function may race against
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) * freezer_attach(). Losing to freezer_attach() means that we don't have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) * to do anything as freezer_attach() will put @task into the appropriate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) * state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) static void freezer_fork(struct task_struct *task)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) struct freezer *freezer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) * The root cgroup is non-freezable, so we can skip locking the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) * freezer. This is safe regardless of race with task migration.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) * If we didn't race or won, skipping is obviously the right thing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) * to do. If we lost and root is the new cgroup, noop is still the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) * right thing to do.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) if (task_css_is_root(task, freezer_cgrp_id))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) mutex_lock(&freezer_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) freezer = task_freezer(task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) if (freezer->state & CGROUP_FREEZING)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) freeze_task(task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) mutex_unlock(&freezer_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) * update_if_frozen - update whether a cgroup finished freezing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) * @css: css of interest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) * Once FREEZING is initiated, transition to FROZEN is lazily updated by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) * calling this function. If the current state is FREEZING but not FROZEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) * this function checks whether all tasks of this cgroup and the descendant
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) * cgroups finished freezing and, if so, sets FROZEN.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) * The caller is responsible for grabbing RCU read lock and calling
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) * update_if_frozen() on all descendants prior to invoking this function.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) * Task states and freezer state might disagree while tasks are being
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) * migrated into or out of @css, so we can't verify task states against
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) * @freezer state here. See freezer_attach() for details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) static void update_if_frozen(struct cgroup_subsys_state *css)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) struct freezer *freezer = css_freezer(css);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) struct cgroup_subsys_state *pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) struct css_task_iter it;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) struct task_struct *task;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) lockdep_assert_held(&freezer_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) if (!(freezer->state & CGROUP_FREEZING) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) (freezer->state & CGROUP_FROZEN))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) /* are all (live) children frozen? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) css_for_each_child(pos, css) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) struct freezer *child = css_freezer(pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) if ((child->state & CGROUP_FREEZER_ONLINE) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) !(child->state & CGROUP_FROZEN)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) /* are all tasks frozen? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) css_task_iter_start(css, 0, &it);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) while ((task = css_task_iter_next(&it))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) if (freezing(task)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) * freezer_should_skip() indicates that the task
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) * should be skipped when determining freezing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) * completion. Consider it frozen in addition to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) * the usual frozen condition.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) if (!frozen(task) && !freezer_should_skip(task))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) goto out_iter_end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) freezer->state |= CGROUP_FROZEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) out_iter_end:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) css_task_iter_end(&it);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) static int freezer_read(struct seq_file *m, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) struct cgroup_subsys_state *css = seq_css(m), *pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) mutex_lock(&freezer_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) /* update states bottom-up */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) css_for_each_descendant_post(pos, css) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) if (!css_tryget_online(pos))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) update_if_frozen(pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) css_put(pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) mutex_unlock(&freezer_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) seq_puts(m, freezer_state_strs(css_freezer(css)->state));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) seq_putc(m, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) static void freeze_cgroup(struct freezer *freezer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) struct css_task_iter it;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) struct task_struct *task;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) css_task_iter_start(&freezer->css, 0, &it);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) while ((task = css_task_iter_next(&it)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) freeze_task(task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) css_task_iter_end(&it);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) static void unfreeze_cgroup(struct freezer *freezer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) struct css_task_iter it;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) struct task_struct *task;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) css_task_iter_start(&freezer->css, 0, &it);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) while ((task = css_task_iter_next(&it)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) __thaw_task(task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) css_task_iter_end(&it);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) * freezer_apply_state - apply state change to a single cgroup_freezer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) * @freezer: freezer to apply state change to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) * @freeze: whether to freeze or unfreeze
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) * @state: CGROUP_FREEZING_* flag to set or clear
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) * Set or clear @state on @cgroup according to @freeze, and perform
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) * freezing or thawing as necessary.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) static void freezer_apply_state(struct freezer *freezer, bool freeze,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) unsigned int state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) /* also synchronizes against task migration, see freezer_attach() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) lockdep_assert_held(&freezer_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) if (!(freezer->state & CGROUP_FREEZER_ONLINE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) if (freeze) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) if (!(freezer->state & CGROUP_FREEZING))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) atomic_inc(&system_freezing_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) freezer->state |= state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) freeze_cgroup(freezer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) bool was_freezing = freezer->state & CGROUP_FREEZING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) freezer->state &= ~state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) if (!(freezer->state & CGROUP_FREEZING)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) if (was_freezing)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) atomic_dec(&system_freezing_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) freezer->state &= ~CGROUP_FROZEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) unfreeze_cgroup(freezer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) * freezer_change_state - change the freezing state of a cgroup_freezer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) * @freezer: freezer of interest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) * @freeze: whether to freeze or thaw
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) * Freeze or thaw @freezer according to @freeze. The operations are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) * recursive - all descendants of @freezer will be affected.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) static void freezer_change_state(struct freezer *freezer, bool freeze)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) struct cgroup_subsys_state *pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) * Update all its descendants in pre-order traversal. Each
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) * descendant will try to inherit its parent's FREEZING state as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) * CGROUP_FREEZING_PARENT.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) mutex_lock(&freezer_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) css_for_each_descendant_pre(pos, &freezer->css) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) struct freezer *pos_f = css_freezer(pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) struct freezer *parent = parent_freezer(pos_f);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) if (!css_tryget_online(pos))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) if (pos_f == freezer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) freezer_apply_state(pos_f, freeze,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) CGROUP_FREEZING_SELF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) freezer_apply_state(pos_f,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) parent->state & CGROUP_FREEZING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) CGROUP_FREEZING_PARENT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) css_put(pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) mutex_unlock(&freezer_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) static ssize_t freezer_write(struct kernfs_open_file *of,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) char *buf, size_t nbytes, loff_t off)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) bool freeze;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) buf = strstrip(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) if (strcmp(buf, freezer_state_strs(0)) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) freeze = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) else if (strcmp(buf, freezer_state_strs(CGROUP_FROZEN)) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) freeze = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) freezer_change_state(css_freezer(of_css(of)), freeze);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) return nbytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) static u64 freezer_self_freezing_read(struct cgroup_subsys_state *css,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) struct cftype *cft)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) struct freezer *freezer = css_freezer(css);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) return (bool)(freezer->state & CGROUP_FREEZING_SELF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) static u64 freezer_parent_freezing_read(struct cgroup_subsys_state *css,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) struct cftype *cft)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) struct freezer *freezer = css_freezer(css);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) return (bool)(freezer->state & CGROUP_FREEZING_PARENT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) static struct cftype files[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) .name = "state",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) .flags = CFTYPE_NOT_ON_ROOT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) .seq_show = freezer_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) .write = freezer_write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) .name = "self_freezing",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) .flags = CFTYPE_NOT_ON_ROOT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) .read_u64 = freezer_self_freezing_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) .name = "parent_freezing",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) .flags = CFTYPE_NOT_ON_ROOT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) .read_u64 = freezer_parent_freezing_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) { } /* terminate */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) struct cgroup_subsys freezer_cgrp_subsys = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) .css_alloc = freezer_css_alloc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) .css_online = freezer_css_online,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) .css_offline = freezer_css_offline,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) .css_free = freezer_css_free,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) .attach = freezer_attach,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) .fork = freezer_fork,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) .legacy_cftypes = files,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) EXPORT_SYMBOL_GPL(freezer_cgrp_subsys);