* [PATCH] fork: Use THREAD_SIZE_ORDER
@ 2024-03-11 13:44 Geert Uytterhoeven
2024-03-11 13:47 ` Arnd Bergmann
0 siblings, 1 reply; 3+ messages in thread
From: Geert Uytterhoeven @ 2024-03-11 13:44 UTC (permalink / raw)
To: Andrew Morton, Arnd Bergmann; +Cc: linux-kernel, Geert Uytterhoeven
Use the existing THREAD_SIZE_ORDER definition instead of calculating it
from THREAD_SIZE and PAGE_SIZE.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
kernel/fork.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/kernel/fork.c b/kernel/fork.c
index 0d944e92a43ffa13..e79fdfe1f0bf4953 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -252,9 +252,9 @@ static int memcg_charge_kernel_stack(struct vm_struct *vm)
int ret;
int nr_charged = 0;
- BUG_ON(vm->nr_pages != THREAD_SIZE / PAGE_SIZE);
+ BUG_ON(vm->nr_pages != THREAD_SIZE_ORDER);
- for (i = 0; i < THREAD_SIZE / PAGE_SIZE; i++) {
+ for (i = 0; i < THREAD_SIZE_ORDER; i++) {
ret = memcg_kmem_charge_page(vm->pages[i], GFP_KERNEL, 0);
if (ret)
goto err;
@@ -535,7 +535,7 @@ static void account_kernel_stack(struct task_struct *tsk, int account)
struct vm_struct *vm = task_stack_vm_area(tsk);
int i;
- for (i = 0; i < THREAD_SIZE / PAGE_SIZE; i++)
+ for (i = 0; i < THREAD_SIZE_ORDER; i++)
mod_lruvec_page_state(vm->pages[i], NR_KERNEL_STACK_KB,
account * (PAGE_SIZE / 1024));
} else {
@@ -556,7 +556,7 @@ void exit_task_stack_account(struct task_struct *tsk)
int i;
vm = task_stack_vm_area(tsk);
- for (i = 0; i < THREAD_SIZE / PAGE_SIZE; i++)
+ for (i = 0; i < THREAD_SIZE_ORDER; i++)
memcg_kmem_uncharge_page(vm->pages[i], 0);
}
}
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fork: Use THREAD_SIZE_ORDER
2024-03-11 13:44 [PATCH] fork: Use THREAD_SIZE_ORDER Geert Uytterhoeven
@ 2024-03-11 13:47 ` Arnd Bergmann
2024-03-11 14:04 ` Geert Uytterhoeven
0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2024-03-11 13:47 UTC (permalink / raw)
To: Geert Uytterhoeven, Andrew Morton; +Cc: linux-kernel
On Mon, Mar 11, 2024, at 14:44, Geert Uytterhoeven wrote:
> Use the existing THREAD_SIZE_ORDER definition instead of calculating it
> from THREAD_SIZE and PAGE_SIZE.
>
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> ---
> kernel/fork.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/fork.c b/kernel/fork.c
> index 0d944e92a43ffa13..e79fdfe1f0bf4953 100644
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -252,9 +252,9 @@ static int memcg_charge_kernel_stack(struct vm_struct *vm)
> int ret;
> int nr_charged = 0;
>
> - BUG_ON(vm->nr_pages != THREAD_SIZE / PAGE_SIZE);
> + BUG_ON(vm->nr_pages != THREAD_SIZE_ORDER);
>
That doesn't look right, THREAD_SIZE_ORDER not the number of
pages but the the log2 of it, right?
I think you want '(1 << THREAD_SIZE_ORDER)', but at that point
it doesn't actually look simpler than the existing code.
Arnd
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fork: Use THREAD_SIZE_ORDER
2024-03-11 13:47 ` Arnd Bergmann
@ 2024-03-11 14:04 ` Geert Uytterhoeven
0 siblings, 0 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2024-03-11 14:04 UTC (permalink / raw)
To: Arnd Bergmann; +Cc: Andrew Morton, linux-kernel
Hi Arnd,
On Mon, Mar 11, 2024 at 2:48 PM Arnd Bergmann <arnd@arndb.de> wrote:
> On Mon, Mar 11, 2024, at 14:44, Geert Uytterhoeven wrote:
> > Use the existing THREAD_SIZE_ORDER definition instead of calculating it
> > from THREAD_SIZE and PAGE_SIZE.
> >
> > Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> > ---
> > kernel/fork.c | 8 ++++----
> > 1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/kernel/fork.c b/kernel/fork.c
> > index 0d944e92a43ffa13..e79fdfe1f0bf4953 100644
> > --- a/kernel/fork.c
> > +++ b/kernel/fork.c
> > @@ -252,9 +252,9 @@ static int memcg_charge_kernel_stack(struct vm_struct *vm)
> > int ret;
> > int nr_charged = 0;
> >
> > - BUG_ON(vm->nr_pages != THREAD_SIZE / PAGE_SIZE);
> > + BUG_ON(vm->nr_pages != THREAD_SIZE_ORDER);
> >
>
> That doesn't look right, THREAD_SIZE_ORDER not the number of
> pages but the the log2 of it, right?
>
> I think you want '(1 << THREAD_SIZE_ORDER)', but at that point
> it doesn't actually look simpler than the existing code.
Thank you for pointing out my silly mistake.
/me hides in a brown paper bag, with a coffee machine.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-03-11 14:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-11 13:44 [PATCH] fork: Use THREAD_SIZE_ORDER Geert Uytterhoeven
2024-03-11 13:47 ` Arnd Bergmann
2024-03-11 14:04 ` Geert Uytterhoeven
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®