On an x86_64 CPU, I have marked some page table entries as write-combining. These pages are backed by a PCIe BAR. After I am finished storing to the memory in the pages, how can I flush the write-combining buffer? Intuitively, it seems like an sfence
(or mfence
) should do this but I am not sure that a flush is guaranteed. The Intel manual says the following about the sfence
instruction:
Orders processor execution relative to all memory stores prior to the SFENCE instruction. The processor ensures that every store prior to SFENCE is globally visible before any store after SFENCE becomes globally visible. The SFENCE instruction is ordered with respect to memory stores, other SFENCE instructions, MFENCE instructions, and any serializing instructions (such as the CPUID instruction). It is not ordered with respect to memory loads or the LFENCE instruction.
It is unclear what "globally visible" means. Does this mean all of the other cores in the CPU or does it mean the entire system, including I/O devices (in which case a flush would be required)?
Alternatively, is a clflush
what I want?