提交 26ba3a84 编写于 作者: Y Yang Yingliang 提交者: Zheng Zengkai

cgroup/files: support boot parameter to control if disable files cgroup

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4G4S5

--------------------------------

When files cgroup is enabled, it's will leads syscall performance
regression in UnixBench. Add a helper files_cgroup_enabled() and
use it to control if use files cgroup, wen can use cgroup_disable=files
in cmdline to disable files cgroup.

syscall of UnixBench (large is better)
enable files cgroup:            2868.5
disable files cgroup:           3177.0
disable config of files cgroup: 3186.5
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Reviewed-by: NTao Hou <houtao1@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Conflicts:
	Documentation/admin-guide/kernel-parameters.txt
Signed-off-by: NLu Jialin <lujialin4@huawei.com>
Reviewed-by: Nweiyang wang <wangweiyang2@huawei.com>
Reviewed-by: NHou Tao <houtao1@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 7e485fec
...@@ -500,9 +500,10 @@ ...@@ -500,9 +500,10 @@
a single hierarchy a single hierarchy
- foo isn't visible as an individually mountable - foo isn't visible as an individually mountable
subsystem subsystem
{Currently only "memory" controller deal with this and {Currently "memory" and "files" controller deal with
cut the overhead, others just disable the usage. So this and cut the overhead, others just disable the usage.
only cgroup_disable=memory is actually worthy} So cgroup_disable=memory and cgroup_disable=files are
actually worthy}
cgroup_no_v1= [KNL] Disable cgroup controllers and named hierarchies in v1 cgroup_no_v1= [KNL] Disable cgroup controllers and named hierarchies in v1
Format: { { controller | "all" | "named" } Format: { { controller | "all" | "named" }
......
...@@ -308,7 +308,8 @@ struct files_struct *dup_fd(struct files_struct *oldf, unsigned int max_fds, int ...@@ -308,7 +308,8 @@ struct files_struct *dup_fd(struct files_struct *oldf, unsigned int max_fds, int
new_fdt->full_fds_bits = newf->full_fds_bits_init; new_fdt->full_fds_bits = newf->full_fds_bits_init;
new_fdt->fd = &newf->fd_array[0]; new_fdt->fd = &newf->fd_array[0];
#ifdef CONFIG_CGROUP_FILES #ifdef CONFIG_CGROUP_FILES
files_cgroup_assign(newf); if (files_cgroup_enabled())
files_cgroup_assign(newf);
#endif #endif
spin_lock(&oldf->file_lock); spin_lock(&oldf->file_lock);
...@@ -374,6 +375,8 @@ struct files_struct *dup_fd(struct files_struct *oldf, unsigned int max_fds, int ...@@ -374,6 +375,8 @@ struct files_struct *dup_fd(struct files_struct *oldf, unsigned int max_fds, int
rcu_assign_pointer(newf->fdt, new_fdt); rcu_assign_pointer(newf->fdt, new_fdt);
#ifdef CONFIG_CGROUP_FILES #ifdef CONFIG_CGROUP_FILES
if (!files_cgroup_enabled())
return newf;
spin_lock(&newf->file_lock); spin_lock(&newf->file_lock);
if (!files_cgroup_alloc_fd(newf, files_cgroup_count_fds(newf))) { if (!files_cgroup_alloc_fd(newf, files_cgroup_count_fds(newf))) {
spin_unlock(&newf->file_lock); spin_unlock(&newf->file_lock);
...@@ -398,7 +401,8 @@ struct files_struct *dup_fd(struct files_struct *oldf, unsigned int max_fds, int ...@@ -398,7 +401,8 @@ struct files_struct *dup_fd(struct files_struct *oldf, unsigned int max_fds, int
out_release: out_release:
#ifdef CONFIG_CGROUP_FILES #ifdef CONFIG_CGROUP_FILES
files_cgroup_remove(newf); if (files_cgroup_enabled())
files_cgroup_remove(newf);
#endif #endif
kmem_cache_free(files_cachep, newf); kmem_cache_free(files_cachep, newf);
out: out:
...@@ -426,7 +430,8 @@ static struct fdtable *close_files(struct files_struct * files) ...@@ -426,7 +430,8 @@ static struct fdtable *close_files(struct files_struct * files)
struct file * file = xchg(&fdt->fd[i], NULL); struct file * file = xchg(&fdt->fd[i], NULL);
if (file) { if (file) {
#ifdef CONFIG_CGROUP_FILES #ifdef CONFIG_CGROUP_FILES
files_cgroup_unalloc_fd(files, 1); if (files_cgroup_enabled())
files_cgroup_unalloc_fd(files, 1);
#endif #endif
filp_close(file, files); filp_close(file, files);
cond_resched(); cond_resched();
...@@ -437,7 +442,8 @@ static struct fdtable *close_files(struct files_struct * files) ...@@ -437,7 +442,8 @@ static struct fdtable *close_files(struct files_struct * files)
} }
} }
#ifdef CONFIG_CGROUP_FILES #ifdef CONFIG_CGROUP_FILES
files_cgroup_remove(files); if (files_cgroup_enabled())
files_cgroup_remove(files);
#endif #endif
return fdt; return fdt;
...@@ -559,7 +565,7 @@ int __alloc_fd(struct files_struct *files, ...@@ -559,7 +565,7 @@ int __alloc_fd(struct files_struct *files,
if (error) if (error)
goto repeat; goto repeat;
#ifdef CONFIG_CGROUP_FILES #ifdef CONFIG_CGROUP_FILES
if (files_cgroup_alloc_fd(files, 1)) { if (files_cgroup_enabled() && files_cgroup_alloc_fd(files, 1)) {
error = -EMFILE; error = -EMFILE;
goto out; goto out;
} }
...@@ -607,7 +613,7 @@ static void __put_unused_fd(struct files_struct *files, unsigned int fd) ...@@ -607,7 +613,7 @@ static void __put_unused_fd(struct files_struct *files, unsigned int fd)
{ {
struct fdtable *fdt = files_fdtable(files); struct fdtable *fdt = files_fdtable(files);
#ifdef CONFIG_CGROUP_FILES #ifdef CONFIG_CGROUP_FILES
if (test_bit(fd, fdt->open_fds)) if (files_cgroup_enabled() && test_bit(fd, fdt->open_fds))
files_cgroup_unalloc_fd(files, 1); files_cgroup_unalloc_fd(files, 1);
#endif #endif
__clear_open_fd(fd, fdt); __clear_open_fd(fd, fdt);
...@@ -1041,7 +1047,8 @@ __releases(&files->file_lock) ...@@ -1041,7 +1047,8 @@ __releases(&files->file_lock)
goto out; goto out;
} }
#ifdef CONFIG_CGROUP_FILES #ifdef CONFIG_CGROUP_FILES
if (!tofree && files_cgroup_alloc_fd(files, 1)) { if (files_cgroup_enabled() &&
!tofree && files_cgroup_alloc_fd(files, 1)) {
err = -EMFILE; err = -EMFILE;
goto out; goto out;
} }
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#define _LINUX_FILESCONTROL_H #define _LINUX_FILESCONTROL_H
#include <linux/fdtable.h> #include <linux/fdtable.h>
#include <linux/cgroup.h>
#ifdef CONFIG_CGROUP_FILES #ifdef CONFIG_CGROUP_FILES
...@@ -30,5 +31,10 @@ extern struct files_struct init_files; ...@@ -30,5 +31,10 @@ extern struct files_struct init_files;
void files_cgroup_assign(struct files_struct *files); void files_cgroup_assign(struct files_struct *files);
void files_cgroup_remove(struct files_struct *files); void files_cgroup_remove(struct files_struct *files);
static inline bool files_cgroup_enabled(void)
{
return cgroup_subsys_enabled(files_cgrp_subsys);
}
#endif /* CONFIG_CGROUP_FILES */ #endif /* CONFIG_CGROUP_FILES */
#endif /* _LINUX_FILESCONTROL_H */ #endif /* _LINUX_FILESCONTROL_H */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册