using segmentation to manage memory in FreeBSD

Ravi Krishna ravikrish at gmail.com
Tue Mar 8 06:06:00 PST 2005


Hi all!

I would like to know if FreeBSD allows one to use segmentation on x86
to reduce the penalty of context switches. (please read on for
details)

Virtual memory on x86 can be managed by either segmentation or by paging. 

when using paging a context switch from one process to other all the
TLB mappings stored in TLB cache are flushed, this makes context the
switch expensive (we will have lots of TLB misses).
There are situations when individual processes donot have large memory
requirements . Some processors have TLB tagging, so OS doesnot flush
all the TLB entries when a context switch happens, only selective ones
are flushed. Unfortunatly Intex x86 does not have TLB tagging
available.

The way to implement something similar on x86 is using segmentation.
say I have four modules
A, B, C, D each needing 100MB address.   I can give each of these a
100MB segment. Assuming TLB cache is large enough to store TLB
mappings for all of these four, to context switch (say frm A to B) I
can just switch the segment, by setting segmentation registers.
These there will be no TLB flush. When we come back frm B to A again
we switch the segment. Now again to TLB flush will happen and A will
be able to use the TLB cache entries for its segment.

This becomes more attractive for 64 bit systems.

My question is that is this functionality available on FreeBSD in any way?

Ravi


More information about the freebsd-hackers mailing list