All of lore.kernel.org
 help / color / mirror / Atom feed
* question: KVM_MR_CREATE and kvm_mmu_slot_apply_flags()
@ 2020-05-15 21:28 Anthony Yznaga
  2020-05-15 23:41 ` Sean Christopherson
  0 siblings, 1 reply; 3+ messages in thread
From: Anthony Yznaga @ 2020-05-15 21:28 UTC (permalink / raw)
  To: kvm

Hi,

I'm investigating optimizing qemu start time for large memory guests,
and I'm trying to understand why kvm_mmu_slot_apply_flags() is called by
kvm_arch_commit_memory_region() for KVM_MR_CREATE.  The comments in
kvm_mmu_slot_apply_flags() imply it should be, but what I've observed is
that the new slot will have no mappings resulting in slot_handle_level_range()
walking the rmaps and doing nothing.  This can take a noticeable amount of
time for very large ranges.  It doesn't look like there would ever be any
mappings in a newly created slot.  Am I missing something?

Thanks,
Anthony

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: question: KVM_MR_CREATE and kvm_mmu_slot_apply_flags()
  2020-05-15 21:28 question: KVM_MR_CREATE and kvm_mmu_slot_apply_flags() Anthony Yznaga
@ 2020-05-15 23:41 ` Sean Christopherson
  2020-05-16  0:48   ` Anthony
  0 siblings, 1 reply; 3+ messages in thread
From: Sean Christopherson @ 2020-05-15 23:41 UTC (permalink / raw)
  To: Anthony Yznaga; +Cc: kvm

On Fri, May 15, 2020 at 02:28:54PM -0700, Anthony Yznaga wrote:
> Hi,
> 
> I'm investigating optimizing qemu start time for large memory guests,
> and I'm trying to understand why kvm_mmu_slot_apply_flags() is called by
> kvm_arch_commit_memory_region() for KVM_MR_CREATE.  The comments in
> kvm_mmu_slot_apply_flags() imply it should be, but what I've observed is
> that the new slot will have no mappings resulting in slot_handle_level_range()
> walking the rmaps and doing nothing.  This can take a noticeable amount of
> time for very large ranges.  It doesn't look like there would ever be any
> mappings in a newly created slot.  Am I missing something?

I don't think so.  I've stared at that call more than once trying to figure
out why it's there.  AFAICT, the original code was completely unoptimized,
then the DELETE check got added as the obvious "this is pointless" case.
Note, KVM_MR_MOVE is in the same boat as CREATE; it's basically DELETE+CREATE.

There can theoretically be rmaps for the new/moved memslot, but they should
already be up-to-date since they're consuming the new memslot's properties.

I've always been too scared to remove it and didn't have a strong argument
for doing so :-)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: question: KVM_MR_CREATE and kvm_mmu_slot_apply_flags()
  2020-05-15 23:41 ` Sean Christopherson
@ 2020-05-16  0:48   ` Anthony
  0 siblings, 0 replies; 3+ messages in thread
From: Anthony @ 2020-05-16  0:48 UTC (permalink / raw)
  To: Sean Christopherson; +Cc: kvm

On 5/15/20 4:41 PM, Sean Christopherson wrote:
> On Fri, May 15, 2020 at 02:28:54PM -0700, Anthony Yznaga wrote:
>> Hi,
>>
>> I'm investigating optimizing qemu start time for large memory guests,
>> and I'm trying to understand why kvm_mmu_slot_apply_flags() is called by
>> kvm_arch_commit_memory_region() for KVM_MR_CREATE.  The comments in
>> kvm_mmu_slot_apply_flags() imply it should be, but what I've observed is
>> that the new slot will have no mappings resulting in slot_handle_level_range()
>> walking the rmaps and doing nothing.  This can take a noticeable amount of
>> time for very large ranges.  It doesn't look like there would ever be any
>> mappings in a newly created slot.  Am I missing something?
> 
> I don't think so.  I've stared at that call more than once trying to figure
> out why it's there.  AFAICT, the original code was completely unoptimized,
> then the DELETE check got added as the obvious "this is pointless" case.
> Note, KVM_MR_MOVE is in the same boat as CREATE; it's basically DELETE+CREATE.
> 
> There can theoretically be rmaps for the new/moved memslot, but they should
> already be up-to-date since they're consuming the new memslot's properties.
> 
> I've always been too scared to remove it and didn't have a strong argument
> for doing so :-)
> 


Thanks, Sean.  This is my first foray into kvm code so I'm still getting
familiar with the code.  I haven't studied the KVM_MR_MOVE case yet, but it
sounds like kvm_mmu_slot_apply_flags() may only do useful work for the
KVM_MR_FLAGS_ONLY case.

Anthony

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-05-16  0:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-15 21:28 question: KVM_MR_CREATE and kvm_mmu_slot_apply_flags() Anthony Yznaga
2020-05-15 23:41 ` Sean Christopherson
2020-05-16  0:48   ` Anthony

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.