0

According to this question the TLB content is not saved in the process control block in Linux, or equivalent in other operating systems. I would like to understand why that is, as saving and loading TLB entries takes time, but I would think this would be (much) less than the TLB misses not saving them causes. Answers can be OS or architecture specific or in general.

n66
  • 1
  • 2
  • *but this should be much less than the TLB misses not saving them causes* And what do you base **that** on? – Andrew Henle Jul 15 '22 at 14:27
  • @AndrewHenle: You probably need at least one data and instruction TLB entry per process, which is probably already more that the TLB size, so the chance that TLB entries for a process from the previous time it ran are still in the TLB is not very high if multiple processes executed in between. A TLB miss can cause multiple RAM or even page file reads, while storing and loading all TLB entries could be done in one page and thus one write and one read to RAM (or disk). – n66 Jul 15 '22 at 14:36
  • 1
    Note that processors with hardware-managed TLBs have no way of loading or saving the TLB anyway. (Also, if a TLB miss would have triggered a page file read, then the page was not present, so it wasn't in the TLB to begin with.) Note that loading the TLB requires you to recalculate the TLB, since page mappings may have changed in the meantime. This may involve recalculating a lot of information that is ultimately never used. – Raymond Chen Jul 15 '22 at 14:44
  • 1
    Well, if you think it should be saved, have you thought about *how* you would save it? Most architectures do not offer a way of reading/writing the TLB directly, just low level instructions to flush the entire table or flush/invalidate specific entries. Also *"loading all TLB entries could be done in one page and thus one write and one read to RAM (or disk)"* this kind of operation would likely be orders of magnitude more expensive than a bunch of TLB misses. – Marco Bonelli Jul 15 '22 at 14:47
  • @MarcoBonelli I didn't say they should be saved, just that from my understanding (apparently more limited than I thought) it could save time. Based on your comment that is probably not true unless these saved TLB entries get updated each time a physical page gets relocated. And that is only doable if they are stored in an L2TLB, which for all I know might already happen. – n66 Jul 15 '22 at 14:59

0 Answers0