From: Linus Walleij <linus.walleij@linaro.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, Pasha Tatashin <pasha.tatashin@soleen.com>
Subject: Re: [PATCH 3/5] fork: Remove assumption that vm_area->nr_pages equals to THREAD_SIZE
Date: Wed, 7 May 2025 14:38:47 +0200 [thread overview]
Message-ID: <CACRpkdYqZ7CPyUuJLsm9KWc103WGMMS-J5vuQC-MWniWT-61Ng@mail.gmail.com> (raw)
In-Reply-To: <20250506185322.cd87ba823030024061b5ae77@linux-foundation.org>
On Wed, May 7, 2025 at 3:53 AM Andrew Morton <akpm@linux-foundation.org> wrote:
> > - BUG_ON(vm->nr_pages != THREAD_SIZE / PAGE_SIZE);
> > -
> > - for (i = 0; i < THREAD_SIZE / PAGE_SIZE; i++) {
> > + for (i = 0; i < vm_area->nr_pages; i++) {
>
> Well, constants are fast and small. I assume this will add a few
> instructions and a bit of runtime overhead?
That is true.
Pashas original patch has a local variable instead of comparing
vm_area->nr_pages, so I went back to that to ascertain we
are not dereferencing the struct on every iteration of the
loop, but will instead use a register.
For this first instance the assignment of that variable should be no
more time consuming than the deleted BUG_ON() dereference so
it is +/- 0.
For the other two instances I like the readability this gives, the
local variable restored there too.
Maybe those two should have also has BUG_ON() guards
actually. vm_area->nr_pages should be the trusted, run-time
value.
I'll resend what I have so you can decide.
Yours,
Linus Walleij
next prev parent reply other threads:[~2025-05-07 12:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-06 7:57 [PATCH 0/5] fork: Page operation cleanups in the fork code Linus Walleij
2025-05-06 7:57 ` [PATCH 1/5] fork: Clean-up ifdef logic around stack allocation Linus Walleij
2025-05-06 7:57 ` [PATCH 2/5] fork: Clean-up naming of vm_strack/vm_struct variables in vmap stacks code Linus Walleij
2025-05-07 1:51 ` Andrew Morton
2025-05-06 7:57 ` [PATCH 3/5] fork: Remove assumption that vm_area->nr_pages equals to THREAD_SIZE Linus Walleij
2025-05-07 1:53 ` Andrew Morton
2025-05-07 12:38 ` Linus Walleij [this message]
2025-05-06 7:57 ` [PATCH 4/5] fork: check charging success before zeroing stack Linus Walleij
2025-05-06 7:57 ` [PATCH 5/5] fork: zero vmap stack using clear_page() instead of memset() Linus Walleij
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=CACRpkdYqZ7CPyUuJLsm9KWc103WGMMS-J5vuQC-MWniWT-61Ng@mail.gmail.com \
--to=linus.walleij@linaro.org \
--cc=akpm@linux-foundation.org \
--cc=linux-mm@kvack.org \
--cc=pasha.tatashin@soleen.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