aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/freezer.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-12-12 11:18:24 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-12 11:18:24 -0500
commitd206e09036d6201f90b2719484c8a59526c46125 (patch)
tree84b9057919bcb8cfd1cff47baa5fc74457e77d6d /include/linux/freezer.h
parentfef3ff2eb777e76cfa5ae67591982d902c17139c (diff)
parent15ef4ffaa797034d5ff82844daf8f595d7c6d53c (diff)
Merge branch 'for-3.8' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup
Pull cgroup changes from Tejun Heo: "A lot of activities on cgroup side. The big changes are focused on making cgroup hierarchy handling saner. - cgroup_rmdir() had peculiar semantics - it allowed cgroup destruction to be vetoed by individual controllers and tried to drain refcnt synchronously. The vetoing never worked properly and caused good deal of contortions in cgroup. memcg was the last reamining user. Michal Hocko removed the usage and cgroup_rmdir() path has been simplified significantly. This was done in a separate branch so that the memcg people can base further memcg changes on top. - The above allowed cleaning up cgroup lifecycle management and implementation of generic cgroup iterators which are used to improve hierarchy support. - cgroup_freezer updated to allow migration in and out of a frozen cgroup and handle hierarchy. If a cgroup is frozen, all descendant cgroups are frozen. - netcls_cgroup and netprio_cgroup updated to handle hierarchy properly. - Various fixes and cleanups. - Two merge commits. One to pull in memcg and rmdir cleanups (needed to build iterators). The other pulled in cgroup/for-3.7-fixes for device_cgroup fixes so that further device_cgroup patches can be stacked on top." Fixed up a trivial conflict in mm/memcontrol.c as per Tejun (due to commit bea8c150a7 ("memcg: fix hotplugged memory zone oops") in master touching code close to commit 2ef37d3fe4 ("memcg: Simplify mem_cgroup_force_empty_list error handling") in for-3.8) * 'for-3.8' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup: (65 commits) cgroup: update Documentation/cgroups/00-INDEX cgroup_rm_file: don't delete the uncreated files cgroup: remove subsystem files when remounting cgroup cgroup: use cgroup_addrm_files() in cgroup_clear_directory() cgroup: warn about broken hierarchies only after css_online cgroup: list_del_init() on removed events cgroup: fix lockdep warning for event_control cgroup: move list add after list head initilization netprio_cgroup: allow nesting and inherit config on cgroup creation netprio_cgroup: implement netprio[_set]_prio() helpers netprio_cgroup: use cgroup->id instead of cgroup_netprio_state->prioidx netprio_cgroup: reimplement priomap expansion netprio_cgroup: shorten variable names in extend_netdev_table() netprio_cgroup: simplify write_priomap() netcls_cgroup: move config inheritance to ->css_online() and remove .broken_hierarchy marking cgroup: remove obsolete guarantee from cgroup_task_migrate. cgroup: add cgroup->id cgroup, cpuset: remove cgroup_subsys->post_clone() cgroup: s/CGRP_CLONE_CHILDREN/CGRP_CPUSET_CLONE_CHILDREN/ cgroup: rename ->create/post_create/pre_destroy/destroy() to ->css_alloc/online/offline/free() ...
Diffstat (limited to 'include/linux/freezer.h')
-rw-r--r--include/linux/freezer.h57
1 files changed, 45 insertions, 12 deletions
diff --git a/include/linux/freezer.h b/include/linux/freezer.h
index b90091af5798..e4238ceaa4d6 100644
--- a/include/linux/freezer.h
+++ b/include/linux/freezer.h
@@ -75,35 +75,68 @@ static inline bool cgroup_freezing(struct task_struct *task)
75 */ 75 */
76 76
77 77
78/* Tell the freezer not to count the current task as freezable. */ 78/**
79 * freezer_do_not_count - tell freezer to ignore %current
80 *
81 * Tell freezers to ignore the current task when determining whether the
82 * target frozen state is reached. IOW, the current task will be
83 * considered frozen enough by freezers.
84 *
85 * The caller shouldn't do anything which isn't allowed for a frozen task
86 * until freezer_cont() is called. Usually, freezer[_do_not]_count() pair
87 * wrap a scheduling operation and nothing much else.
88 */
79static inline void freezer_do_not_count(void) 89static inline void freezer_do_not_count(void)
80{ 90{
81 current->flags |= PF_FREEZER_SKIP; 91 current->flags |= PF_FREEZER_SKIP;
82} 92}
83 93
84/* 94/**
85 * Tell the freezer to count the current task as freezable again and try to 95 * freezer_count - tell freezer to stop ignoring %current
86 * freeze it. 96 *
97 * Undo freezer_do_not_count(). It tells freezers that %current should be
98 * considered again and tries to freeze if freezing condition is already in
99 * effect.
87 */ 100 */
88static inline void freezer_count(void) 101static inline void freezer_count(void)
89{ 102{
90 current->flags &= ~PF_FREEZER_SKIP; 103 current->flags &= ~PF_FREEZER_SKIP;
104 /*
105 * If freezing is in progress, the following paired with smp_mb()
106 * in freezer_should_skip() ensures that either we see %true
107 * freezing() or freezer_should_skip() sees !PF_FREEZER_SKIP.
108 */
109 smp_mb();
91 try_to_freeze(); 110 try_to_freeze();
92} 111}
93 112
94/* 113/**
95 * Check if the task should be counted as freezable by the freezer 114 * freezer_should_skip - whether to skip a task when determining frozen
115 * state is reached
116 * @p: task in quesion
117 *
118 * This function is used by freezers after establishing %true freezing() to
119 * test whether a task should be skipped when determining the target frozen
120 * state is reached. IOW, if this function returns %true, @p is considered
121 * frozen enough.
96 */ 122 */
97static inline int freezer_should_skip(struct task_struct *p) 123static inline bool freezer_should_skip(struct task_struct *p)
98{ 124{
99 return !!(p->flags & PF_FREEZER_SKIP); 125 /*
126 * The following smp_mb() paired with the one in freezer_count()
127 * ensures that either freezer_count() sees %true freezing() or we
128 * see cleared %PF_FREEZER_SKIP and return %false. This makes it
129 * impossible for a task to slip frozen state testing after
130 * clearing %PF_FREEZER_SKIP.
131 */
132 smp_mb();
133 return p->flags & PF_FREEZER_SKIP;
100} 134}
101 135
102/* 136/*
103 * These macros are intended to be used whenever you want allow a task that's 137 * These macros are intended to be used whenever you want allow a sleeping
104 * sleeping in TASK_UNINTERRUPTIBLE or TASK_KILLABLE state to be frozen. Note 138 * task to be frozen. Note that neither return any clear indication of
105 * that neither return any clear indication of whether a freeze event happened 139 * whether a freeze event happened while in this function.
106 * while in this function.
107 */ 140 */
108 141
109/* Like schedule(), but should not block the freezer. */ 142/* Like schedule(), but should not block the freezer. */