On Wed, Jul 02, 2025 at 08:18:48AM +0800, Edgecombe, Rick P wrote: > > > We need mmu write lock for demote, but as long as the order is: > > > 1. set lpage_info > > > 2. demote if needed > > > 3. go to fault handler > > > > > > Then (3) should have what it needs even if another fault races (1). For now I implemented the sequence as 1. check lpage_info, if 2MB is already disabled for a GFN, goto 3. 2. if 2MB is not disabled, 2.1 acquire write mmu_lock 2.2 split the GFN mapping and kvm_flush_remote_tlbs() if split is performed 2.3 update lpage_info to disable 2MB for the GFN 2.4 release write mmu_lock 3. fault handler for the GFN Note: write mmu_lock is held during 2.2 successfully splitting a huge GFN entry and 2.3. So, it can guarantee that there's no 2MB mapping for the GFN after 2.3. Step 1 can help reduce the count of write mmu_lock from 17626 to 11.