The BTS and PEBS buffers both have their virtual addressesprogrammed into the hardware. This means that any access to themis performed via the page tables. The times that the hardwareaccesses these are entirely dependent on how the performancemonitoring hardware events are set up. In other words, there isno way for the kernel to tell when the hardware might accessthese buffers.

To avoid perf crashes, place 'debug_store' in the user-mappedper-cpu area instead of dynamically allocating. Also use thepage allocator plus kaiser_add_mapping() to keep the BTS and PEBSbuffers user-mapped (that is, present in the user mapping, thoughvisible only to kernel and hardware). The PEBS fixup buffer doesnot need this treatment.

The need for a user-mapped struct debug_store showed up before doingany conscious perf testing: in a couple of kernel paging oopses onWestmere, implicating the debug_store offset of the per-cpu area.