Cache Management Advise

User mode commands to flush a cache line have been implicated in Row Hammer attacks. Perhaps we should do without such user mode commands. They do serve a purpose, however. I suggest here a slightly higher level semantics that a kernel could support along with some new hardware support. Other related problems are addressed as well.

Suppose there were a kernel call involving some stated span of virtual memory to the effect: “For any x, within the span, when I touch address I will soon need x+k”. Variable k is an argument to the call. The kernel can use this information to decorate page table entries so that cache control can do its thing, whatever that is. The kernel could also inform disk activity to prefetch data from the disk. If the call serves both purposes then “soon” in the call needs to be quantified. k can be positive or negative. Another message to the kernel might be “For any address x within the span when I touch address x I am done with addresses x+k.”. This allows hardware cache control to free up cache space, and perhaps do a lazy write to clean the cache line if it is dirty. It might also lessen batched cache flush latency. The disk version is analogous.

This logic could work at different cache levels. The program making these calls needs less information about line sizes.

Much latitude is permissible because the semantics to the program are invisible. Only performance changes. Some facilities for feedback are needed.

Some have suggested that it might be better for the hardware to dynamically derive this information. It might even be easier. The kernel could do likewise for the disk.