On 3/28/2024 8:23 PM, Gregory Nutt wrote:
...
On all platforms that I am aware of, the virtual address of the
framebuffer is just a configurable constant. This makes sense if the
framebuffer is in a fixed virtual address in every process. The kernel
can manage the virtual address space anyway that it likes. A fixed
virtual position for the framebuffer is a reasonable decision. More
logic is need to manage the virtual address space to handle things
like pthread stacks, heap, shared libraries, framebuffers, etc. The
logic and virtual memory layout in Linux is quite complex even though
all of these are at fixed virtual addresses in every process.
pthread stacks have some particular complexities. First, their virtual
address be aligned to a large value. Old versions of Linux that I
worked with in the past aligned the pthread virtual addresses to 2
MByte. This permits TLS to work by simply ANDing an address (vs
performing a system call).
Right now, pthread stacks are malloc'ed and, as a result, cannot exploit
this fast TLS access.
Old versions of Linux supported an array of pthread stacks (hence,
limiting the number of pthreads to something like 200). Each stack was
2MByte of virtual address. All fixed, constant virtual addresses.