0

In 'Computer Organization and Design' RISC-V version ebook by Patterson and Hennessy p850, it says:

A common alternative is to extend the virtual address space by adding a process identifier or task identifier. The Intrinsity FastMATH has an 8-bit address space ID (ASID) field for this purpose. This small field identifies the currently running process; it is kept in a register loaded by the operating system when it switches processes. RISC-V also offers ASID to reduce TLB flushes on context switches. The process identifier is concatenated to the tag portion of the TLB, so that a TLB hit occurs only if both the page number and the process identifier match. This combination eliminates the need to clear the TLB, except on rare occasions.

So what is the rare occasions? Does it refers to the rare condition that the TLB is full of translation cache of one process ? Or something else ?

zg c
  • 113
  • 1
  • 1
  • 7
  • By the way while that paragraph in P&H makes it sound easy, it is [difficult to use such process IDs for actual process IDs](https://stackoverflow.com/q/20155304/555045). There are too few of them (so *if* you use them that way, you need some way to recycle IDs) and there are other problems. – harold Jun 22 '23 at 13:27
  • Thanks. 1. As the link you offered say, we 'have to do some research (experiments, prototypes, benchmarking) to determine the most effective way' like the [kernel](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=10af6235e0d327d42e1bad974385197817923dc1) does. 2. Although on my laptop, only '381' processes are running by checking `ps axu | wc -l`, but 'there are monster systems with over 4096 CPUs' (the kernel link above says) and 'use all 12 PCID bits have resulted in slowdowns'. – zg c Jun 23 '23 at 01:52
  • These two factors cause 'patch uses PCID differently' which needs understanding the source codes (I will do that after learning some basic knowledge.). (PCID recycling see what ['Brendan'](https://forum.osdev.org/viewtopic.php?f=1&t=29935) says) 3. Answering to the original question, the ['TLB shootdown'](https://stackoverflow.com/questions/3748384/what-is-tlb-shootdown) (see 'invalidated in all of the cores' in the link) is the above 'rare occasions' (maybe not rare). It is similar to cache coherency. – zg c Jun 23 '23 at 02:11
  • Complement to the 1st element in the list: this implies the somewhat difficult implementation. Complement to the 2nd element in the list: From linux 4.14, it ['uses a PCID cache per CPU'](https://stackoverflow.com/a/41404782/21294350) which is to 'identify a recently-used mm on a per-cpu basis' as the above kernel link says. So it use PCID per-cpu instead of 'PCID per-process'. Complement to the 3rd element in the list: 'TLB shootdown' is one of the rare occasions. If my understanding is wrong, please point out. Thanks. – zg c Jun 23 '23 at 02:20

0 Answers0