Page MenuHomeFreeBSD

arm64 pmap: optimize TLB management by pmap_update_entry()
AcceptedPublic

Authored by alc on Tue, Aug 18, 5:29 PM.
Tags
None
Referenced Files
F167923169: D58917.id184267.diff
Tue, Aug 25, 11:05 AM
F167830058: D58917.diff
Mon, Aug 24, 8:19 PM
Unknown Object (File)
Thu, Aug 20, 8:47 PM
Unknown Object (File)
Tue, Aug 18, 6:51 PM
Unknown Object (File)
Tue, Aug 18, 6:50 PM
Unknown Object (File)
Tue, Aug 18, 6:50 PM
Unknown Object (File)
Tue, Aug 18, 6:49 PM
Unknown Object (File)
Tue, Aug 18, 6:23 PM
Subscribers

Details

Summary

To date, pmap_update_entry() has unconditionally passed false as final_only to pmap_s1_invalidate_range(). Passing false means that we invalidate the intermediate "page walk cache" entries in the TLB as well as the leaf that is being replaced. However, invalidating intermediate entries is only necessary when doing a superpage promotion that replaces a pointer to a page table page by a large page mapping.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

alc requested review of this revision.Tue, Aug 18, 5:29 PM
alc edited the summary of this revision. (Show Details)
markj added inline comments.
sys/arm64/arm64/pmap.c
5115–5116

This comment is a bit stale now. It's not really wrong but it's essentially just restating what was added to the function header comment.

This revision is now accepted and ready to land.Tue, Aug 18, 6:32 PM
sys/arm64/arm64/pmap.c
5090

Without the __always_inline here the compiler already inlines all of the calls except the one from pmap_promote_l2. For that, the compiler generates the one and only call to a non-specialized static function that doesn't exploit constant propagation and dead code elimination. This surprised me, since functions with a single call site are normally inlined. (I guess that heuristic is being applied early based on the source level, rather than late based on IR.) The __always_inline here enables specialization, reducing the overall code size by ~90 bytes.

sys/arm64/arm64/pmap.c
5115–5116

Would a more useful comment be along the lines of "We aggressively inline this function so that constant propagation and dead code elimination will effectively specialize the following code."?

sys/arm64/arm64/pmap.c
5090

Indeed, I can get clang to output:

sys/arm64/arm64/pmap.c:5353:2: remark: 'pmap_update_entry' not inlined into 'pmap_promote_l2' because too costly to inline (cost=65, threshold=45) [-Rpass-missed=inline]

but I don't know how it determines those numbers. Looking at InlineCost.cpp and InlineAdvisor.cpp, I see some heuristics regarding the last call of a static function, but it seems they are failing somehow.

5115–5116

I think that would be good.

Does arm64 use recursive mapping? If yes, could the function be used on recursive mapping?

In D58917#1352088, @kib wrote:

Does arm64 use recursive mapping? If yes, could the function be used on recursive mapping?

No, it does not.

This revision now requires review to proceed.Tue, Aug 18, 7:48 PM
This revision is now accepted and ready to land.Tue, Aug 18, 7:50 PM