public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Wanpeng Li <wanpeng.li@linux.intel.com>
To: Andres Lagar-Cavilla <andreslc@google.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Paolo Bonzini <pbonzini@redhat.com>,
	Xiao Guangrong <guangrong.xiao@linux.intel.com>,
	Eric Northup <digitaleric@google.com>
Subject: Re: [PATCH v3] kvm: mmu: lazy collapse small sptes into large sptes
Date: Tue, 14 Apr 2015 13:25:39 +0800	[thread overview]
Message-ID: <20150414052539.GA2559@kernel> (raw)
In-Reply-To: <CAJu=L59ogYcW_VGVXeEyjVY65ExNrr_P61TdnpdXuWe9cHEpNw@mail.gmail.com>

Hi Andres,
On Fri, Apr 10, 2015 at 11:05:26AM -0700, Andres Lagar-Cavilla wrote:
[...]
>> +               if (sp->role.direct &&
>> +                       !kvm_is_reserved_pfn(pfn) &&
>> +                       PageTransCompound(pfn_to_page(pfn))) {
>
>Not your fault, but PageTransCompound is very unhappy naming, as it
>also yields true for PageHuge. Suggestion: document this check covers
>static hugetlbfs, or switch to PageCompound() check.
>
>A slightly bolder approach would be to refactor and reuse the nearly
>identical check done in transparent_hugepage_adjust, instead of
>open-coding here. In essence this code is asking for the same check,
>plus the out-of-band check for static hugepages.

PageCompound() check still return true for both transparent huge pages
and hugetlbfs pages, !PageHuge(page) && PageTransHuge(page) check can 
guarantee to catch the right transparent huge pages just as my old commit 
e76d30e20be5fc ("mm/hwpoison: fix test for a transparent huge page"). 
I will send a patch to fix this.

>
>
>> +                       drop_spte(kvm, sptep);
>> +                       sptep = rmap_get_first(*rmapp, &iter);
>> +                       need_tlb_flush = 1;
>> +               } else
>> +                       sptep = rmap_get_next(&iter);
>> +       }
>> +
>> +       return need_tlb_flush;
>> +}
>> +
>> +void kvm_mmu_zap_collapsible_sptes(struct kvm *kvm,
>> +                       struct kvm_memory_slot *memslot)
>> +{
>> +       bool flush = false;
>> +       unsigned long *rmapp;
>> +       unsigned long last_index, index;
>> +       gfn_t gfn_start, gfn_end;
>> +
>> +       spin_lock(&kvm->mmu_lock);
>> +
>> +       gfn_start = memslot->base_gfn;
>> +       gfn_end = memslot->base_gfn + memslot->npages - 1;
>> +
>> +       if (gfn_start >= gfn_end)
>> +               goto out;
>
>I don't understand the value of this check here. Are we looking for a
>broken memslot? Shouldn't this be a BUG_ON? Is this the place to care
>about these things? npages is capped to KVM_MEM_MAX_NR_PAGES, i.e.
>2^31. A 64 bit overflow would be caused by a gigantic gfn_start which
>would be trouble in many other ways.
>
>All this to say: please remove the above 5 lines and make code simpler.

I will send a patch to cleanup it. Thanks for your review. :)

Regards,
Wanpeng Li


  parent reply	other threads:[~2015-04-14  5:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-03  7:40 [PATCH v3] kvm: mmu: lazy collapse small sptes into large sptes Wanpeng Li
2015-04-07 15:41 ` Paolo Bonzini
2015-04-10 18:05 ` Andres Lagar-Cavilla
2015-04-13  1:45   ` Xiao Guangrong
2015-04-13  5:59     ` Wanpeng Li
2015-04-13  6:31     ` Andres Lagar-Cavilla
2015-04-14  4:04       ` [PATCH] KVM: MMU: fix comment in kvm_mmu_zap_collapsible_spte Xiao Guangrong
2015-04-15 15:05         ` Paolo Bonzini
2015-04-16  0:38           ` Xiao Guangrong
2015-04-16  8:14           ` Wanpeng Li
2015-04-14  5:25   ` Wanpeng Li [this message]
2015-04-14  6:06     ` [PATCH v3] kvm: mmu: lazy collapse small sptes into large sptes Andres Lagar-Cavilla
2015-04-14  6:38       ` Wanpeng Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150414052539.GA2559@kernel \
    --to=wanpeng.li@linux.intel.com \
    --cc=andreslc@google.com \
    --cc=digitaleric@google.com \
    --cc=guangrong.xiao@linux.intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox