2006-01-06 16:16:15

by Adrian Bunk

[permalink] [raw]
Subject: [2.6 patch] fix arm26 THREAD_SIZE

arm26 currently has a 256 kB THREAD_SIZE (sic).

Looking at the comment in the code, this seems to be based on a
misunderstanding.

The comment says:
this needs attention (see kernel/fork.c which gets a nice div by zero if
this is lower than 8*32768

kernel/fork.c does:
max_threads = mempages / (8 * THREAD_SIZE / PAGE_SIZE)

Therefore, a division by 0 is impossible for all reasonable cases with
THREAD_SIZE >= PAGE_SIZE.

Since the minimum PAGE_SIZE Linux uses on the arm26 architecture is 16k,
PAGE_SIZE should be sufficient for THREAD_SIZE.


Signed-off-by: Adrian Bunk <[email protected]>

--- linux-2.6.15-mm1-full/include/asm-arm26/thread_info.h.old 2006-01-06 16:45:40.000000000 +0100
+++ linux-2.6.15-mm1-full/include/asm-arm26/thread_info.h 2006-01-06 16:46:07.000000000 +0100
@@ -80,8 +80,7 @@
return (struct thread_info *)(sp & ~0x1fff);
}

-/* FIXME - PAGE_SIZE < 32K */
-#define THREAD_SIZE (8*32768) // FIXME - this needs attention (see kernel/fork.c which gets a nice div by zero if this is lower than 8*32768
+#define THREAD_SIZE PAGE_SIZE
#define task_pt_regs(task) ((struct pt_regs *)(task_stack_page(task) + THREAD_SIZE - 8) - 1)

extern struct thread_info *alloc_thread_info(struct task_struct *task);


2006-01-07 00:36:46

by Ian molton

[permalink] [raw]
Subject: Re: [2.6 patch] fix arm26 THREAD_SIZE

Adrian Bunk wrote:

Looks good to me. cant recall why that got that way, but the div by zero
definately went away at the time. certainly its wrong as-is, the
implication is that an 8 MB machine would get a max_threads of about 4 :)

Signed-off-by: Adrian Bunk <[email protected]>
Signed-off-by: Ian Molton <[email protected]>

--- linux-2.6.15-mm1-full/include/asm-arm26/thread_info.h.old 2006-01-06
16:45:40.000000000 +0100
+++ linux-2.6.15-mm1-full/include/asm-arm26/thread_info.h 2006-01-06
16:46:07.000000000 +0100
@@ -80,8 +80,7 @@
return (struct thread_info *)(sp & ~0x1fff);
}

-/* FIXME - PAGE_SIZE < 32K */
-#define THREAD_SIZE (8*32768) // FIXME - this needs attention (see
kernel/fork.c which gets a nice div by zero if this is lower than 8*32768
+#define THREAD_SIZE PAGE_SIZE
#define task_pt_regs(task) ((struct pt_regs *)(task_stack_page(task) +
THREAD_SIZE - 8) - 1)

extern struct thread_info *alloc_thread_info(struct task_struct *task);