All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Zhoujian (jay)" <jianjay.zhou@huawei.com>
To: Peter Xu <peterx@redhat.com>
Cc: "kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"pbonzini@redhat.com" <pbonzini@redhat.com>,
	"sean.j.christopherson@intel.com"
	<sean.j.christopherson@intel.com>,
	"wangxin (U)" <wangxinxin.wang@huawei.com>,
	"Huangweidong (C)" <weidong.huang@huawei.com>,
	"Liujinsong (Paul)" <liu.jinsong@huawei.com>
Subject: RE: [PATCH v3] KVM: x86: enable dirty log gradually in small chunks
Date: Wed, 26 Feb 2020 04:59:32 +0000	[thread overview]
Message-ID: <B2D15215269B544CADD246097EACE7474BB21BE8@dggemm508-mbx.china.huawei.com> (raw)
In-Reply-To: <20200225160758.GB127720@xz-x1>

[...]

> > >
> > >   KVM_MANUAL_PROTECT_ENABLE
> > >   KVM_MANUAL_PROTECT_INIT_ALL_SET
> >
> > I think this naming emphasizes more about "manual protect", and the
> > original naming emphasizes more about "dirty log". The object of
> > manual protect and initial-all-set is dirty log, so it seem that the
> > original names are a little more close to the thing we do.
> 
> OK.  Then maybe rename bit 0 of KVM_DIRTY_LOG_MANUAL_PROTECT2 to
> KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE?  No strong opinion but it looks
> weird to have the ending "2" in the sub-caps..

Will do.

[...]

> > > > +bool kvm_manual_dirty_log_init_set(struct kvm *kvm) {
> > > > +	return kvm->manual_dirty_log_protect &
> > > > +KVM_DIRTY_LOG_INITIALLY_SET; }
> > >
> > > Nit: this can be put into kvm_host.h as inlined.
> >
> > I'm afraid not. I tried to do it, but it can't be compiled through.
> > Since this function is shared between the kvm and kvm_intel(vmx part)
> > module, it should be exported.
> 
> What's the error?  Did you add it into the right kvm_host.h (which
> is ./include/linux/kvm_host.h, not per-arch one), and was it with "static inline"?

After adding "static inline" it can be compiled through (I mis-understood and added
"static" only last time, sorry).

[...]

> > > > @@ -3320,6 +3326,10 @@ static long
> > > kvm_vm_ioctl_check_extension_generic(struct kvm *kvm, long arg)
> > > >  	case KVM_CAP_COALESCED_PIO:
> > > >  		return 1;
> > > >  #endif
> > > > +#ifdef CONFIG_KVM_GENERIC_DIRTYLOG_READ_PROTECT
> > > > +	case KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2:
> > > > +		return KVM_DIRTY_LOG_MANUAL_CAPS;
> > >
> > > We probably can only return the new feature bit when with CONFIG_X86?
> >
> > How about to define different values in different architectures(see
> > KVM_USER_MEM_SLOTS as an example), like this:
> >
> > diff --git a/arch/arm/include/asm/kvm_host.h
> > b/arch/arm/include/asm/kvm_host.h index c3314b2..383a8ae 100644
> > --- a/arch/arm/include/asm/kvm_host.h
> > +++ b/arch/arm/include/asm/kvm_host.h
> > @@ -23,6 +23,10 @@
> >  #define KVM_HAVE_ONE_REG
> >  #define KVM_HALT_POLL_NS_DEFAULT 500000
> >
> > +#define KVM_DIRTY_LOG_MANUAL_PROTECT (1 << 0) #define
> > +KVM_DIRTY_LOG_INITIALLY_SET 0 #define KVM_DIRTY_LOG_MANUAL_CAPS
> > +KVM_DIRTY_LOG_MANUAL_PROTECT
> > +
> >  #define KVM_VCPU_MAX_FEATURES 2
> >
> >  #include <kvm/arm_vgic.h>
> > diff --git a/arch/mips/include/asm/kvm_host.h
> > b/arch/mips/include/asm/kvm_host.h
> > index 41204a4..503ee17 100644
> > --- a/arch/mips/include/asm/kvm_host.h
> > +++ b/arch/mips/include/asm/kvm_host.h
> > @@ -85,6 +85,10 @@
> >
> >  #define KVM_HALT_POLL_NS_DEFAULT 500000
> >
> > +#define KVM_DIRTY_LOG_MANUAL_PROTECT (1 << 0) #define
> > +KVM_DIRTY_LOG_INITIALLY_SET 0 #define KVM_DIRTY_LOG_MANUAL_CAPS
> > +KVM_DIRTY_LOG_MANUAL_PROTECT
> > +
> >  #ifdef CONFIG_KVM_MIPS_VZ
> >  extern unsigned long GUESTID_MASK;
> >  extern unsigned long GUESTID_FIRST_VERSION; diff --git
> > a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> > index 40a0c0f..ac05172 100644
> > --- a/arch/x86/include/asm/kvm_host.h
> > +++ b/arch/x86/include/asm/kvm_host.h
> > @@ -49,6 +49,11 @@
> >
> >  #define KVM_IRQCHIP_NUM_PINS  KVM_IOAPIC_NUM_PINS
> >
> > +#define KVM_DIRTY_LOG_MANUAL_PROTECT (1 << 0) #define
> > +KVM_DIRTY_LOG_INITIALLY_SET (1 << 1) #define
> > +KVM_DIRTY_LOG_MANUAL_CAPS (KVM_DIRTY_LOG_MANUAL_PROTECT | \
> > +               KVM_DIRTY_LOG_INITIALLY_SET)
> > +
> >  /* x86-specific vcpu->requests bit members */
> >  #define KVM_REQ_MIGRATE_TIMER          KVM_ARCH_REQ(0)
> >  #define KVM_REQ_REPORT_TPR_ACCESS      KVM_ARCH_REQ(1)
> > diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index
> > e89eb67..ebd3e55 100644
> > --- a/include/linux/kvm_host.h
> > +++ b/include/linux/kvm_host.h
> > @@ -360,6 +360,18 @@ static inline unsigned long
> *kvm_second_dirty_bitmap(struct kvm_memory_slot *mem
> >         return memslot->dirty_bitmap + len /
> > sizeof(*memslot->dirty_bitmap);  }
> >
> > +#ifndef KVM_DIRTY_LOG_MANUAL_PROTECT
> > +#define KVM_DIRTY_LOG_MANUAL_PROTECT 0 #endif #ifndef
> > +KVM_DIRTY_LOG_INITIALLY_SET #define KVM_DIRTY_LOG_INITIALLY_SET 0
> > +#endif #ifndef KVM_DIRTY_LOG_MANUAL_CAPS #define
> > +KVM_DIRTY_LOG_MANUAL_CAPS 0 #endif
> 
> This seems a bit more awkward to me... You also reminded me that maybe it's
> good we put the sub-cap definition into uapi.  How about:

