<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/kernel/cgroup_freezer.c, branch v3.19</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v3.19</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v3.19'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2014-07-15T15:05:09Z</updated>
<entry>
<title>cgroup: rename cgroup_subsys-&gt;base_cftypes to -&gt;legacy_cftypes</title>
<updated>2014-07-15T15:05:09Z</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2014-07-15T15:05:09Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=5577964e64692e17cc498854b7e0833e6532cd64'/>
<id>urn:sha1:5577964e64692e17cc498854b7e0833e6532cd64</id>
<content type='text'>
Currently, cgroup_subsys-&gt;base_cftypes is used for both the unified
default hierarchy and legacy ones and subsystems can mark each file
with either CFTYPE_ONLY_ON_DFL or CFTYPE_INSANE if it has to appear
only on one of them.  This is quite hairy and error-prone.  Also, we
may end up exposing interface files to the default hierarchy without
thinking it through.

cgroup_subsys will grow two separate cftype arrays and apply each only
on the hierarchies of the matching type.  This will allow organizing
cftypes in a lot clearer way and encourage subsystems to scrutinize
the interface which is being exposed in the new default hierarchy.

In preparation, this patch renames cgroup_subsys-&gt;base_cftypes to
cgroup_subsys-&gt;legacy_cftypes.  This patch is pure rename.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Acked-by: Neil Horman &lt;nhorman@tuxdriver.com&gt;
Acked-by: Li Zefan &lt;lizefan@huawei.com&gt;
Cc: Johannes Weiner &lt;hannes@cmpxchg.org&gt;
Cc: Michal Hocko &lt;mhocko@suse.cz&gt;
Cc: Vivek Goyal &lt;vgoyal@redhat.com&gt;
Cc: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Cc: Paul Mackerras &lt;paulus@samba.org&gt;
Cc: Ingo Molnar &lt;mingo@redhat.com&gt;
Cc: Arnaldo Carvalho de Melo &lt;acme@kernel.org&gt;
Cc: Aristeu Rozanski &lt;aris@redhat.com&gt;
Cc: Aneesh Kumar K.V &lt;aneesh.kumar@linux.vnet.ibm.com&gt;
</content>
</entry>
<entry>
<title>cgroup: remove css_parent()</title>
<updated>2014-05-16T17:22:48Z</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2014-05-16T17:22:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=5c9d535b893f30266ea29fe377cb9b002fcd76aa'/>
<id>urn:sha1:5c9d535b893f30266ea29fe377cb9b002fcd76aa</id>
<content type='text'>
cgroup in general is moving towards using cgroup_subsys_state as the
fundamental structural component and css_parent() was introduced to
convert from using cgroup-&gt;parent to css-&gt;parent.  It was quite some
time ago and we're moving forward with making css more prominent.

This patch drops the trivial wrapper css_parent() and let the users
dereference css-&gt;parent.  While at it, explicitly mark fields of css
which are public and immutable.

v2: New usage from device_cgroup.c converted.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Acked-by: Michal Hocko &lt;mhocko@suse.cz&gt;
Acked-by: Neil Horman &lt;nhorman@tuxdriver.com&gt;
Acked-by: "David S. Miller" &lt;davem@davemloft.net&gt;
Acked-by: Li Zefan &lt;lizefan@huawei.com&gt;
Cc: Vivek Goyal &lt;vgoyal@redhat.com&gt;
Cc: Jens Axboe &lt;axboe@kernel.dk&gt;
Cc: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Cc: Johannes Weiner &lt;hannes@cmpxchg.org&gt;
</content>
</entry>
<entry>
<title>cgroup: replace cftype-&gt;write_string() with cftype-&gt;write()</title>
<updated>2014-05-13T16:16:21Z</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2014-05-13T16:16:21Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=451af504df0c62f695a69b83c250486e77c66378'/>
<id>urn:sha1:451af504df0c62f695a69b83c250486e77c66378</id>
<content type='text'>
Convert all cftype-&gt;write_string() users to the new cftype-&gt;write()
which maps directly to kernfs write operation and has full access to
kernfs and cgroup contexts.  The conversions are mostly mechanical.

