aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memcontrol.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2014-07-08 18:02:57 -0400
committerTejun Heo <tj@kernel.org>2014-07-08 18:02:57 -0400
commit1ced953b17bfaf54ec1499f8bbfdf31ab36453af (patch)
tree270f730f641e23ebc6827593e295f434a60a9732 /mm/memcontrol.c
parentaf0ba6789c8e43518635606d0af1ff475ba7471a (diff)
blkcg, memcg: make blkcg depend on memcg on the default hierarchy
Currently, the blkio subsystem attributes all of writeback IOs to the root. One of the issues is that there's no way to tell who originated a writeback IO from block layer. Those IOs are usually issued asynchronously from a task which didn't have anything to do with actually generating the dirty pages. The memory subsystem, when enabled, already keeps track of the ownership of each dirty page and it's desirable for blkio to piggyback instead of adding its own per-page tag. cgroup now has a mechanism to express such dependency - cgroup_subsys->depends_on. This patch declares that blkcg depends on memcg so that memcg is enabled automatically on the default hierarchy when available. Future changes will make blkcg map the memcg tag to find out the cgroup to blame for writeback IOs. As this means that a memcg may be made invisible, this patch also implements css_reset() for memcg which resets its basic configurations. This implementation will probably need to be expanded to cover other states which are used in the default hierarchy. v2: blkcg's dependency on memcg is wrapped with CONFIG_MEMCG to avoid build failure. Reported by kbuild test robot. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Li Zefan <lizefan@huawei.com> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Cc: Michal Hocko <mhocko@suse.cz> Cc: Vivek Goyal <vgoyal@redhat.com> Cc: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r--mm/memcontrol.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index a2c7bcb0e6eb..db536e90c8ee 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -6407,6 +6407,29 @@ static void mem_cgroup_css_free(struct cgroup_subsys_state *css)
6407 __mem_cgroup_free(memcg); 6407 __mem_cgroup_free(memcg);
6408} 6408}
6409 6409
6410/**
6411 * mem_cgroup_css_reset - reset the states of a mem_cgroup
6412 * @css: the target css
6413 *
6414 * Reset the states of the mem_cgroup associated with @css. This is
6415 * invoked when the userland requests disabling on the default hierarchy
6416 * but the memcg is pinned through dependency. The memcg should stop
6417 * applying policies and should revert to the vanilla state as it may be
6418 * made visible again.
6419 *
6420 * The current implementation only resets the essential configurations.
6421 * This needs to be expanded to cover all the visible parts.
6422 */
6423static void mem_cgroup_css_reset(struct cgroup_subsys_state *css)
6424{
6425 struct mem_cgroup *memcg = mem_cgroup_from_css(css);
6426
6427 mem_cgroup_resize_limit(memcg, ULLONG_MAX);
6428 mem_cgroup_resize_memsw_limit(memcg, ULLONG_MAX);
6429 memcg_update_kmem_limit(memcg, ULLONG_MAX);
6430 res_counter_set_soft_limit(&memcg->res, ULLONG_MAX);
6431}
6432
6410#ifdef CONFIG_MMU 6433#ifdef CONFIG_MMU
6411/* Handlers for move charge at task migration. */ 6434/* Handlers for move charge at task migration. */
6412#define PRECHARGE_COUNT_AT_ONCE 256 6435#define PRECHARGE_COUNT_AT_ONCE 256
@@ -7019,6 +7042,7 @@ struct cgroup_subsys memory_cgrp_subsys = {
7019 .css_online = mem_cgroup_css_online, 7042 .css_online = mem_cgroup_css_online,
7020 .css_offline = mem_cgroup_css_offline, 7043 .css_offline = mem_cgroup_css_offline,
7021 .css_free = mem_cgroup_css_free, 7044 .css_free = mem_cgroup_css_free,
7045 .css_reset = mem_cgroup_css_reset,
7022 .can_attach = mem_cgroup_can_attach, 7046 .can_attach = mem_cgroup_can_attach,
7023 .cancel_attach = mem_cgroup_cancel_attach, 7047 .cancel_attach = mem_cgroup_cancel_attach,
7024 .attach = mem_cgroup_move_task, 7048 .attach = mem_cgroup_move_task,