[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f6gjouakla3aivcersitnmlmcjel3kl5w3ynatq6qgmpcyddke@pzu2l3m3vmlk>
Date: Fri, 29 Aug 2025 11:39:15 -0400
From: "Liam R. Howlett" <Liam.Howlett@...cle.com>
To: Linus Walleij <linus.walleij@...aro.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>, Ingo Molnar <mingo@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Juri Lelli <juri.lelli@...hat.com>,
Vincent Guittot <vincent.guittot@...aro.org>,
Dietmar Eggemann <dietmar.eggemann@....com>,
Steven Rostedt <rostedt@...dmis.org>, Ben Segall <bsegall@...gle.com>,
Mel Gorman <mgorman@...e.de>, Valentin Schneider <vschneid@...hat.com>,
Kees Cook <kees@...nel.org>, David Hildenbrand <david@...hat.com>,
Lorenzo Stoakes <lorenzo.stoakes@...cle.com>,
Vlastimil Babka <vbabka@...e.cz>, Mike Rapoport <rppt@...nel.org>,
Suren Baghdasaryan <surenb@...gle.com>, Michal Hocko <mhocko@...e.com>,
Pasha Tatashin <pasha.tatashin@...een.com>,
linux-kernel@...r.kernel.org, linux-mm@...ck.org
Subject: Re: [PATCH 1/2] fork: check charging success before zeroing stack
* Linus Walleij <linus.walleij@...aro.org> [250829 07:44]:
> From: Pasha Tatashin <pasha.tatashin@...een.com>
>
> No need to do zero cached stack if memcg charge fails, so move the
> charging attempt before the memset operation.
>
> Signed-off-by: Pasha Tatashin <pasha.tatashin@...een.com>
> Link: https://lore.kernel.org/20240311164638.2015063-6-pasha.tatashin@soleen.com
> Signed-off-by: Linus Walleij <linus.walleij@...aro.org>
Reviewed-by: Liam R. Howlett <Liam.Howlett@...cle.com>
> ---
> kernel/fork.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/kernel/fork.c b/kernel/fork.c
> index af673856499dcaa35e135a9e8042ef28d5c5370d..2a5b7a5fa09b1f3a42473cf44a1316ec8b3b31d0 100644
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -290,6 +290,11 @@ static int alloc_thread_stack_node(struct task_struct *tsk, int node)
> if (!vm_area)
> continue;
>
> + if (memcg_charge_kernel_stack(vm_area)) {
> + vfree(vm_area->addr);
> + return -ENOMEM;
> + }
> +
> /* Reset stack metadata. */
> kasan_unpoison_range(vm_area->addr, THREAD_SIZE);
>
> @@ -298,11 +303,6 @@ static int alloc_thread_stack_node(struct task_struct *tsk, int node)
> /* Clear stale pointers from reused stack. */
> memset(stack, 0, THREAD_SIZE);
>
> - if (memcg_charge_kernel_stack(vm_area)) {
> - vfree(vm_area->addr);
> - return -ENOMEM;
> - }
> -
> tsk->stack_vm_area = vm_area;
> tsk->stack = stack;
> return 0;
>
> --
> 2.50.1
>
Powered by blists - more mailing lists