Page MenuHomeFreeBSD

arm64 pmap: Avoid redundant icache synchronization using PGA_EXECUTABLE
AcceptedPublic

Authored by alc on Sun, Sep 20, 10:31 PM.
Tags
None
Referenced Files
F172885154: D59865.diff
Mon, Sep 21, 8:28 PM
F172849787: D59865.id187304.diff
Mon, Sep 21, 1:59 PM
F172849660: D59865.diff
Mon, Sep 21, 1:58 PM
Subscribers

Details

Summary

Creating an executable user-space mapping to write-back memory synchronizes the icache with the page's contents, whether or not those contents have changed since the previous synchronization. Use the page flag PGA_EXECUTABLE to record that the icache has been synchronized with a managed page's contents and that the page has no writable mappings. When the flag is set, the creation of another executable mapping of the page can skip the synchronization. The flag is cleared when a writable mapping of the page is created, using a single atomic operation that keeps PGA_WRITEABLE and PGA_EXECUTABLE from ever being simultaneously set, and when the page's last mapping is destroyed.

(This is stricter than mmu_oea64's use of the same flag, PGA_EXECUTABLE. Specifically, mmu_oea64 allows PGA_WRITEABLE and PGA_EXECUTABLE to be set simultaneously.)

Assisted-by: Claude Code (Fable 5.1)

Test Plan

I've tested this patch on an EC2 a1.4xlarge (16x Cortex A72) machine to see the greatest impact. (This is the entire machine, so there isn't any variance due to other VMs on the machine.) I added a COUNTER_U64 to track icache flushes by the pmap. A buildworld performed 229.09M icache synchronizations per run before this change and 8.33M after it, a 96.4% reduction. System time fell from 5097 s to 4502 s (-11.7%), user time fell by 1.1%, and wall-clock time fell by 1.5%.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

alc requested review of this revision.Sun, Sep 20, 10:31 PM
kib added inline comments.
sys/arm64/arm64/pmap.c
5690

Should we assert there and in loop that _WRITEABLE and _EXECUTABLE are not set simultaneously?

This revision is now accepted and ready to land.Mon, Sep 21, 12:19 PM