* [PATCH] mm: memcontrol-v1: use nofail allocations for soft limit trees
@ 2026-06-08 6:36 Ruoyu Wang
2026-06-08 8:02 ` Michal Hocko
0 siblings, 1 reply; 3+ messages in thread
From: Ruoyu Wang @ 2026-06-08 6:36 UTC (permalink / raw)
To: Johannes Weiner
Cc: Michal Hocko, Roman Gushchin, Shakeel Butt, Muchun Song,
Andrew Morton, cgroups, linux-mm, linux-kernel, Ruoyu Wang
memcg1_init() allocates one soft-limit tree node per NUMA node and
then initializes the returned object. If kzalloc_node() fails, the rb_root
and lock initialization dereference NULL.
The per-node soft-limit tree is required by memcg v1. Use nofail
GFP_KERNEL allocations for these init-time objects so the init path does
not continue without the required tree nodes.
Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
---
mm/memcontrol-v1.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/mm/memcontrol-v1.c b/mm/memcontrol-v1.c
index 433bba9dfe715..3f41a15d8a8cf 100644
--- a/mm/memcontrol-v1.c
+++ b/mm/memcontrol-v1.c
@@ -2246,7 +2246,8 @@ static int __init memcg1_init(void)
for_each_node(node) {
struct mem_cgroup_tree_per_node *rtpn;
- rtpn = kzalloc_node(sizeof(*rtpn), GFP_KERNEL, node);
+ rtpn = kzalloc_node(sizeof(*rtpn), GFP_KERNEL | __GFP_NOFAIL,
+ node);
rtpn->rb_root = RB_ROOT;
rtpn->rb_rightmost = NULL;
--
2.51.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] mm: memcontrol-v1: use nofail allocations for soft limit trees
2026-06-08 6:36 [PATCH] mm: memcontrol-v1: use nofail allocations for soft limit trees Ruoyu Wang
@ 2026-06-08 8:02 ` Michal Hocko
[not found] ` <CAK_7xqyyDqNW1+puMSp2LzxmOKxFUx-UO9uGiDKoL7ZTJ8+3ZQ@mail.gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Michal Hocko @ 2026-06-08 8:02 UTC (permalink / raw)
To: Ruoyu Wang
Cc: Johannes Weiner, Roman Gushchin, Shakeel Butt, Muchun Song,
Andrew Morton, cgroups, linux-mm, linux-kernel
On Mon 08-06-26 14:36:44, Ruoyu Wang wrote:
> memcg1_init() allocates one soft-limit tree node per NUMA node and
> then initializes the returned object. If kzalloc_node() fails, the rb_root
> and lock initialization dereference NULL.
>
> The per-node soft-limit tree is required by memcg v1. Use nofail
> GFP_KERNEL allocations for these init-time objects so the init path does
> not continue without the required tree nodes.
This is an early init code executing in during boot. Have you really
seen this allocation failing?
> Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
> ---
> mm/memcontrol-v1.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/mm/memcontrol-v1.c b/mm/memcontrol-v1.c
> index 433bba9dfe715..3f41a15d8a8cf 100644
> --- a/mm/memcontrol-v1.c
> +++ b/mm/memcontrol-v1.c
> @@ -2246,7 +2246,8 @@ static int __init memcg1_init(void)
> for_each_node(node) {
> struct mem_cgroup_tree_per_node *rtpn;
>
> - rtpn = kzalloc_node(sizeof(*rtpn), GFP_KERNEL, node);
> + rtpn = kzalloc_node(sizeof(*rtpn), GFP_KERNEL | __GFP_NOFAIL,
> + node);
>
> rtpn->rb_root = RB_ROOT;
> rtpn->rb_rightmost = NULL;
> --
> 2.51.0
--
Michal Hocko
SUSE Labs
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-06-08 13:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-08 6:36 [PATCH] mm: memcontrol-v1: use nofail allocations for soft limit trees Ruoyu Wang
2026-06-08 8:02 ` Michal Hocko
[not found] ` <CAK_7xqyyDqNW1+puMSp2LzxmOKxFUx-UO9uGiDKoL7ZTJ8+3ZQ@mail.gmail.com>
2026-06-08 13:29 ` Michal Hocko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox