Middleware, development tools, realtime operating system
software and services for superior embedded design
‹ QNX.com
Home
Project Categories
Projects
Community Search
Search Wiki Pages Project: QNX Operating System     Wiki > PPCE_BAT_Addressing_Technology > View Wiki Page
wiki1323: PPCE_BAT_Addressing_Technology

!Kludge Alert. Don't use this!

A customer was worried about TLB miss performance. Without any performance numbers, they insisted on having the ability to set PPC BAT registers to point at particular regions of memory to avoid any TLB misses. Previously, BAT registers were only used to map the system address area (first 256M), gain addressability to devices used by the callouts (via the startup callout_memory_map()/callout_io_map() functions), and (on SMP) the cpu_page. All these are global quantities, so we didn't have to save/restore them across context switches that changed address spaces. With this feature, we'd now have to slow down everybody :-(. What we did was tricky: Implemented on top of the variable page size support (which the PPC 600 series family doesn't have) we put in gear that looked for shared memory objects with the SHMCTL_HIGHUSAGE flag set (see the shm_ctl() function on how to set that bit). When that flag is on, and the variable page size support can coalesce the mapping into something that a BAT register can use, take an available BAT and point it at the memory on top of the regular page table entries. Since BAT translations take priority over the TLB/page tables, you never get a TLB miss. To avoid making everybody pay the performance cost of saving and restoring the BAT registers, we play some games with the memmgr variable. The memmgr.aspace field normally points at the vmm_aspace function in memmgr/ppc/vmm_aspace.c. This function doesn't bother saving/restoring the BAT registers, so normal people get better performance. As soon at the SHMCTL_HIGHUSAGE flag actually causes a BAT to be used, the memmgr.aspace field is reset to point at vmm_aspace_bat in memmgr/ppc/600/fam_pte.c. This function has the slower version of the address space switch which saves and restores the BAT registers. Also, there are usually only 4 instruction and 4 data BAT registers on a PPC600 family chip (some implementations add extra BATs). On a non-SMP system, there's only one free BAT once the system sets up it's ones and there's none at all for the SMP version of procnto.