Page MenuHomeFreeBSD

arm64 vfp: eliminate nested critical sections
Needs ReviewPublic

Authored by alc on Sat, Aug 15, 4:49 PM.

Details

Summary

At two out of three call sites to vfp_restore_state_common(), the caller must use critical_{enter,exit} to prevent preemption between its call to vfp_restore_state_common() and other actions, notably its call to sve_enable(). So, it is arguably better to make vfp_restore_state_common()'s caller responsible for performing critical_{enter,exit} and simply perform CRITICAL_ASSERT() inside vfp_restore_state_common().

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

alc requested review of this revision.Sat, Aug 15, 4:49 PM
sys/arm64/arm64/vfp.c
737–738

Is it better to dereference curthread outside of the section (for some value of 'better')?

sys/arm64/arm64/vfp.c
737–738

One load instruction moves out of the critical section, and moving it doesn't create any more register pressure. That instruction is going to be a cache hit (when inside the critical section) because critical_enter() itself fetches curthread. Unfortunately, wherever you place td = curthread;, the compiler has to generate two load instructions for curthread. It can't eliminate one because volatile blocks common subexpression expression.

I'm pretty much indifferent to where td = curthread; goes, so I'm happy to move it.

This revision is now accepted and ready to land.Sat, Aug 15, 10:44 PM

Move td = curthread; out of the critical section.

This revision now requires review to proceed.Sat, Aug 15, 10:54 PM