Sure.

> 
> ==========
> 
> diff --git a/arch/x86/include/asm/kvm_host.h
> b/arch/x86/include/asm/kvm_host.h index 40a0c0fd95ca..fcffaf8a6964 100644
> --- a/arch/x86/include/asm/kvm_host.h
> +++ b/arch/x86/include/asm/kvm_host.h
> @@ -1697,4 +1697,7 @@ static inline int kvm_cpu_get_apicid(int mps_cpu)
>  #define GET_SMSTATE(type, buf, offset)         \
>         (*(type *)((buf) + (offset) - 0x7e00))
> 
> +#define KVM_DIRTY_LOG_MANUAL_CAPS
> (KVM_DIRTY_LOG_MANUAL_PROTECT | \
> +
> KVM_DIRTY_LOG_INITIALLY_SET)
> +
>  #endif /* _ASM_X86_KVM_HOST_H */
> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index
> e89eb67356cb..39d49802ee87 100644
> --- a/include/linux/kvm_host.h
> +++ b/include/linux/kvm_host.h
> @@ -1410,4 +1410,8 @@ int kvm_vm_create_worker_thread(struct kvm *kvm,
> kvm_vm_thread_fn_t thread_fn,
>                                 uintptr_t data, const char *name,
>                                 struct task_struct **thread_ptr);
> 
> +#ifndef KVM_DIRTY_LOG_MANUAL_CAPS
> +#define KVM_DIRTY_LOG_MANUAL_CAPS
> KVM_DIRTY_LOG_MANUAL_PROTECT
> +#endif
> +
>  #endif
> diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index
> 4b95f9a31a2f..a83f7627c0c1 100644
> --- a/include/uapi/linux/kvm.h
> +++ b/include/uapi/linux/kvm.h
> @@ -1628,4 +1628,7 @@ struct kvm_hyperv_eventfd {
>  #define KVM_HYPERV_CONN_ID_MASK                0x00ffffff
>  #define KVM_HYPERV_EVENTFD_DEASSIGN    (1 << 0)
> 
> +#define KVM_DIRTY_LOG_MANUAL_PROTECT   (1 << 0)
> +#define KVM_DIRTY_LOG_INITIALLY_SET    (1 << 1)
> +
>  #endif /* __LINUX_KVM_H */
> 

I replied about this change in another thread.


Regards,
Jay Zhou


      parent reply	other threads:[~2020-02-26  4:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-24  3:25 [PATCH v3] KVM: x86: enable dirty log gradually in small chunks Jay Zhou
2020-02-24 17:05 ` Peter Xu
2020-02-24 17:38   ` Sean Christopherson
2020-02-25  4:01     ` Zhoujian (jay)
2020-02-25  3:15   ` Zhoujian (jay)
2020-02-25 16:07     ` Peter Xu
2020-02-25 19:07       ` Peter Xu
2020-02-26  4:59         ` Zhoujian (jay)
2020-02-26 15:40           ` Peter Xu
2020-02-26  4:59       ` Zhoujian (jay) [this message]

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=B2D15215269B544CADD246097EACE7474BB21BE8@dggemm508-mbx.china.huawei.com \
    --to=jianjay.zhou@huawei.com \
    --cc=kvm@vger.kernel.org \
    --cc=liu.jinsong@huawei.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=sean.j.christopherson@intel.com \
    --cc=wangxinxin.wang@huawei.com \
    --cc=weidong.huang@huawei.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 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.