linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Linus Walleij <linusw@kernel.org>
Cc: 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>,
	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>,
	linux-mm@kvack.org, Mateusz Guzik <mjguzik@gmail.com>,
	Pasha Tatashin <pasha.tatashin@soleen.com>,
	Ankur Arora <ankur.a.arora@oracle.com>
Subject: Re: [PATCH] fork: zero vmap stack using clear_pages() instead of memset()
Date: Tue, 24 Feb 2026 15:26:50 +0100	[thread overview]
Message-ID: <10fb20fc-b379-433d-9a08-cc962ab70480@kernel.org> (raw)
In-Reply-To: <CAD++jLm6iyeFuGoC2zfHDOu6gYdb2L1gsjQhT5a4qS-CBWia9Q@mail.gmail.com>

On 2/24/26 14:53, Linus Walleij wrote:
> On Tue, Feb 24, 2026 at 2:21 PM David Hildenbrand (Arm)
> <david@kernel.org> wrote:
>> On 2/24/26 11:26, Linus Walleij wrote:
> 
>>> 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.
>>
>> The pages are virtually contiguous (vmalloc IIUC), not necessarily
>> physically contiguous. For clear_pages() that should work.
> 
> Yeah that's what I meant with contiguous, sorry.
> 
>>>               /* Clear stale pointers from reused stack. */
>>> -             memset(stack, 0, THREAD_SIZE);
>>> +             clear_pages(vm_area->addr, vm_area->nr_pages);
>>
>> LGTM.
>>
>> Do we have any idea about performance impact etc?
> 
> I have a pending patch for implementing clear_pages() for arm64,
> https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-integrator.git/log/?h=b4/aarch64-clear-pages
> which is in a performance test loop, once I get baseline data from that
> I can test something fork-intensive (hackbench, I guess) with this patch on top.
> 
> So making that patch made me remember this one code site...

I'll note that clear_pages() documents: "When running under preemptible
models this is not a problem. Under cooperatively scheduled models,
however, the caller is expected to limit @npages to no more than
PROCESS_PAGES_NON_PREEMPT_BATCH."

We discussed during review that we should probably move that batching
logic into clear_pages() at some point.

PROCESS_PAGES_NON_PREEMPT_BATCH defaults to 1. I'd assume that handling
3 pages here doesn't make a difference, just pointing it out.

CCing Ankur.

> 
> If someone has a good fork performance test running on x86
> and can give this a spin, it'd be great!

That would be nice :)


-- 
Cheers,

David


      reply	other threads:[~2026-02-24 14:27 UTC|newest]

Thread overview: 4+ 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) [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=10fb20fc-b379-433d-9a08-cc962ab70480@kernel.org \
    --to=david@kernel.org \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=ankur.a.arora@oracle.com \
    --cc=bsegall@google.com \
    --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