Page MenuHomeFreeBSD

amd64: move pcb out of kstack to struct thread
ClosedPublic

Authored by kib on Oct 24 2019, 6:42 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sep 30 2024, 8:13 AM
Unknown Object (File)
Sep 21 2024, 2:02 AM
Unknown Object (File)
Sep 19 2024, 10:05 PM
Unknown Object (File)
Sep 17 2024, 1:10 AM
Unknown Object (File)
Sep 17 2024, 1:10 AM
Unknown Object (File)
Sep 17 2024, 1:10 AM
Unknown Object (File)
Sep 17 2024, 1:10 AM
Unknown Object (File)
Sep 17 2024, 1:10 AM
Subscribers

Details

Summary

This saves 320 bytes of the precious stack space.

The only negative aspect of the change I can think of is that the struct thread increased by 320 bytes obviously, and that 320 bytes are not swapped out anymore. I believe the freed stack space is much more important than that. ALso, current struct thread size is 1392 bytes in size on amd64, so UMA will allocate two thread structures per (4KB) slab, which leaves a space for pcb without increasing zone memory use.

I consider moving the user FPU save area into the dedicated allocation as the next step. Then it might be even possible to reduce the default stack size (not tried yet).

Tested by: pho

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

The only negative aspect of the change I can think of is that the struct thread increased by 320 bytes obviously, and that 320 bytes are not swapped out anymore. I believe the freed stack space is much more important than that.

struct thread is 1392 bytes in size on amd64, so UMA will allocate two thread structures per (4KB) slab. There is thus a lot of space being wasted currently, so I think using some of it for the PCB is fine.

I think "top of the stack" is a bit of a misnomer: the base address of a stack is typically called the "bottom" of the stack, but that is confusing here since thread stacks grow down. I don't think md_bottom_of_stack would be any more clear; maybe consider calling it md_stack_base?

sys/amd64/amd64/vm_machdep.c
104 ↗(On Diff #63624)

Perhaps include the thread pointer in the message?

192 ↗(On Diff #63624)

The parens are not needed.

359 ↗(On Diff #63624)

Same as above.

This revision is now accepted and ready to land.Oct 24 2019, 2:25 PM
kib marked 3 inline comments as done.

Mark' notes.

This revision now requires review to proceed.Oct 24 2019, 3:16 PM
This revision is now accepted and ready to land.Oct 24 2019, 4:15 PM
sys/amd64/amd64/machdep.c
1792 ↗(On Diff #63634)

This sentence is a bit awkward. Do you mean the following? "We initialize the PCB pointer early so that exception handlers will work."

kib marked an inline comment as done.

Reformulate comment as suggested by alc.

This revision now requires review to proceed.Oct 25 2019, 6:50 AM
This revision is now accepted and ready to land.Oct 25 2019, 5:55 PM
This revision was automatically updated to reflect the committed changes.