* @css and @cft are accessed using of_css() and of_cft() accessors
  respectively instead of being specified as arguments.

* Should return @nbytes on success instead of 0.

* @buf is not trimmed automatically.  Trim if necessary.  Note that
  blkcg and netprio don't need this as the parsers already handle
  whitespaces.

cftype-&gt;write_string() has no user left after the conversions and
removed.

While at it, remove unnecessary local variable @p in
cgroup_subtree_control_write() and stale comment about
CGROUP_LOCAL_BUFFER_SIZE in cgroup_freezer.c.

This patch doesn't introduce any visible behavior changes.

v2: netprio was missing from conversion.  Converted.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Acked-by: Aristeu Rozanski &lt;arozansk@redhat.com&gt;
Acked-by: Vivek Goyal &lt;vgoyal@redhat.com&gt;
Acked-by: Li Zefan &lt;lizefan@huawei.com&gt;
Cc: Jens Axboe &lt;axboe@kernel.dk&gt;
Cc: Johannes Weiner &lt;hannes@cmpxchg.org&gt;
Cc: Michal Hocko &lt;mhocko@suse.cz&gt;
Cc: Neil Horman &lt;nhorman@tuxdriver.com&gt;
Cc: "David S. Miller" &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>cgroup: rename css_tryget*() to css_tryget_online*()</title>
<updated>2014-05-13T16:11:01Z</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2014-05-13T16:11:01Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=ec903c0c858e4963a9e0724bdcadfa837253341c'/>
<id>urn:sha1:ec903c0c858e4963a9e0724bdcadfa837253341c</id>
<content type='text'>
Unlike the more usual refcnting, what css_tryget() provides is the
distinction between online and offline csses instead of protection
against upping a refcnt which already reached zero.  cgroup is
planning to provide actual tryget which fails if the refcnt already
reached zero.  Let's rename the existing trygets so that they clearly
indicate that they're onliness.

I thought about keeping the existing names as-are and introducing new
names for the planned actual tryget; however, given that each
controller participates in the synchronization of the online state, it
seems worthwhile to make it explicit that these functions are about
on/offline state.

Rename css_tryget() to css_tryget_online() and css_tryget_from_dir()
to css_tryget_online_from_dir().  This is pure rename.

v2: cgroup_freezer grew new usages of css_tryget().  Update
    accordingly.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Acked-by: Johannes Weiner &lt;hannes@cmpxchg.org&gt;
