From 1e5f901926a52a3c02e98a2ea5ecb9d201684ec5 Mon Sep 17 00:00:00 2001 From: WangRunji Date: Sun, 21 Apr 2019 15:01:52 +0800 Subject: [PATCH] shrink kstack size, avoid alloc kstack for init thread --- kernel/src/arch/riscv32/boot/entry32.asm | 4 ++-- kernel/src/arch/riscv32/boot/entry64.asm | 4 ++-- kernel/src/memory.rs | 2 +- kernel/src/process/structs.rs | 6 ++---- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/kernel/src/arch/riscv32/boot/entry32.asm b/kernel/src/arch/riscv32/boot/entry32.asm index 22cc0ee..3ea0676 100644 --- a/kernel/src/arch/riscv32/boot/entry32.asm +++ b/kernel/src/arch/riscv32/boot/entry32.asm @@ -8,7 +8,7 @@ _start: # 1. set sp # sp = bootstack + (hartid + 1) * 0x10000 add t0, a0, 1 - slli t0, t0, 16 + slli t0, t0, 14 lui sp, %hi(bootstack) add sp, sp, t0 @@ -32,7 +32,7 @@ _start: .align 12 # page align .global bootstack bootstack: - .space 4096 * 16 * 8 + .space 4096 * 4 * 8 .global bootstacktop bootstacktop: diff --git a/kernel/src/arch/riscv32/boot/entry64.asm b/kernel/src/arch/riscv32/boot/entry64.asm index 69727d5..6fbedbb 100644 --- a/kernel/src/arch/riscv32/boot/entry64.asm +++ b/kernel/src/arch/riscv32/boot/entry64.asm @@ -8,7 +8,7 @@ _start: # 1. set sp # sp = bootstack + (hartid + 1) * 0x10000 add t0, a0, 1 - slli t0, t0, 16 + slli t0, t0, 14 lui sp, %hi(bootstack) add sp, sp, t0 @@ -32,7 +32,7 @@ _start: .align 12 # page align .global bootstack bootstack: - .space 4096 * 16 * 8 + .space 4096 * 4 * 8 .global bootstacktop bootstacktop: diff --git a/kernel/src/memory.rs b/kernel/src/memory.rs index 54c2cff..ee152c9 100644 --- a/kernel/src/memory.rs +++ b/kernel/src/memory.rs @@ -77,7 +77,7 @@ pub fn dealloc_frame(target: usize) { } pub struct KernelStack(usize); -const STACK_SIZE: usize = 0x8000; +const STACK_SIZE: usize = 0x4000; impl KernelStack { pub fn new() -> Self { diff --git a/kernel/src/process/structs.rs b/kernel/src/process/structs.rs index a9982ee..c19cbe7 100644 --- a/kernel/src/process/structs.rs +++ b/kernel/src/process/structs.rs @@ -126,10 +126,8 @@ impl Thread { pub unsafe fn new_init() -> Box { Box::new(Thread { context: Context::null(), - kstack: KernelStack::new(), - clear_child_tid: 0, - // safety: this field will never be used - proc: core::mem::uninitialized(), + // safety: other fields will never be used + .. core::mem::uninitialized() }) }