All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexandru Stefan ISAILA <aisaila@bitdefender.com>
To: "dunlapg@umich.edu" <dunlapg@umich.edu>
Cc: "wei.liu2@citrix.com" <wei.liu2@citrix.com>,
	"andrew.cooper3@citrix.com" <andrew.cooper3@citrix.com>,
	"ian.jackson@eu.citrix.com" <ian.jackson@eu.citrix.com>,
	"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>,
	"paul.durrant@citrix.com" <paul.durrant@citrix.com>,
	"jbeulich@suse.com" <jbeulich@suse.com>
Subject: Re: [PATCH RFC v2] x86/domctl: Don't pause the whole domain if only getting vcpu state
Date: Thu, 22 Feb 2018 13:48:20 +0000	[thread overview]
Message-ID: <1519307300.4963.42.camel@bitdefender.com> (raw)
In-Reply-To: <CAFLBxZYDUJ5PkdByx=Y9RAgWeseGBNiY_6083Pjcu2Z+ugbZkA@mail.gmail.com>

On Mi, 2018-02-21 at 18:24 +0000, George Dunlap wrote:
> On Fri, Oct 6, 2017 at 11:02 AM, Alexandru Isaila
> <aisaila@bitdefender.com> wrote:
> >
> > This patch adds the hvm_save_one_cpu_ctxt() function.
> > It optimizes by only pausing the vcpu on all HVMSR_PER_VCPU save
> > callbacks where only data for one VCPU is required.
> Sorry it's taken so long to get back to you on this one.
>
> So first of all, a big issue with this patch in general is that
> there's way too much code duplication.  Duplicating the code in every
> case will not only increase HV code size and decrease cache
> effectiveness, it will also increase the likelihood of subtle bugs
> creeping in when the two copies don't match up.  If you were going to
> do it this way I think you'd basically have to make a *_save_*_one()
> function for each callback.

That sounds good.
>
> The only other option would be to pass a cpumask instead, and set
> either a single bit or all the bits; but that seems a bit wasteful.
> (Jan, Andy -- if you don't like this solution, now is the time to say
> so.)
>
> However -- whole pausing only one vcpu for register state should be
> fine, are you sure that it's fine for all the other callbacks?  I.e.,
> are you sure that there are no instances where vcpu N will directly
> modify vcpu M's entry in a way that will give you an inconsistent
> save
> record?

I am not sure, I've only tested the hvm_save_cpu_ctxt. The rest of the
save functions where changed so that the patch would be general.
>
> If so, you should mention it in the commit message; otherwise, it
> might be better to make this only for the cpu context (since that
> seems to be what you're mostly interested in).

Yes, I am interested in the cpu ctxt but Jan suggested to make this
change for all save functions.
>
> Further comments below...
>
> >
> > -static int hvm_save_cpu_ctxt(struct domain *d,
> > hvm_domain_context_t *h)
> > +void hvm_save_one_cpu_ctxt(struct vcpu *v, struct hvm_hw_cpu
> > *ctxt)
> I'd call this hvm_save_cpu_ctxt_one()  (with the _one at the end);
> same with all the other singleton callbacks.
>
> >
> > diff --git a/xen/arch/x86/hvm/save.c b/xen/arch/x86/hvm/save.c
> > index 8984a23..97b56f7 100644
> > --- a/xen/arch/x86/hvm/save.c
> > +++ b/xen/arch/x86/hvm/save.c
> > @@ -138,6 +138,7 @@ int hvm_save_one(struct domain *d, unsigned int
> > typecode, unsigned int instance,
> >      int rv;
> >      hvm_domain_context_t ctxt = { };
> >      const struct hvm_save_descriptor *desc;
> > +    bool is_single_instance = false;
> As far as I can tell is mostly unnecessary -- if you look at the
> original code, the rather wonky algorithm is:
>
> * Pause all vcpus
> * Collect data for all vcpus
> * Loop over this data until we find one whose instance id matches the
> one we're looking for, and copy it out.
> * Unpause all vcpus
>
> In other words, hvm_save_one(), as the name suggests, only copies a
> single instance anyway.  If anyone ever passed d->max_vcpus, then
> nothing would be copied (since none of the individual records would
> ever match that "instance").
>
> You will need to pause the whole domain for callbacks not of type
> HVMSR_PER_VCPU; but in any case you'll only ever have to copy a
> single
> record.  So you can just re-write this function without the loop, now
> that we have a way to ask the individual callbacks for only a single
> instance.
>
> One other note about the patch as it is: In the error path you forget
> to un-pause.
Thanks, will do.

~Alex
>
>  -George
>

________________________
This email was scanned by Bitdefender
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

      parent reply	other threads:[~2018-02-22 13:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-06 10:02 [PATCH RFC v2] x86/domctl: Don't pause the whole domain if only getting vcpu state Alexandru Isaila
2017-10-23  9:19 ` Ping: " Alexandru Stefan ISAILA
2018-01-05  8:58 ` Alexandru Stefan ISAILA
2018-02-19  8:55   ` Alexandru Stefan ISAILA
2018-02-21 18:24 ` George Dunlap
2018-02-22  8:20   ` Jan Beulich
2018-02-22 13:48   ` Alexandru Stefan ISAILA [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=1519307300.4963.42.camel@bitdefender.com \
    --to=aisaila@bitdefender.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=dunlapg@umich.edu \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=paul.durrant@citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /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.