[PATCH] Use two-page stacks

3 views
Skip to first unread message

Barret Rhoden

unread,
Sep 12, 2018, 11:30:13 AM9/12/18
to aka...@googlegroups.com
This was an option before, but with all of the 9p/#gtfs stuff, we're
running off a single stack page.

I'm not as worried about two-page stacks anymore, due to our arena
allocator. We're currently grabbing two physically contiguous pages,
which we can always change if it becomes a problem - kernel stacks are
virtually mapped.

Also, the guard page at the end of the kernel stacks still works. =)

For those curious, here is an example backtrace with frame pointers to
show the stack consumption. None are egregious, but there are a few
large ones.

01 [<0xffffffffc2002292>] FP 0xfffffff000075048 in arena_alloc
02 [<0xffffffffc20533c4>] FP 0xfffffff000075098 in __kmem_alloc_from_slab
03 [<0xffffffffc2053bea>] FP 0xfffffff0000750d8 in kmem_cache_alloc
04 [<0xffffffffc200a272>] FP 0xfffffff0000750f8 in kmalloc
05 [<0xffffffffc2030308>] FP 0xfffffff000075118 in block_alloc
06 [<0xffffffffc203b165>] FP 0xfffffff000075158 in copyblock
07 [<0xffffffffc203b2ab>] FP 0xfffffff000075178 in linearizeblock
08 [<0xffffffffc20ee840>] FP 0xfffffff0000751a8 in etheroq
09 [<0xffffffffc20eed23>] FP 0xfffffff000075248 in etherbwrite
10 [<0xffffffffc201a272>] FP 0xfffffff0000752b8 in etherbwrite
11 [<0xffffffffc201d4a5>] FP 0xfffffff000075388 in ipoput4
12 [<0xffffffffc202b9b6>] FP 0xfffffff000075478 in tcpoutput
13 [<0xffffffffc202bed0>] FP 0xfffffff0000754f8 in tcpkick
14 [<0xffffffffc203aa8e>] FP 0xfffffff000075538 in __qbwrite
15 [<0xffffffffc203acd0>] FP 0xfffffff0000755d8 in __qwrite
16 [<0xffffffffc203c2b7>] FP 0xfffffff0000755e8 in qwrite
17 [<0xffffffffc201676c>] FP 0xfffffff0000756a8 in ipwrite
18 [<0xffffffffc20f4d0c>] FP 0xfffffff000075728 in mountio
19 [<0xffffffffc20f4fc5>] FP 0xfffffff000075748 in mountrpc
20 [<0xffffffffc20f6394>] FP 0xfffffff0000757e8 in mntstat
21 [<0xffffffffc203dd0d>] FP 0xfffffff000075888 in chandirstat
22 [<0xffffffffc20f08f8>] FP 0xfffffff0000758b8 in gtfs_tf_couple_backend
23 [<0xffffffffc20f09e3>] FP 0xfffffff0000758e8 in gtfs_tf_lookup
24 [<0xffffffffc205c7b3>] FP 0xfffffff000075978 in lookup_child_entry
25 [<0xffffffffc2042a4e>] FP 0xfffffff000075a38 in tree_file_walk
26 [<0xffffffffc2042af4>] FP 0xfffffff000075a68 in tree_chan_walk
27 [<0xffffffffc20f0bf1>] FP 0xfffffff000075a88 in gtfs_walk
28 [<0xffffffffc20324ad>] FP 0xfffffff000075b38 in walk
29 [<0xffffffffc2032f19>] FP 0xfffffff000075ca8 in __namec_from
30 [<0xffffffffc2033aff>] FP 0xfffffff000075d18 in namec
31 [<0xffffffffc203c926>] FP 0xfffffff000075db8 in __stat
32 [<0xffffffffc203dad9>] FP 0xfffffff000075de8 in sysstatakaros
33 [<0xffffffffc2055ebc>] FP 0xfffffff000075e28 in stat_helper
34 [<0xffffffffc2055f6f>] FP 0xfffffff000075e38 in sys_lstat
35 [<0xffffffffc20596d9>] FP 0xfffffff000075ee8 in syscall
36 [<0xffffffffc20598d4>] FP 0xfffffff000075f58 in run_local_syscall
37 [<0xffffffffc2059e09>] FP 0xfffffff000075f78 in prep_syscalls
38 [<0xffffffffc212206a>] FP 0xfffffff000075f98 in sysenter_callwrapper

Signed-off-by: Barret Rhoden <br...@cs.berkeley.edu>
---
Kconfig | 12 ------------
kern/include/kstack.h | 4 ----
2 files changed, 16 deletions(-)

diff --git a/Kconfig b/Kconfig
index 2c28f4566f80..8fdc079fd241 100644
--- a/Kconfig
+++ b/Kconfig
@@ -156,18 +156,6 @@ config SEM_SPINWAIT_NR_LOOPS
help
How many times to poll a busy semaphore before going to sleep.

-config LARGE_KSTACKS
- bool "Large (two-page) Kernel Stacks"
- default y
- help
- Ideally, we'd like to use single-page stacks, which are easier on the
- memory allocator. Some of the Plan 9 code hogs stack space, and we may
- run off the end of a single-page stack.
-
- Say 'y' to play it safe and use the larger, slower stacks. Say 'n' for
- higher performance, and mention this setting if you have any weird
- crashes or panics.
-
config DISABLE_SMT
bool "Disables symmetric multithreading"
default n
diff --git a/kern/include/kstack.h b/kern/include/kstack.h
index b6e0e3d2dbb6..1a089fcb899d 100644
--- a/kern/include/kstack.h
+++ b/kern/include/kstack.h
@@ -1,9 +1,5 @@
#pragma once

-#ifdef CONFIG_LARGE_KSTACKS
#define KSTKSHIFT (PGSHIFT + 1) /* KSTKSIZE == 2 * PGSIZE */
-#else
-#define KSTKSHIFT (PGSHIFT) /* KSTKSIZE == PGSIZE */
-#endif

#define KSTKSIZE (1 << KSTKSHIFT) /* size of a static kernel stack */
--
2.19.0.rc2.392.g5ba43deb5a-goog

Reply all
Reply to author
Forward
0 new messages