From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755939AbbCSBY1 (ORCPT ); Wed, 18 Mar 2015 21:24:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51436 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751563AbbCSBYW (ORCPT ); Wed, 18 Mar 2015 21:24:22 -0400 Date: Wed, 18 Mar 2015 22:23:42 -0300 From: Marcelo Tosatti To: Paolo Bonzini Cc: Takuya Yoshikawa , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] KVM: Eliminate extra function calls in kvm_get_dirty_log_protect() Message-ID: <20150319012342.GA19205@amt.cnet> References: <20150317161958.991bd7dc36c714f6498821db@lab.ntt.co.jp> <5507ECAD.1030908@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5507ECAD.1030908@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 17, 2015 at 09:58:21AM +0100, Paolo Bonzini wrote: > > > On 17/03/2015 08:19, Takuya Yoshikawa wrote: > > When all bits in mask are not set, > > kvm_arch_mmu_enable_log_dirty_pt_masked() has nothing to do. But since > > it needs to be called from the generic code, it cannot be inlined, and > > a few function calls, two when PML is enabled, are wasted. > > > > Since it is common to see many pages remain clean, e.g. framebuffers can > > stay calm for a long time, it is worth eliminating this overhead. > > > > Signed-off-by: Takuya Yoshikawa > > --- > > virt/kvm/kvm_main.c | 8 +++++--- > > 1 file changed, 5 insertions(+), 3 deletions(-) > > > > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > > index a109370..420d8cf 100644 > > --- a/virt/kvm/kvm_main.c > > +++ b/virt/kvm/kvm_main.c > > @@ -1061,9 +1061,11 @@ int kvm_get_dirty_log_protect(struct kvm *kvm, > > mask = xchg(&dirty_bitmap[i], 0); > > dirty_bitmap_buffer[i] = mask; > > > > - offset = i * BITS_PER_LONG; > > - kvm_arch_mmu_enable_log_dirty_pt_masked(kvm, memslot, offset, > > - mask); > > + if (mask) { > > + offset = i * BITS_PER_LONG; > > + kvm_arch_mmu_enable_log_dirty_pt_masked(kvm, memslot, > > + offset, mask); > > + } > > } > > > > spin_unlock(&kvm->mmu_lock); > > > > Good catch! > > Reviewed-by: Paolo Bonzini Applied, thanks.