On Mon, Sep 08, 2014 at 03:55:11PM +0300, Alexander Shishkin wrote: > Fair enough. Then I'd like to disable the ACTIVE ones before freeing AUX > stuff and then re-enabling them since perf_event_{en,dis}able() already > provide the convenient cross-cpu calls, which would also avoid > concurrency between pmu::{add,del} callbacks and this unmap path. Makes > sense? But why? The buffer stuff is RCU freed, so if the hardware observes pages and does get_page_unless_zero() on them its good. The memory will not be freed from underneath the hardware writer because of the get_page(). Then when the buffer is full and we 'swap', we'll find there is no next buffer. At that point we can not provide a new buffer, effectively stopping the hardware writes and release the old buffer, freeing the memory.