提交 769519ba 编写于 作者: J Jiufei Xue 提交者: Joseph Qi

writeback: introduce cgwb_v1 boot param

So far writeback control is supported for cgroup v1 interface. However
it also has some restrictions, so introduce a new kernel boot parameter
to control the behavior which is disabled by default. Users can enable
the writeback control for cgroup v1 with the command line "cgwb_v1".
Signed-off-by: NJiufei Xue <jiufei.xue@linux.alibaba.com>
Reviewed-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
上级 dda65ea8
......@@ -496,6 +496,9 @@
nosocket -- Disable socket memory accounting.
nokmem -- Disable kernel memory accounting.
cgwb_v1 Enable writeback control for cgroup for cgroup v1
interface.
checkreqprot [SELINUX] Set initial checkreqprot flag value.
Format: { "0" | "1" }
See security/selinux/Kconfig help text.
......
......@@ -233,6 +233,21 @@ void wb_memcg_offline(struct mem_cgroup *memcg);
void wb_blkcg_offline(struct blkcg *blkcg);
int inode_congested(struct inode *inode, int cong_bits);
extern bool cgwb_v1;
static inline bool memcg_blkcg_on_dfl(void)
{
return cgroup_subsys_on_dfl(memory_cgrp_subsys) &&
cgroup_subsys_on_dfl(io_cgrp_subsys);
}
static inline bool cgroup_writeback_support_v1(void)
{
return cgwb_v1 &&
!cgroup_subsys_on_dfl(memory_cgrp_subsys) &&
!cgroup_subsys_on_dfl(io_cgrp_subsys);
}
/**
* inode_cgwb_enabled - test whether cgroup writeback is enabled on an inode
* @inode: inode of interest
......@@ -248,7 +263,9 @@ static inline bool inode_cgwb_enabled(struct inode *inode)
{
struct backing_dev_info *bdi = inode_to_bdi(inode);
return bdi_cap_account_dirty(bdi) &&
return (memcg_blkcg_on_dfl() ||
cgroup_writeback_support_v1()) &&
bdi_cap_account_dirty(bdi) &&
(bdi->capabilities & BDI_CAP_CGROUP_WRITEBACK) &&
(inode->i_sb->s_iflags & SB_I_CGROUPWB);
}
......
......@@ -49,6 +49,9 @@ static void bdi_debug_init(void)
if (!bdi_debug_root)
return;
if (!cgwb_v1)
return;
memcg_blkcg_file = debugfs_create_file("bdi_wb_link", 0444, bdi_debug_root,
NULL, &memcg_blkcg_debug_fops);
#endif
......@@ -455,6 +458,9 @@ int allocate_memcg_blkcg_links(int count, struct list_head *tmp_links)
struct memcg_blkcg_link *link;
int i;
if (!cgwb_v1)
return 0;
for (i = 0; i < count; i++) {
link = kzalloc(sizeof(*link), GFP_KERNEL);
if (!link) {
......@@ -482,6 +488,9 @@ void insert_memcg_blkcg_link(struct cgroup_subsys *ss,
struct cgroup_subsys_state *memcg_css;
int err;
if (!cgwb_v1)
return;
if (ss->id != io_cgrp_id && ss->id != memory_cgrp_id)
return;
......@@ -567,6 +576,9 @@ static void delete_blkcg_link(struct cgroup_subsys_state *blkcg_css)
void delete_memcg_blkcg_link(struct cgroup_subsys *ss,
struct cgroup_subsys_state *css)
{
if (!cgwb_v1)
return;
if (ss->id != io_cgrp_id && ss->id != memory_cgrp_id)
return;
......
......@@ -468,7 +468,8 @@ struct cgroup_subsys_state *mem_cgroup_css_from_page(struct page *page)
memcg = page->mem_cgroup;
if (!memcg)
if (!memcg ||
(!cgroup_subsys_on_dfl(memory_cgrp_subsys) && !cgwb_v1))
memcg = root_mem_cgroup;
return &memcg->css;
......@@ -6369,6 +6370,16 @@ static int __init cgroup_memory(char *s)
}
__setup("cgroup.memory=", cgroup_memory);
bool cgwb_v1 = false;
static int __init enable_cgroup_writeback_v1(char *s)
{
cgwb_v1 = true;
return 0;
}
__setup("cgwb_v1", enable_cgroup_writeback_v1);
/*
* subsys_initcall() for memory controller.
*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册