Page MenuHomeFreeBSD

amd64: move common_tss into pcpu
ClosedPublic

Authored by kib on Nov 3 2019, 5:29 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Dec 7, 12:54 AM
Unknown Object (File)
Nov 19 2024, 4:25 AM
Unknown Object (File)
Nov 19 2024, 4:08 AM
Unknown Object (File)
Nov 19 2024, 12:34 AM
Unknown Object (File)
Nov 11 2024, 6:39 AM
Unknown Object (File)
Sep 27 2024, 4:39 PM
Unknown Object (File)
Sep 17 2024, 1:11 AM
Unknown Object (File)
Sep 17 2024, 1:10 AM

Details

Summary

This saves some memory, around 256K I think. Also it reduces some code, e.g. KPTI does not need to specially map common_tss anymore.

Also, common_tss become domain-local.

Diff Detail

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

Event Timeline

sys/amd64/amd64/mp_machdep.c
342 ↗(On Diff #63905)

This block is simply moved above, so that pcpu_init() happens before initialization of pc_common_tss.

jhb added inline comments.
sys/amd64/amd64/cpu_switch.S
191 ↗(On Diff #63905)

I guess with our macros it doesn't work, but too bad you can't just use leaq here instead:

leaq PCPU(COMMONTSS),%r13
sys/amd64/amd64/machdep.c
1693 ↗(On Diff #63905)

This is redundant I think? amd64_bsp_pcpu_init1() is already setting this?

sys/amd64/amd64/pmap.c
9724 ↗(On Diff #63905)

This seems like the next candidate to move perhaps so that it is domain-local? Will it fit into the remaining space?

This revision is now accepted and ready to land.Nov 6 2019, 7:46 PM
kib marked an inline comment as done.Nov 6 2019, 8:28 PM
kib added inline comments.
sys/amd64/amd64/cpu_switch.S
191 ↗(On Diff #63905)

I need linear address there, while lea can only provide the effective. AFAIK there is no way to read the segment base at all, unless using something like RDGSBASE. This is why pc_prvspace exists.

sys/amd64/amd64/machdep.c
1693 ↗(On Diff #63905)

Yes, removed.

sys/amd64/amd64/pmap.c
9724 ↗(On Diff #63905)

Do you mean IDT or GDT ?

I believe GDT can be moved, it currently uses 13 descriptors which means 13 * 8 == 104 bytes. PCPU has around 3K free. I will do this next.

For IDT, I am not sure. Currently we use single global IDT, do you want to dup it to each CPU ? In principle it is doable but I remember a discussion some time ago about using per-cpu IDT to increase number of hw-unique MSI vectors, and an argument was that interrupt sources in sw provide enough dispatching capability so that we do not need it.

sys/amd64/amd64/pmap.c
9724 ↗(On Diff #63905)

I actually meant IDT, though you are right that the per-CPU indirection is not in the IDT itself. The GDT does seem trivial as it is already per-CPU. For IDT we could perhaps do a per-domain IDT if we think it made any difference. Perhaps Netflix's workload is one where they could try a patch to see if there is any measurable difference.

This revision was automatically updated to reflect the committed changes.
kib marked an inline comment as done.