Skip to content
Snippets Groups Projects
Commit 10455c5b authored by Glauber Costa's avatar Glauber Costa Committed by Pekka Enberg
Browse files

bsd: set a smaller default stack for BSD threads.


All threads created through the bsd/porting/kthread interface are threads that
used to be kernel threads in BSD, which means they are expected to use less
stack. Although I have no idea what is the default stack size for BSD, in Linux
things need as little as 4k. More importantly, they are threads whose memory
usage are under our control, and we could fix heavy offenders without a
problem.

If we don't say anything, they will start with 64k which is way, way, too much.
I am proposing here we go lower and get to 16k - which is even still quite
conservative, but so am I.

Measuring memory before and after the mount - because ZFS is currently our
heaviest user, I can save around 7Mb with this patch.

Passes make check (except for tst-kill, which is broken AFAICT) and misc-fs-stress.

Reviewed-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
Signed-off-by: default avatarGlauber Costa <glommer@cloudius-systems.com>
Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>
parent a69b2d2d
No related branches found
No related tags found
No related merge requests found
......@@ -31,7 +31,7 @@ kthread_add(void (*func)(void *), void *arg, struct proc *p,
vsnprintf(name_buf, sizeof(name_buf), fmt, va);
va_end(va);
sched::thread* t = new sched::thread([=] { func(arg); },
sched::thread::attr().detached().name(name_buf));
sched::thread::attr().detached().name(name_buf).stack(16 << 10));
t->start();
*newtdp = reinterpret_cast<struct thread *>(t);
......@@ -48,7 +48,7 @@ int kproc_create(void (*func)(void *), void *arg, struct proc **p,
vsnprintf(name_buf, sizeof(name_buf), str, va);
va_end(va);
sched::thread* t = new sched::thread([=] { func(arg); },
sched::thread::attr().detached().name(name_buf));
sched::thread::attr().detached().name(name_buf).stack(16 << 10));
t->start();
if (p) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment