linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Christophe Leroy (CS GROUP)" <chleroy@kernel.org>
To: Linus Walleij <linusw@kernel.org>, Kees Cook <kees@kernel.org>,
	Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	Valentin Schneider <vschneid@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	David Hildenbrand <david@kernel.org>,
	Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
	"Liam R. Howlett" <Liam.Howlett@oracle.com>,
	Vlastimil Babka <vbabka@suse.cz>, Mike Rapoport <rppt@kernel.org>,
	Suren Baghdasaryan <surenb@google.com>,
	Michal Hocko <mhocko@suse.com>
Cc: linux-mm@kvack.org, Mateusz Guzik <mjguzik@gmail.com>,
	Pasha Tatashin <pasha.tatashin@soleen.com>
Subject: Re: [PATCH] fork: zero vmap stack using clear_pages() instead of memset()
Date: Fri, 6 Mar 2026 14:19:32 +0100	[thread overview]
Message-ID: <fb9bd5ef-09b1-4c84-8435-d595f2154331@kernel.org> (raw)
In-Reply-To: <f861cc00-2b41-4112-bba4-810388a5747b@kernel.org>



Le 06/03/2026 à 14:16, Christophe Leroy (CS GROUP) a écrit :
> 
> 
> Le 24/02/2026 à 11:26, Linus Walleij a écrit :
>> After the introduction of clear_pages() we exploit the
>> fact that the process vm_area is allocated in contiguous
>> pages to just clear them all in one swift operation.
>>
>> Suggested-by: Mateusz Guzik <mjguzik@gmail.com>
>> Link: https://eur01.safelinks.protection.outlook.com/? 
>> url=https%3A%2F%2Flore.kernel.org%2Flinux- 
>> mm%2Fdpnwsp7dl4535rd7qmszanw6u5an2p74uxfex4dh53frpb7pu3%402bnjjavjrepe%2F&data=05%7C02%7Cchristophe.leroy%40csgroup.eu%7C5eca287345d5408b59ce08de738f41a2%7C8b87af7d86474dc78df45f69a2011bb5%7C0%7C0%7C639075256284265137%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=PrUINapvx0%2BJH9Dl9%2F2bRfUJmrvPCxwk%2FxGll6rgle8%3D&reserved=0
>> Suggested-by: Pasha Tatashin <pasha.tatashin@soleen.com>
>> Link: https://eur01.safelinks.protection.outlook.com/? 
>> url=https%3A%2F%2Flore.kernel.org%2F20240311164638.2015063-7- 
>> pasha.tatashin%40soleen.com&data=05%7C02%7Cchristophe.leroy%40csgroup.eu%7C5eca287345d5408b59ce08de738f41a2%7C8b87af7d86474dc78df45f69a2011bb5%7C0%7C0%7C639075256284308057%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=J2HT3AP4aZTX0Va0XE0taOtnA9GsETKFY1mWhrHBQbg%3D&reserved=0
>> Signed-off-by: Linus Walleij <linusw@kernel.org>
>> ---
>>   kernel/fork.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/kernel/fork.c b/kernel/fork.c
>> index e832da9d15a4..88d78ccef245 100644
>> --- a/kernel/fork.c
>> +++ b/kernel/fork.c
>> @@ -345,7 +345,7 @@ static int alloc_thread_stack_node(struct 
>> task_struct *tsk, int node)
>>           stack = kasan_reset_tag(vm_area->addr);
>>           /* Clear stale pointers from reused stack. */
>> -        memset(stack, 0, THREAD_SIZE);
>> +        clear_pages(vm_area->addr, vm_area->nr_pages);
> 
> THREAD_SIZE can be smaller that PAGE_SIZE, how do you deal with that ?
> 
> For instance on powerpc/64 when PAGE_SIZE is 64k, while the default 
> THREAD_SHIFT is 14, leading to THREAD_SIZE being 16k
> 
> Or on powerpc/32 when PAGE_SIZE is 16k, while the default THREAD_SHIFT 
> is 13, leading to THREAD_SIZE being 8k.
> 

Oops sorry, I missed it was only for VMAP_STACK, in that case stack size 
is at least one page.

Christophe

> Christophe
> 
> 
> 
>>           tsk->stack_vm_area = vm_area;
>>           tsk->stack = stack;
>>
>> ---
>> base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f
>> change-id: 20260224-mm-fork-clear-pages-ae7c52d12a93
>>
>> Best regards,
> 



      reply	other threads:[~2026-03-06 13:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-24 10:26 Linus Walleij
2026-02-24 13:21 ` David Hildenbrand (Arm)
2026-02-24 13:53   ` Linus Walleij
2026-02-24 14:26     ` David Hildenbrand (Arm)
2026-02-25  7:53       ` Ankur Arora
2026-03-06 12:00 ` Lorenzo Stoakes (Oracle)
2026-03-06 13:16 ` Christophe Leroy (CS GROUP)
2026-03-06 13:19   ` Christophe Leroy (CS GROUP) [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fb9bd5ef-09b1-4c84-8435-d595f2154331@kernel.org \
    --to=chleroy@kernel.org \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=bsegall@google.com \
    --cc=david@kernel.org \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=kees@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=mgorman@suse.de \
    --cc=mhocko@suse.com \
    --cc=mingo@redhat.com \
    --cc=mjguzik@gmail.com \
    --cc=pasha.tatashin@soleen.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=rppt@kernel.org \
    --cc=surenb@google.com \
    --cc=vbabka@suse.cz \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox