From: Chunguang Xu <redacted>
Since the global open files are limited, in order to avoid the
abnormal behavior of some containers from generating too many
files, causing other containers to be unavailable, we need to
limit the open files of some containers.
v2: fix compile error while CONFIG_CGROUP_MISC not set.
Signed-off-by: Chunguang Xu <redacted>
Reported-by: kernel test robot <redacted>
---
fs/file_table.c | 28 ++++++++++++++++++++++++++--
include/linux/fs.h | 4 +++-
include/linux/misc_cgroup.h | 1 +
kernel/cgroup/misc.c | 1 +
4 files changed, 31 insertions(+), 3 deletions(-)
@@ -947,7 +947,9 @@ struct file {#endif/* needed for tty driver, and maybe others */void*private_data;-+#ifdef CONFIG_CGROUP_MISC+structcgroup_subsys_state*f_css;+#endif#ifdef CONFIG_EPOLL/* Used by fs/eventpoll.c to link all the hooks to this file */structhlist_head*f_ep;
From: Chunguang Xu <redacted>
Since the upper-level logic will constantly retry when it fails, in
high-stress scenarios, a large number of failure logs may affect
performance. Therefore, we can replace it with the failcnt counter.
Signed-off-by: Chunguang Xu <redacted>
---
kernel/cgroup/misc.c | 2 --
1 file changed, 2 deletions(-)
@@ -159,8 +159,6 @@ int misc_cg_try_charge(enum misc_res_type type, struct misc_cg *cg,if(new_usage>READ_ONCE(res->max)||new_usage>READ_ONCE(misc_res_capacity[type])){if(!res->failed){-pr_info("cgroup: charge rejected by the misc controller for %s resource in ",-misc_res_name[type]);pr_cont_cgroup_path(i->css.cgroup);pr_cont("\n");res->failed=true;
On Thu, Jul 22, 2021 at 11:20:17PM +0800, brookxu wrote:
From: Chunguang Xu <redacted>
Since the global open files are limited, in order to avoid the
abnormal behavior of some containers from generating too many
files, causing other containers to be unavailable, we need to
limit the open files of some containers.
v2: fix compile error while CONFIG_CGROUP_MISC not set.
Signed-off-by: Chunguang Xu <redacted>
Reported-by: kernel test robot <redacted>
This is different from pid in that there's no actual limit on how many open
files there can be in the system other than the total amount of available
memory. I don't see why this would need a separate limit outside of memory
control. A couple machines I looked at all have file-max at LONG_MAX by
default too.
Thanks.
--
tejun
Thanks for your time.
Tejun Heo wrote on 2021/7/27 5:27:
On Thu, Jul 22, 2021 at 11:20:17PM +0800, brookxu wrote:
quoted
From: Chunguang Xu <redacted>
Since the global open files are limited, in order to avoid the
abnormal behavior of some containers from generating too many
files, causing other containers to be unavailable, we need to
limit the open files of some containers.
v2: fix compile error while CONFIG_CGROUP_MISC not set.
Signed-off-by: Chunguang Xu <redacted>
Reported-by: kernel test robot <redacted>
This is different from pid in that there's no actual limit on how many open
files there can be in the system other than the total amount of available
memory. I don't see why this would need a separate limit outside of memory
control. A couple machines I looked at all have file-max at LONG_MAX by
default too.
According to files_maxfiles_init(), we only allow about 10% of free memory to
create filps, and each filp occupies about 1K of cache. In this way, on a 16G
memory machine, the maximum usable filp is about 1,604,644. In general
scenarios, this may not be a big problem, but if the task is abnormal, it will
very likely become a bottleneck and affect other modules.
Hello,
On Tue, Jul 27, 2021 at 11:18:00AM +0800, brookxu wrote:
According to files_maxfiles_init(), we only allow about 10% of free memory to
create filps, and each filp occupies about 1K of cache. In this way, on a 16G
memory machine, the maximum usable filp is about 1,604,644. In general
scenarios, this may not be a big problem, but if the task is abnormal, it will
very likely become a bottleneck and affect other modules.
Yeah but that can be configured trivially through sysfs. The reason why the
default limit is lowered is because we wanna prevent a part of system to
consume all the memory through fds. With cgroups, we already have that
protection and at least some systems already configure file-max to maximum,
so I don't see a point in adding another interface to subdivide the
artificial limit.
Thanks.
--
tejun
Hello,
On Tue, Jul 27, 2021 at 11:18:00AM +0800, brookxu wrote:
quoted
According to files_maxfiles_init(), we only allow about 10% of free memory to
create filps, and each filp occupies about 1K of cache. In this way, on a 16G
memory machine, the maximum usable filp is about 1,604,644. In general
scenarios, this may not be a big problem, but if the task is abnormal, it will
very likely become a bottleneck and affect other modules.
Yeah but that can be configured trivially through sysfs. The reason why the
default limit is lowered is because we wanna prevent a part of system to
consume all the memory through fds. With cgroups, we already have that
protection and at least some systems already configure file-max to maximum,
so I don't see a point in adding another interface to subdivide the
artificial limit.
Yeah we can adjust file-max through sysctl, but in many cases we adjust it according
to the actual load of the machine, not for abnormal tasks. Another problem is that in
practical applications, kmem_limit will cause some minor problems. In many cases,
kmem_limit is disabled. Limit_in_bytes mainly counts user pages and pagecache, which
may cause files_cache to be out of control. In this case, if file-max is set to MAX,
we may have a risk in the abnormal scene, which prevents us from recovering from the
abnormal scene. Maybe I missed something.
On Wed, Jul 28, 2021 at 11:17:08AM +0800, brookxu wrote:
Yeah we can adjust file-max through sysctl, but in many cases we adjust it according
to the actual load of the machine, not for abnormal tasks. Another problem is that in
practical applications, kmem_limit will cause some minor problems. In many cases,
kmem_limit is disabled. Limit_in_bytes mainly counts user pages and pagecache, which
may cause files_cache to be out of control. In this case, if file-max is set to MAX,
we may have a risk in the abnormal scene, which prevents us from recovering from the
abnormal scene. Maybe I missed something.
Kmem control is always on in cgroup2 and has been in wide production use for
years now. If there are problems with it, we need to fix them. That really
doesn't justify adding another feature.
Thanks.
--
tejun
On Wed, Jul 28, 2021 at 11:17:08AM +0800, brookxu wrote:
quoted
Yeah we can adjust file-max through sysctl, but in many cases we adjust it according
to the actual load of the machine, not for abnormal tasks. Another problem is that in
practical applications, kmem_limit will cause some minor problems. In many cases,
kmem_limit is disabled. Limit_in_bytes mainly counts user pages and pagecache, which
may cause files_cache to be out of control. In this case, if file-max is set to MAX,
we may have a risk in the abnormal scene, which prevents us from recovering from the
abnormal scene. Maybe I missed something.
Kmem control is always on in cgroup2 and has been in wide production use for
years now. If there are problems with it, we need to fix them. That really
doesn't justify adding another feature.
But considering stability issues(k8s), There are still many production environments use
cgroup v1 without kmem. If kmem is enabled, due to the relatively large granularity
of kmem, this feature can also prevent the abnormal open behavior from making the entire
container unavailable? but I currently do not have this scenario.
Thanks for your time.
Hello,
On Wed, Jul 28, 2021 at 05:47:05PM +0800, brookxu wrote:
But considering stability issues(k8s), There are still many production environments use
cgroup v1 without kmem. If kmem is enabled, due to the relatively large granularity
of kmem, this feature can also prevent the abnormal open behavior from making the entire
container unavailable? but I currently do not have this scenario.
Now we are repeating the same points. This simply doesn't justify adding a
user-facing feature that we have to maintain for eternity.
Thanks.
--
tejun
Thanks for your time.
Tejun Heo wrote on 2021/7/28 11:38 下午:
Hello,
On Wed, Jul 28, 2021 at 05:47:05PM +0800, brookxu wrote:
quoted
But considering stability issues(k8s), There are still many production environments use
cgroup v1 without kmem. If kmem is enabled, due to the relatively large granularity
of kmem, this feature can also prevent the abnormal open behavior from making the entire
container unavailable? but I currently do not have this scenario.
Now we are repeating the same points. This simply doesn't justify adding a
user-facing feature that we have to maintain for eternity.