Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1291898 > unrolled thread
| Started by | Kai Huang <kai.huang@linux.intel.com> |
|---|---|
| First post | 2015-12-15 08:20 +0100 |
| Last post | 2015-12-15 09:10 +0100 |
| Articles | 2 — 1 participant |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH 05/11] KVM: page track: introduce kvm_page_track_{add,remove}_page Kai Huang <kai.huang@linux.intel.com> - 2015-12-15 08:20 +0100
Re: [PATCH 05/11] KVM: page track: introduce kvm_page_track_{add,remove}_page Kai Huang <kai.huang@linux.intel.com> - 2015-12-15 09:10 +0100
| From | Kai Huang <kai.huang@linux.intel.com> |
|---|---|
| Date | 2015-12-15 08:20 +0100 |
| Subject | Re: [PATCH 05/11] KVM: page track: introduce kvm_page_track_{add,remove}_page |
| Message-ID | <qFS3T-QA-3@gated-at.bofh.it> |
On 12/01/2015 02:26 AM, Xiao Guangrong wrote:
> These two functions are the user APIs:
> - kvm_page_track_add_page(): add the page to the tracking pool after
> that later specified access on that page will be tracked
>
> - kvm_page_track_remove_page(): remove the page from the tracking pool,
> the specified access on the page is not tracked after the last user is
> gone
>
> Both of these are called under the protection of kvm->srcu or
> kvm->slots_lock
>
> Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
> ---
> arch/x86/include/asm/kvm_page_track.h | 5 ++
> arch/x86/kvm/page_track.c | 95 +++++++++++++++++++++++++++++++++++
> 2 files changed, 100 insertions(+)
>
> diff --git a/arch/x86/include/asm/kvm_page_track.h b/arch/x86/include/asm/kvm_page_track.h
> index 347d5c9..9cc17c6 100644
> --- a/arch/x86/include/asm/kvm_page_track.h
> +++ b/arch/x86/include/asm/kvm_page_track.h
> @@ -10,4 +10,9 @@ int kvm_page_track_create_memslot(struct kvm_memory_slot *slot,
> unsigned long npages);
> void kvm_page_track_free_memslot(struct kvm_memory_slot *free,
> struct kvm_memory_slot *dont);
> +
> +void kvm_page_track_add_page(struct kvm *kvm, gfn_t gfn,
> + enum kvm_page_track_mode mode);
> +void kvm_page_track_remove_page(struct kvm *kvm, gfn_t gfn,
> + enum kvm_page_track_mode mode);
> #endif
> diff --git a/arch/x86/kvm/page_track.c b/arch/x86/kvm/page_track.c
> index 0338d36..ad510db 100644
> --- a/arch/x86/kvm/page_track.c
> +++ b/arch/x86/kvm/page_track.c
> @@ -56,3 +56,98 @@ void kvm_page_track_free_memslot(struct kvm_memory_slot *free,
> if (!dont || free->arch.gfn_track != dont->arch.gfn_track)
> page_track_slot_free(free);
> }
> +
> +static bool check_mode(enum kvm_page_track_mode mode)
> +{
> + if (mode < 0 || mode >= KVM_PAGE_TRACK_MAX)
> + return false;
> +
> + return true;
> +}
> +
> +static void update_gfn_track(struct kvm_memory_slot *slot, gfn_t gfn,
> + enum kvm_page_track_mode mode, int count)
> +{
> + int index, val;
> +
> + index = gfn_to_index(gfn, slot->base_gfn, PT_PAGE_TABLE_LEVEL);
> +
> + slot->arch.gfn_track[mode][index] += count;
> + val = slot->arch.gfn_track[mode][index];
> + WARN_ON(val < 0);
> +}
> +
> +/*
> + * add guest page to the tracking pool so that corresponding access on that
> + * page will be intercepted.
> + *
> + * It should be called under the protection of kvm->srcu or kvm->slots_lock
> + *
> + * @kvm: the guest instance we are interested in.
> + * @gfn: the guest page.
> + * @mode: tracking mode, currently only write track is supported.
> + */
> +void kvm_page_track_add_page(struct kvm *kvm, gfn_t gfn,
> + enum kvm_page_track_mode mode)
> +{
> + struct kvm_memslots *slots;
> + struct kvm_memory_slot *slot;
> + int i;
> +
> + WARN_ON(!check_mode(mode));
> +
> + for (i = 0; i < KVM_ADDRESS_SPACE_NUM; i++) {
> + slots = __kvm_memslots(kvm, i);
> + slot = __gfn_to_memslot(slots, gfn);
> +
> + spin_lock(&kvm->mmu_lock);
> + update_gfn_track(slot, gfn, mode, 1);
> +
> + /*
> + * new track stops large page mapping for the
> + * tracked page.
> + */
> + kvm_mmu_gfn_disallow_lpage(slot, gfn);
Where is kvm_mmu_gfn_disallow_lpage? Neither did I see it in your patch
nor in my own latest KVM repo without your patch :)
> +
> + if (mode == KVM_PAGE_TRACK_WRITE)
> + if (kvm_mmu_slot_gfn_write_protect(kvm, slot, gfn))
> + kvm_flush_remote_tlbs(kvm);
Neither can I find kvm_mmu_slot_gfn_write_protect. Did I miss something?
Thanks,
-Kai
> + spin_unlock(&kvm->mmu_lock);
> + }
> +}
> +
> +/*
> + * remove the guest page from the tracking pool which stops the interception
> + * of corresponding access on that page. It is the opposed operation of
> + * kvm_page_track_add_page().
> + *
> + * It should be called under the protection of kvm->srcu or kvm->slots_lock
> + *
> + * @kvm: the guest instance we are interested in.
> + * @gfn: the guest page.
> + * @mode: tracking mode, currently only write track is supported.
> + */
> +void kvm_page_track_remove_page(struct kvm *kvm, gfn_t gfn,
> + enum kvm_page_track_mode mode)
> +{
> + struct kvm_memslots *slots;
> + struct kvm_memory_slot *slot;
> + int i;
> +
> + WARN_ON(!check_mode(mode));
> +
> + for (i = 0; i < KVM_ADDRESS_SPACE_NUM; i++) {
> + slots = __kvm_memslots(kvm, i);
> + slot = __gfn_to_memslot(slots, gfn);
> +
> + spin_lock(&kvm->mmu_lock);
> + update_gfn_track(slot, gfn, mode, -1);
> +
> + /*
> + * allow large page mapping for the tracked page
> + * after the tracker is gone.
> + */
> + kvm_mmu_gfn_allow_lpage(slot, gfn);
> + spin_unlock(&kvm->mmu_lock);
> + }
> +}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Kai Huang <kai.huang@linux.intel.com> |
|---|---|
| Date | 2015-12-15 09:10 +0100 |
| Message-ID | <qFSQj-1nP-29@gated-at.bofh.it> |
| In reply to | #1291898 |
On 12/15/2015 03:15 PM, Kai Huang wrote:
>
>
> On 12/01/2015 02:26 AM, Xiao Guangrong wrote:
>> These two functions are the user APIs:
>> - kvm_page_track_add_page(): add the page to the tracking pool after
>> that later specified access on that page will be tracked
>>
>> - kvm_page_track_remove_page(): remove the page from the tracking pool,
>> the specified access on the page is not tracked after the last
>> user is
>> gone
>>
>> Both of these are called under the protection of kvm->srcu or
>> kvm->slots_lock
>>
>> Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
>> ---
>> arch/x86/include/asm/kvm_page_track.h | 5 ++
>> arch/x86/kvm/page_track.c | 95
>> +++++++++++++++++++++++++++++++++++
>> 2 files changed, 100 insertions(+)
>>
>> diff --git a/arch/x86/include/asm/kvm_page_track.h
>> b/arch/x86/include/asm/kvm_page_track.h
>> index 347d5c9..9cc17c6 100644
>> --- a/arch/x86/include/asm/kvm_page_track.h
>> +++ b/arch/x86/include/asm/kvm_page_track.h
>> @@ -10,4 +10,9 @@ int kvm_page_track_create_memslot(struct
>> kvm_memory_slot *slot,
>> unsigned long npages);
>> void kvm_page_track_free_memslot(struct kvm_memory_slot *free,
>> struct kvm_memory_slot *dont);
>> +
>> +void kvm_page_track_add_page(struct kvm *kvm, gfn_t gfn,
>> + enum kvm_page_track_mode mode);
>> +void kvm_page_track_remove_page(struct kvm *kvm, gfn_t gfn,
>> + enum kvm_page_track_mode mode);
>> #endif
>> diff --git a/arch/x86/kvm/page_track.c b/arch/x86/kvm/page_track.c
>> index 0338d36..ad510db 100644
>> --- a/arch/x86/kvm/page_track.c
>> +++ b/arch/x86/kvm/page_track.c
>> @@ -56,3 +56,98 @@ void kvm_page_track_free_memslot(struct
>> kvm_memory_slot *free,
>> if (!dont || free->arch.gfn_track != dont->arch.gfn_track)
>> page_track_slot_free(free);
>> }
>> +
>> +static bool check_mode(enum kvm_page_track_mode mode)
>> +{
>> + if (mode < 0 || mode >= KVM_PAGE_TRACK_MAX)
>> + return false;
>> +
>> + return true;
>> +}
>> +
>> +static void update_gfn_track(struct kvm_memory_slot *slot, gfn_t gfn,
>> + enum kvm_page_track_mode mode, int count)
>> +{
>> + int index, val;
>> +
>> + index = gfn_to_index(gfn, slot->base_gfn, PT_PAGE_TABLE_LEVEL);
>> +
>> + slot->arch.gfn_track[mode][index] += count;
>> + val = slot->arch.gfn_track[mode][index];
>> + WARN_ON(val < 0);
>> +}
>> +
>> +/*
>> + * add guest page to the tracking pool so that corresponding access
>> on that
>> + * page will be intercepted.
>> + *
>> + * It should be called under the protection of kvm->srcu or
>> kvm->slots_lock
>> + *
>> + * @kvm: the guest instance we are interested in.
>> + * @gfn: the guest page.
>> + * @mode: tracking mode, currently only write track is supported.
>> + */
>> +void kvm_page_track_add_page(struct kvm *kvm, gfn_t gfn,
>> + enum kvm_page_track_mode mode)
>> +{
>> + struct kvm_memslots *slots;
>> + struct kvm_memory_slot *slot;
>> + int i;
>> +
>> + WARN_ON(!check_mode(mode));
>> +
>> + for (i = 0; i < KVM_ADDRESS_SPACE_NUM; i++) {
>> + slots = __kvm_memslots(kvm, i);
>> + slot = __gfn_to_memslot(slots, gfn);
>> +
>> + spin_lock(&kvm->mmu_lock);
>> + update_gfn_track(slot, gfn, mode, 1);
>> +
>> + /*
>> + * new track stops large page mapping for the
>> + * tracked page.
>> + */
>> + kvm_mmu_gfn_disallow_lpage(slot, gfn);
> Where is kvm_mmu_gfn_disallow_lpage? Neither did I see it in your
> patch nor in my own latest KVM repo without your patch :)
>
>> +
>> + if (mode == KVM_PAGE_TRACK_WRITE)
>> + if (kvm_mmu_slot_gfn_write_protect(kvm, slot, gfn))
>> + kvm_flush_remote_tlbs(kvm);
> Neither can I find kvm_mmu_slot_gfn_write_protect. Did I miss something?
Forget this reply. Looks my thunderbird has something wrong and couldn't
show your whole patch series, and I missed patch 1~3. Now I see them. Sorry.
Thanks,
-Kai
>
> Thanks,
> -Kai
>> + spin_unlock(&kvm->mmu_lock);
>> + }
>> +}
>> +
>> +/*
>> + * remove the guest page from the tracking pool which stops the
>> interception
>> + * of corresponding access on that page. It is the opposed operation of
>> + * kvm_page_track_add_page().
>> + *
>> + * It should be called under the protection of kvm->srcu or
>> kvm->slots_lock
>> + *
>> + * @kvm: the guest instance we are interested in.
>> + * @gfn: the guest page.
>> + * @mode: tracking mode, currently only write track is supported.
>> + */
>> +void kvm_page_track_remove_page(struct kvm *kvm, gfn_t gfn,
>> + enum kvm_page_track_mode mode)
>> +{
>> + struct kvm_memslots *slots;
>> + struct kvm_memory_slot *slot;
>> + int i;
>> +
>> + WARN_ON(!check_mode(mode));
>> +
>> + for (i = 0; i < KVM_ADDRESS_SPACE_NUM; i++) {
>> + slots = __kvm_memslots(kvm, i);
>> + slot = __gfn_to_memslot(slots, gfn);
>> +
>> + spin_lock(&kvm->mmu_lock);
>> + update_gfn_track(slot, gfn, mode, -1);
>> +
>> + /*
>> + * allow large page mapping for the tracked page
>> + * after the tracker is gone.
>> + */
>> + kvm_mmu_gfn_allow_lpage(slot, gfn);
>> + spin_unlock(&kvm->mmu_lock);
>> + }
>> +}
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web