> > > + > > > + next = __stage2_range_addr_end(addr, end, chunk_size); > > > + ret = kvm_pgtable_stage2_split(pgt, addr, next - addr, > > > + cache, cache_capacity); > > > + if (ret) > > > + break; > > > + } while (addr = next, addr != end); > > > + > > > + return ret; > > > +} > > > + > > > #define stage2_apply_range_resched(kvm, addr, end, fn) \ > > > stage2_apply_range(kvm, addr, end, fn, true) > > > > > > > I'm wandering if stage2_apply_range() can be reused to avoid invent another similar > > function. the gap are the granularity and conditions to reschedule. > > Will try and see what it looks like and report back. > Tried and don't like the result very much: static int _stage2_apply_range(struct kvm *kvm, phys_addr_t addr, phys_addr_t end, int (*fn)(struct kvm_pgtable *, u64, u64), bool fn_ignore_failures, bool fn_drop_mmu_lock, struct kvm_mmu_memory_cache *cache, int cache_capacity, bool resched) The generic function would require too many arguments to work for all cases. Thanks, Ricardo