Acked-by: Michal Hocko &lt;mhocko@suse.cz&gt;
Acked-by: Li Zefan &lt;lizefan@huawei.com&gt;
Cc: Vivek Goyal &lt;vgoyal@redhat.com&gt;
Cc: Jens Axboe &lt;axboe@kernel.dk&gt;
Cc: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Cc: Paul Mackerras &lt;paulus@samba.org&gt;
Cc: Ingo Molnar &lt;mingo@redhat.com&gt;
Cc: Arnaldo Carvalho de Melo &lt;acme@kernel.org&gt;
</content>
</entry>
<entry>
<title>cgroup: fix rcu_read_lock() leak in update_if_frozen()</title>
<updated>2014-05-13T15:28:30Z</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2014-05-13T15:28:30Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=36e9d2ebcc15d029b33f42a36146ab5a5bcfcfe7'/>
<id>urn:sha1:36e9d2ebcc15d029b33f42a36146ab5a5bcfcfe7</id>
<content type='text'>
While updating cgroup_freezer locking, 68fafb77d827 ("cgroup_freezer:
replace freezer-&gt;lock with freezer_mutex") introduced a bug in
update_if_frozen() where it returns with rcu_read_lock() held.  Fix it
by adding rcu_read_unlock() before returning.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Reported-by: kbuild test robot &lt;fengguang.wu@intel.com&gt;
</content>
</entry>
<entry>
<title>cgroup_freezer: replace freezer-&gt;lock with freezer_mutex</title>
<updated>2014-05-13T15:26:31Z</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2014-05-08T01:31:17Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=e5ced8ebb10c20a3b349bd798b69ccabd3b25d21'/>
<id>urn:sha1:e5ced8ebb10c20a3b349bd798b69ccabd3b25d21</id>
<content type='text'>
After 96d365e0b86e ("cgroup: make css_set_lock a rwsem and rename it
to css_set_rwsem"), css task iterators requires sleepable context as
it may block on css_set_rwsem.  I missed that cgroup_freezer was
iterating tasks under IRQ-safe spinlock freezer-&gt;lock.  This leads to
errors like the following on freezer state reads and transitions.

  BUG: sleeping function called from invalid context at /work
 /os/work/kernel/locking/rwsem.c:20
  in_atomic(): 0, irqs_disabled(): 0, pid: 462, name: bash
  5 locks held by bash/462:
   #0:  (sb_writers#7){.+.+.+}, at: [&lt;ffffffff811f0843&gt;] vfs_write+0x1a3/0x1c0
   #1:  (&amp;of-&gt;mutex){+.+.+.}, at: [&lt;ffffffff8126d78b&gt;] kernfs_fop_write+0xbb/0x170
   #2:  (s_active#70){.+.+.+}, at: [&lt;ffffffff8126d793&gt;] kernfs_fop_write+0xc3/0x170
   #3:  (freezer_mutex){+.+...}, at: [&lt;ffffffff81135981&gt;] freezer_write+0x61/0x1e0
   #4:  (rcu_read_lock){......}, at: [&lt;ffffffff81135973&gt;] freezer_write+0x53/0x1e0
  Preemption disabled at:[&lt;ffffffff81104404&gt;] console_unlock+0x1e4/0x460

  CPU: 3 PID: 462 Comm: bash Not tainted 3.15.0-rc1-work+ #10
  Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
   ffff88000916a6d0 ffff88000e0a3da0 ffffffff81cf8c96 0000000000000000
   ffff88000e0a3dc8 ffffffff810cf4f2 ffffffff82388040 ffff880013aaf740
   0000000000000002 ffff88000e0a3de8 ffffffff81d05974 0000000000000246
  Call Trace:
   [&lt;ffffffff81cf8c96&gt;] dump_stack+0x4e/0x7a
   [&lt;ffffffff810cf4f2&gt;] __might_sleep+0x162/0x260
   [&lt;ffffffff81d05974&gt;] down_read+0x24/0x60
   [&lt;ffffffff81133e87&gt;] css_task_iter_start+0x27/0x70
   [&lt;ffffffff8113584d&gt;] freezer_apply_state+0x5d/0x130
   [&lt;ffffffff81135a16&gt;] freezer_write+0xf6/0x1e0
   [&lt;ffffffff8112eb88&gt;] cgroup_file_write+0xd8/0x230
   [&lt;ffffffff8126d7b7&gt;] kernfs_fop_write+0xe7/0x170
   [&lt;ffffffff811f0756&gt;] vfs_write+0xb6/0x1c0
   [&lt;ffffffff811f121d&gt;] SyS_write+0x4d/0xc0
   [&lt;ffffffff81d08292&gt;] system_call_fastpath+0x16/0x1b

freezer-&gt;lock used to be used in hot paths but that time is long gone
and there's no reason for the lock to be IRQ-safe spinlock or even
per-cgroup.  In fact, given the fact that a cgroup may contain large
number of tasks, it's not a good idea to iterate over them while
holding IRQ-safe spinlock.

Let's simplify locking by replacing per-cgroup freezer-&gt;lock with
global freezer_mutex.  This also makes the comments explaining the
intricacies of policy inheritance and the locking around it as the
states are protected by a common mutex.

The conversion is mostly straight-forward.  The followings are worth
mentioning.

* freezer_css_online() no longer needs double locking.

* freezer_attach() now performs propagation simply while holding
  freezer_mutex.  update_if_frozen() race no longer exists and the
  comment is removed.

* freezer_fork() now tests whether the task is in root cgroup using
  the new task_css_is_root() without doing rcu_read_lock/unlock().  If
  not, it grabs freezer_mutex and performs the operation.

* freezer_read() and freezer_change_state() grab freezer_mutex across
  the whole operation and pin the css while iterating so that each
  descendant processing happens in sleepable context.

Fixes: 96d365e0b86e ("cgroup: make css_set_lock a rwsem and rename it to css_set_rwsem")
Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Acked-by: Li Zefan &lt;lizefan@huawei.com&gt;
</content>
</entry>
<entry>
<title>cgroup: drop const from @buffer of cftype-&gt;write_string()</title>
<updated>2014-03-19T14:23:54Z</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2014-03-19T14:23:54Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=4d3bb511b5f9980fc3e9ae5939ebc475b231d3fc'/>
<id>urn:sha1:4d3bb511b5f9980fc3e9ae5939ebc475b231d3fc</id>
<content type='text'>
cftype-&gt;write_string() just passes on the writeable buffer from kernfs
and there's no reason to add const restriction on the buffer.  The
only thing const achieves is unnecessarily complicating parsing of the
buffer.  Drop const from @buffer.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Acked-by: Li Zefan &lt;lizefan@huawei.com&gt;
Cc: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Cc: Paul Mackerras &lt;paulus@samba.org&gt;
Cc: Ingo Molnar &lt;mingo@redhat.com&gt;
Cc: Arnaldo Carvalho de Melo &lt;acme@ghostprotocols.net&gt;
Cc: Daniel Borkmann &lt;dborkman@redhat.com&gt;
Cc: Michal Hocko &lt;mhocko@suse.cz&gt;                                           
Cc: Johannes Weiner &lt;hannes@cmpxchg.org&gt;
Cc: Balbir Singh &lt;bsingharora@gmail.com&gt;
Cc: KAMEZAWA Hiroyuki &lt;kamezawa.hiroyu@jp.fujitsu.com&gt;
</content>
</entry>
<entry>
<title>cgroup_freezer: document freezer_fork() subtleties</title>
<updated>2014-02-25T15:04:40Z</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2014-02-12T21:07:59Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=a60bed296ac67b9e2765646dec8e36e3b4d7c395'/>
<id>urn:sha1:a60bed296ac67b9e2765646dec8e36e3b4d7c395</id>
<content type='text'>
cgroup_subsys-&gt;fork() callback is special in that it's called outside
the usual cgroup locking and may race with on-going migration.
freezer_fork() currently doesn't consider such race condition;
however, it is still correct thanks to the fact that freeze_task() may
be called spuriously.

This is quite subtle.  Let's explain what's going on and add test to
detect racing and losing to task migration and skip freeze_task() in
such cases for documentation.

This doesn't make any behavior difference meaningful to userland.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Cc: Li Zefan &lt;lizefan@huawei.com&gt;
Cc: "Rafael J. Wysocki" &lt;rjw@rjwysocki.net&gt;
</content>
</entry>
<entry>
<title>cgroup: drop @skip_css from cgroup_taskset_for_each()</title>
<updated>2014-02-13T11:58:41Z</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2014-02-13T11:58:41Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=924f0d9a2078f49ff331bb43196ec5afadc16b8f'/>
<id>urn:sha1:924f0d9a2078f49ff331bb43196ec5afadc16b8f</id>
<content type='text'>
If !NULL, @skip_css makes cgroup_taskset_for_each() skip the matching
css.  The intention of the interface is to make it easy to skip css's
(cgroup_subsys_states) which already match the migration target;
however, this is entirely unnecessary as migration taskset doesn't
include tasks which are already in the target cgroup.  Drop @skip_css
from cgroup_taskset_for_each().

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Acked-by: Li Zefan &lt;lizefan@huawei.com&gt;
Cc: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&gt;
Cc: Paul Mackerras &lt;paulus@samba.org&gt;
Cc: Ingo Molnar &lt;mingo@redhat.com&gt;
Cc: Arnaldo Carvalho de Melo &lt;acme@ghostprotocols.net&gt;
Cc: Daniel Borkmann &lt;dborkman@redhat.com&gt;
</content>
</entry>
<entry>
<title>cgroup: clean up cgroup_subsys names and initialization</title>
<updated>2014-02-08T15:36:58Z</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2014-02-08T15:36:58Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=073219e995b4a3f8cf1ce8228b7ef440b6994ac0'/>
<id>urn:sha1:073219e995b4a3f8cf1ce8228b7ef440b6994ac0</id>
<content type='text'>
cgroup_subsys is a bit messier than it needs to be.

* The name of a subsys can be different from its internal identifier
  defined in cgroup_subsys.h.  Most subsystems use the matching name
  but three - cpu, memory and perf_event - use different ones.

* cgroup_subsys_id enums are postfixed with _subsys_id and each
  cgroup_subsys is postfixed with _subsys.  cgroup.h is widely
  included throughout various subsystems, it doesn't and shouldn't
  have claim on such generic names which don't have any qualifier
  indicating that they belong to cgroup.

* cgroup_subsys-&gt;subsys_id should always equal the matching
  cgroup_subsys_id enum; however, we require each controller to
  initialize it and then BUG if they don't match, which is a bit
  silly.

This patch cleans up cgroup_subsys names and initialization by doing
the followings.

* cgroup_subsys_id enums are now postfixed with _cgrp_id, and each
  cgroup_subsys with _cgrp_subsys.

* With the above, renaming subsys identifiers to match the userland
  visible names doesn't cause any naming conflicts.  All non-matching
  identifiers are renamed to match the official names.

  cpu_cgroup -&gt; cpu
  mem_cgroup -&gt; memory
  perf -&gt; perf_event

* controllers no longer need to initialize -&gt;subsys_id and -&gt;name.
  They're generated in cgroup core and set automatically during boot.

* Redundant cgroup_subsys declarations removed.

* While updating BUG_ON()s in cgroup_init_early(), convert them to
  WARN()s.  BUGging that early during boot is stupid - the kernel
  can't print anything, even through serial console and the trap
  handler doesn't even link stack frame properly for back-tracing.

This patch doesn't introduce any behavior changes.

v2: Rebased on top of fe1217c4f3f7 ("net: net_cls: move cgroupfs
    classid handling into core").

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Acked-by: Neil Horman &lt;nhorman@tuxdriver.com&gt;
Acked-by: "David S. Miller" &lt;davem@davemloft.net&gt;
Acked-by: "Rafael J. Wysocki" &lt;rjw@rjwysocki.net&gt;
Acked-by: Michal Hocko &lt;mhocko@suse.cz&gt;
Acked-by: Peter Zijlstra &lt;peterz@infradead.org&gt;
Acked-by: Aristeu Rozanski &lt;aris@redhat.com&gt;
Acked-by: Ingo Molnar &lt;mingo@redhat.com&gt;
Acked-by: Li Zefan &lt;lizefan@huawei.com&gt;
Cc: Johannes Weiner &lt;hannes@cmpxchg.org&gt;
Cc: Balbir Singh &lt;bsingharora@gmail.com&gt;
Cc: KAMEZAWA Hiroyuki &lt;kamezawa.hiroyu@jp.fujitsu.com&gt;
Cc: Serge E. Hallyn &lt;serue@us.ibm.com&gt;
Cc: Vivek Goyal &lt;vgoyal@redhat.com&gt;
Cc: Thomas Graf &lt;tgraf@suug.ch&gt;
</content>
</entry>
</feed>
