From: Greg Kroah-Hartman Date: Wed, 4 Oct 2023 17:10:31 +0000 (+0200) Subject: 6.1-stable patches X-Git-Tag: v6.5.6~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b08db89a536cc1fb4f4ff3abdc1554cf4399a31b;p=thirdparty%2Fkernel%2Fstable-queue.git 6.1-stable patches added patches: memcg-drop-kmem.limit_in_bytes.patch mm-memcg-reconsider-kmem.limit_in_bytes-deprecation.patch --- diff --git a/queue-6.1/memcg-drop-kmem.limit_in_bytes.patch b/queue-6.1/memcg-drop-kmem.limit_in_bytes.patch new file mode 100644 index 00000000000..752bee8e760 --- /dev/null +++ b/queue-6.1/memcg-drop-kmem.limit_in_bytes.patch @@ -0,0 +1,86 @@ +From 86327e8eb94c52eca4f93cfece2e29d1bf52acbf Mon Sep 17 00:00:00 2001 +From: Michal Hocko +Date: Tue, 4 Jul 2023 13:52:40 +0200 +Subject: memcg: drop kmem.limit_in_bytes + +From: Michal Hocko + +commit 86327e8eb94c52eca4f93cfece2e29d1bf52acbf upstream. + +kmem.limit_in_bytes (v1 way to limit kernel memory usage) has been +deprecated since 58056f77502f ("memcg, kmem: further deprecate +kmem.limit_in_bytes") merged in 5.16. We haven't heard about any serious +users since then but it seems that the mere presence of the file is +causing more harm thatn good. We (SUSE) have had several bug reports from +customers where Docker based containers started to fail because a write to +kmem.limit_in_bytes has failed. + +This was unexpected because runc code only expects ENOENT (kmem disabled) +or EBUSY (tasks already running within cgroup). So a new error code was +unexpected and the whole container startup failed. This has been later +addressed by +https://github.com/opencontainers/runc/commit/52390d68040637dfc77f9fda6bbe70952423d380 +so current Docker runtimes do not suffer from the problem anymore. There +are still older version of Docker in use and likely hard to get rid of +completely. + +Address this by wiping out the file completely and effectively get back to +pre 4.5 era and CONFIG_MEMCG_KMEM=n configuration. + +I would recommend backporting to stable trees which have picked up +58056f77502f ("memcg, kmem: further deprecate kmem.limit_in_bytes"). + +[mhocko@suse.com: restore _KMEM switch case] + Link: https://lkml.kernel.org/r/ZKe5wxdbvPi5Cwd7@dhcp22.suse.cz +Link: https://lkml.kernel.org/r/20230704115240.14672-1-mhocko@kernel.org +Signed-off-by: Michal Hocko +Acked-by: Shakeel Butt +Acked-by: Johannes Weiner +Acked-by: Roman Gushchin +Cc: Muchun Song +Cc: Tejun Heo +Cc: +Signed-off-by: Andrew Morton +Signed-off-by: Greg Kroah-Hartman +--- + Documentation/admin-guide/cgroup-v1/memory.rst | 2 -- + mm/memcontrol.c | 10 ---------- + 2 files changed, 12 deletions(-) + +--- a/Documentation/admin-guide/cgroup-v1/memory.rst ++++ b/Documentation/admin-guide/cgroup-v1/memory.rst +@@ -91,8 +91,6 @@ Brief summary of control files. + memory.oom_control set/show oom controls. + memory.numa_stat show the number of memory usage per numa + node +- memory.kmem.limit_in_bytes This knob is deprecated and writing to +- it will return -ENOTSUPP. + memory.kmem.usage_in_bytes show current kernel memory allocation + memory.kmem.failcnt show the number of kernel memory usage + hits limits +--- a/mm/memcontrol.c ++++ b/mm/memcontrol.c +@@ -3841,10 +3841,6 @@ static ssize_t mem_cgroup_write(struct k + case _MEMSWAP: + ret = mem_cgroup_resize_max(memcg, nr_pages, true); + break; +- case _KMEM: +- /* kmem.limit_in_bytes is deprecated. */ +- ret = -EOPNOTSUPP; +- break; + case _TCP: + ret = memcg_update_tcp_max(memcg, nr_pages); + break; +@@ -5056,12 +5052,6 @@ static struct cftype mem_cgroup_legacy_f + }, + #endif + { +- .name = "kmem.limit_in_bytes", +- .private = MEMFILE_PRIVATE(_KMEM, RES_LIMIT), +- .write = mem_cgroup_write, +- .read_u64 = mem_cgroup_read_u64, +- }, +- { + .name = "kmem.usage_in_bytes", + .private = MEMFILE_PRIVATE(_KMEM, RES_USAGE), + .read_u64 = mem_cgroup_read_u64, diff --git a/queue-6.1/mm-memcg-reconsider-kmem.limit_in_bytes-deprecation.patch b/queue-6.1/mm-memcg-reconsider-kmem.limit_in_bytes-deprecation.patch new file mode 100644 index 00000000000..b4f5b8577af --- /dev/null +++ b/queue-6.1/mm-memcg-reconsider-kmem.limit_in_bytes-deprecation.patch @@ -0,0 +1,101 @@ +From 4597648fddeadef5877610d693af11906aa666ac Mon Sep 17 00:00:00 2001 +From: Michal Hocko +Date: Thu, 21 Sep 2023 09:38:29 +0200 +Subject: mm, memcg: reconsider kmem.limit_in_bytes deprecation + +From: Michal Hocko + +commit 4597648fddeadef5877610d693af11906aa666ac upstream. + +This reverts commits 86327e8eb94c ("memcg: drop kmem.limit_in_bytes") and +partially reverts 58056f77502f ("memcg, kmem: further deprecate +kmem.limit_in_bytes") which have incrementally removed support for the +kernel memory accounting hard limit. Unfortunately it has turned out that +there is still userspace depending on the existence of +memory.kmem.limit_in_bytes [1]. The underlying functionality is not +really required but the non-existent file just confuses the userspace +which fails in the result. The patch to fix this on the userspace side +has been submitted but it is hard to predict how it will propagate through +the maze of 3rd party consumers of the software. + +Now, reverting alone 86327e8eb94c is not an option because there is +another set of userspace which cannot cope with ENOTSUPP returned when +writing to the file. Therefore we have to go and revisit 58056f77502f as +well. There are two ways to go ahead. Either we give up on the +deprecation and fully revert 58056f77502f as well or we can keep +kmem.limit_in_bytes but make the write a noop and warn about the fact. +This should work for both known breaking workloads which depend on the +existence but do not depend on the hard limit enforcement. + +Note to backporters to stable trees. a8c49af3be5f ("memcg: add per-memcg +total kernel memory stat") introduced in 4.18 has added memcg_account_kmem +so the accounting is not done by obj_cgroup_charge_pages directly for v1 +anymore. Prior kernels need to add it explicitly (thanks to Johannes for +pointing this out). + +[akpm@linux-foundation.org: fix build - remove unused local] +Link: http://lkml.kernel.org/r/20230920081101.GA12096@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net [1] +Link: https://lkml.kernel.org/r/ZRE5VJozPZt9bRPy@dhcp22.suse.cz +Fixes: 86327e8eb94c ("memcg: drop kmem.limit_in_bytes") +Fixes: 58056f77502f ("memcg, kmem: further deprecate kmem.limit_in_bytes") +Signed-off-by: Michal Hocko +Acked-by: Shakeel Butt +Acked-by: Johannes Weiner +Cc: Greg Kroah-Hartman +Cc: Jeremi Piotrowski +Cc: Muchun Song +Cc: Roman Gushchin +Cc: Tejun heo +Cc: +Signed-off-by: Andrew Morton +Signed-off-by: Greg Kroah-Hartman +--- + Documentation/admin-guide/cgroup-v1/memory.rst | 7 +++++++ + mm/memcontrol.c | 13 +++++++++++++ + 2 files changed, 20 insertions(+) + +--- a/Documentation/admin-guide/cgroup-v1/memory.rst ++++ b/Documentation/admin-guide/cgroup-v1/memory.rst +@@ -91,6 +91,13 @@ Brief summary of control files. + memory.oom_control set/show oom controls. + memory.numa_stat show the number of memory usage per numa + node ++ memory.kmem.limit_in_bytes Deprecated knob to set and read the kernel ++ memory hard limit. Kernel hard limit is not ++ supported since 5.16. Writing any value to ++ do file will not have any effect same as if ++ nokmem kernel parameter was specified. ++ Kernel memory is still charged and reported ++ by memory.kmem.usage_in_bytes. + memory.kmem.usage_in_bytes show current kernel memory allocation + memory.kmem.failcnt show the number of kernel memory usage + hits limits +--- a/mm/memcontrol.c ++++ b/mm/memcontrol.c +@@ -3841,6 +3841,13 @@ static ssize_t mem_cgroup_write(struct k + case _MEMSWAP: + ret = mem_cgroup_resize_max(memcg, nr_pages, true); + break; ++ case _KMEM: ++ pr_warn_once("kmem.limit_in_bytes is deprecated and will be removed. " ++ "Writing any value to this file has no effect. " ++ "Please report your usecase to linux-mm@kvack.org if you " ++ "depend on this functionality.\n"); ++ ret = 0; ++ break; + case _TCP: + ret = memcg_update_tcp_max(memcg, nr_pages); + break; +@@ -5052,6 +5059,12 @@ static struct cftype mem_cgroup_legacy_f + }, + #endif + { ++ .name = "kmem.limit_in_bytes", ++ .private = MEMFILE_PRIVATE(_KMEM, RES_LIMIT), ++ .write = mem_cgroup_write, ++ .read_u64 = mem_cgroup_read_u64, ++ }, ++ { + .name = "kmem.usage_in_bytes", + .private = MEMFILE_PRIVATE(_KMEM, RES_USAGE), + .read_u64 = mem_cgroup_read_u64, diff --git a/queue-6.1/series b/queue-6.1/series index 27360671f74..5ca372c7b5c 100644 --- a/queue-6.1/series +++ b/queue-6.1/series @@ -254,3 +254,5 @@ power-supply-ab8500-set-typing-and-props.patch fs-binfmt_elf_efpic-fix-personality-for-elf-fdpic.patch drm-amdkfd-use-gpu_offset-for-user-queue-s-wptr.patch drm-meson-fix-memory-leak-on-hpd_notify-callback.patch +memcg-drop-kmem.limit_in_bytes.patch +mm-memcg-reconsider-kmem.limit_in_bytes-deprecation.patch