Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: "Zhoujian (jay)" <jianjay.zhou@huawei.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 10:40:41 -0500	[thread overview]
Message-ID: <20200226154041.GB140200@xz-x1> (raw)
In-Reply-To: <B2D15215269B544CADD246097EACE7474BB21BF6@dggemm508-mbx.china.huawei.com>

On Wed, Feb 26, 2020 at 04:59:40AM +0000, Zhoujian (jay) wrote:
> 
> 
> > -----Original Message-----
> > From: Peter Xu [mailto:peterx@redhat.com]
> 
> [...]
> 
> > > > > > @@ -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?
> 
> Since the meaning of KVM_DIRTY_LOG_MANUAL_CAPS will change accordingly in
> different archs, we can use it in kvm_vm_ioctl_enable_cap_generic, how about:
> 
> @@ -3347,11 +3351,17 @@ static int kvm_vm_ioctl_enable_cap_generic(struct kvm *kvm,
>  {
>         switch (cap->cap) {
>  #ifdef CONFIG_KVM_GENERIC_DIRTYLOG_READ_PROTECT
> -       case KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2:
> -               if (cap->flags || (cap->args[0] & ~1))
> +       case KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2: {
> +               u64 allowed_options = KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE;
> +
> +               if (cap->args[0] & KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE)
> +                       allowed_options = KVM_DIRTY_LOG_MANUAL_CAPS;
> +
> +               if (cap->flags || (cap->args[0] & ~allowed_options))
>                         return -EINVAL;
>                 kvm->manual_dirty_log_protect = cap->args[0];
>                 return 0;
> +       }

Looks good to me.

> 
> [...]
> 
> >> How about:
> > >
> > > ==========
> > >
> > > 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
> > > +
> > 
> > Hmm... Maybe this won't work, because I saw that asm/kvm_host.h and
> > linux/kvm_host.h has no dependency between each other (which I thought they
> > had).  Right now in most cases linux/ header can be included earlier than the
> > asm/ header in C files.  So intead, maybe we can move these lines into
> > kvm_main.c directly.
> 
> I did some tests on x86, and it works. Looks good to me.
> 
> > 
> > (I'm thinking ideally linux/kvm_host.h should include asm/kvm_host.h  within
> > itself, then C files should not include asm/kvm_host.h  directly. However I dare
> > not try that right now without being able to  test compile on all archs...)
> > 
> But, I see include/linux/kvm_host.h has already included asm/kvm_host.h in the
> upstream. Do I understand your meaning correctly?

Oh you are right, my eyeball missed that... :)

Then we should be able to remove the asm/kvm_host.h in most of the C
files.  I'll prepare a patch for it.

Thanks,

-- 
Peter Xu


  reply	other threads:[~2020-02-26 15:40 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 [this message]
2020-02-26  4:59       ` Zhoujian (jay)

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=20200226154041.GB140200@xz-x1 \
    --to=peterx@redhat.com \
    --cc=jianjay.zhou@huawei.com \
    --cc=kvm@vger.kernel.org \
    --cc=liu.jinsong@huawei.com \
    --cc=pbonzini@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox