I recently heard that Linux simply flushes the TLB cache when the corresponding data in that physical address is swapped out, resulting in underutilization of the TLB. I don't know whether all OSes do the same.

If this is true then will increasing RAM and avoiding context switching keep cache in TLB?


2 Answers 2


It seems that Linux kernel handle TLB and TLB cache with the same approach. At the architecture independent level there is no thing like flushing a part or entire TLB cache AFAIK. The vm will for example page out things, and there are some hooks to this action which will trigger hardware dependent code if necessary. Depending on the CPU, the kernel might then do several page flushes for each page out, or the CPU supports range of page flushing, or it supports neither and the kernel uses the most expensive flush which flushes the complete cache.

There are two interesting articles on this topic:


To swap data out is quite a bit more expensive than deleting a TLB line (which won't be of any use afterwards). And flushing the full TLB is probably also much cheaper.

The Linux honchos are absolute performance freaks. If they do as you claim, it's because the affected architecture doesn't allow anything better (or it just doesn' matter).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .