Skip to content
This repository was archived by the owner on Oct 13, 2020. It is now read-only.

Commit fb13977

Browse files
committed
kernel: disable CONFIG_MEMCG_KMEM
This causes kernel memory leaks when using versions of `runc` that unconditionally enable per-cgroup kernel memory resource accounting, leading to systems becoming unusable when many containers were created. The links below mention actual leaks of cgroups as well. However, in testing this appears to be fixed in more recent RedHat/CentOS kernel versions. We disable the feature in the kernel configuration, which however changes its ABI. See: https://docs.google.com/document/d/1892PZs2ZdV4_JsSoFwC6WfoOHqKVirFci9r_6NAJzUU/edit?usp=sharing See: moby/moby#29638 (comment) See: kubernetes/kubernetes#61937 See: opencontainers/runc#1725 See: https://bugzilla.redhat.com/show_bug.cgi?id=1507149 See: https://bugs.schedmd.com/show_bug.cgi?id=5082#c28
1 parent 4de91ed commit fb13977

File tree

5 files changed

+51
-4
lines changed

5 files changed

+51
-4
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@ default: .rpms
3232
-v $(PWD)/SRPMS:/home/build/kernel/SRPMS:Z \
3333
--tmpfs /var/tmp \
3434
--tmpfs /tmp \
35-
"$(CONTAINER)"
35+
"$(CONTAINER)" \
36+
--without kabichk
3637
touch $@
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
From e58aeb67c287c2eed59c0b4bdcd8fdf54ee256b0 Mon Sep 17 00:00:00 2001
2+
From: Nicolas Trangez <ikke@nicolast.be>
3+
Date: Wed, 9 Oct 2019 13:44:21 +0000
4+
Subject: [PATCH] mm: fix compilation with `CONFIG_MEMCG_KMEM` disabled
5+
6+
The `memcg_limit_mutex` mutex is used in code *not* protected by
7+
`CONFIG_MEMCG_KMEM`, so if we disable the feature, its declaration
8+
must go outside the `#ifdef`ed section.
9+
10+
See: https://docs.google.com/document/d/1892PZs2ZdV4_JsSoFwC6WfoOHqKVirFci9r_6NAJzUU/edit?usp=sharing
11+
12+
Signed-off-by: Nicolas Trangez <nicolas.trangez@scality.com>
13+
---
14+
mm/memcontrol.c | 4 ++--
15+
1 file changed, 2 insertions(+), 2 deletions(-)
16+
17+
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
18+
index 16fe560..d8efcd2 100644
19+
--- a/mm/memcontrol.c
20+
+++ b/mm/memcontrol.c
21+
@@ -2995,6 +2995,8 @@ static void __mem_cgroup_commit_charge(struct mem_cgroup *memcg,
22+
memcg_check_events(memcg, page);
23+
}
24+
25+
+static DEFINE_MUTEX(memcg_limit_mutex);
26+
+
27+
#ifdef CONFIG_MEMCG_KMEM
28+
/*
29+
* The memcg_slab_mutex is held whenever a per memcg kmem cache is created or
30+
@@ -3375,8 +3377,6 @@ static inline void memcg_resume_kmem_account(void)
31+
current->memcg_kmem_skip_account--;
32+
}
33+
34+
-static DEFINE_MUTEX(memcg_limit_mutex);
35+
-
36+
int __kmem_cache_destroy_memcg_children(struct kmem_cache *s)
37+
{
38+
struct kmem_cache *c;
39+
--
40+
1.8.3.1
41+

SOURCES/kernel-3.10.0-x86_64-debug.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ CONFIG_PAGE_COUNTER=y
168168
CONFIG_MEMCG=y
169169
CONFIG_MEMCG_SWAP=y
170170
CONFIG_MEMCG_SWAP_ENABLED=y
171-
CONFIG_MEMCG_KMEM=y
171+
CONFIG_MEMCG_KMEM=n
172172
CONFIG_CGROUP_HUGETLB=y
173173
CONFIG_CGROUP_PERF=y
174174
CONFIG_CGROUP_SCHED=y

SOURCES/kernel-3.10.0-x86_64.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ CONFIG_PAGE_COUNTER=y
168168
CONFIG_MEMCG=y
169169
CONFIG_MEMCG_SWAP=y
170170
CONFIG_MEMCG_SWAP_ENABLED=y
171-
CONFIG_MEMCG_KMEM=y
171+
CONFIG_MEMCG_KMEM=n
172172
CONFIG_CGROUP_HUGETLB=y
173173
CONFIG_CGROUP_PERF=y
174174
CONFIG_CGROUP_SCHED=y

SPECS/kernel.spec

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Summary: The Linux kernel
55

66
%define dist .el7
77

8-
%define buildid .1.scality
8+
%define buildid .2.scality
99

1010
# For a kernel released for public testing, released_kernel should be 1.
1111
# For internal testing builds during development, it should be 0.
@@ -447,6 +447,7 @@ Source2001: cpupower.config
447447
Source9999: lastcommit.stat
448448
%endif
449449

450+
Patch40000: 0001-mm-fix-compilation-with-CONFIG_MEMCG_KMEM-disabled.patch
450451
# empty final patch to facilitate testing of kernel patches
451452
Patch999999: linux-kernel-test.patch
452453

@@ -788,6 +789,7 @@ cd linux-%{KVRA}
788789
# Drop some necessary files from the source dir into the buildroot
789790
cp $RPM_SOURCE_DIR/kernel-%{version}-*.config .
790791

792+
ApplyOptionalPatch 0001-mm-fix-compilation-with-CONFIG_MEMCG_KMEM-disabled.patch
791793
ApplyOptionalPatch linux-kernel-test.patch
792794

793795
# Any further pre-build tree manipulations happen here.
@@ -1769,6 +1771,9 @@ fi
17691771
%kernel_variant_files %{with_kdump} kdump
17701772

17711773
%changelog
1774+
* Wed Oct 09 2019 Nicolas Trangez <nicolas.trangez@scality.com> [3.10.0-1062.1.2.el7.2.scality]
1775+
- [mm] disable CONFIG_MEMCG_KMEM
1776+
17721777
* Wed Oct 09 2019 Nicolas Trangez <nicolas.trangez@scality.com> [3.10.0-1062.1.2.el7.1.scality]
17731778
- build: don't require 'SOURCES' to be writable
17741779

0 commit comments

Comments
 (0)