public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Srivatsa Vaddagiri <vatsa@linux.vnet.ibm.com>
To: Avi Kivity <avi@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Anthony Liguori <aliguori@linux.vnet.ibm.com>,
	qemu-devel@nongnu.org, kvm@vger.kernel.org,
	Chris Wright <chrisw@sous-sol.org>, Ingo Molnar <mingo@elte.hu>,
	Mike Galbraith <efault@gmx.de>, Rik van Riel <riel@redhat.com>
Subject: Re: [PATCH] qemu-kvm: response to SIGUSR1 to start/stop a VCPU (v2)
Date: Thu, 2 Dec 2010 20:58:20 +0530	[thread overview]
Message-ID: <20101202152819.GB16411@linux.vnet.ibm.com> (raw)
In-Reply-To: <20101202152716.GA16411@linux.vnet.ibm.com>

Actually CCing Rik now!

On Thu, Dec 02, 2010 at 08:57:16PM +0530, Srivatsa Vaddagiri wrote:
> On Thu, Dec 02, 2010 at 03:49:44PM +0200, Avi Kivity wrote:
> > On 12/02/2010 03:13 PM, Srivatsa Vaddagiri wrote:
> > >On Thu, Dec 02, 2010 at 02:41:35PM +0200, Avi Kivity wrote:
> > >>  >>   What I'd like to see in directed yield is donating exactly the
> > >>  >>   amount of vruntime that's needed to make the target thread run.
> > >>  >
> > >>  >I presume this requires the target vcpu to move left in rb-tree to run
> > >>  >earlier than scheduled currently and that it doesn't involve any
> > >>  >change to the sched_period() of target vcpu?
> > >>  >
> > >>  >Just was wondering how this would work in case of buggy guests. Lets say that a
> > >>  >guest ran into a AB<->BA deadlock. VCPU0 spins on lock B (held by VCPU1
> > >>  >currently), while VCPU spins on lock A (held by VCPU0 currently). Both keep
> > >>  >boosting each other's vruntime, potentially affecting fairtime for other guests
> > >>  >(to the point of starving them perhaps)?
> > >>
> > >>  We preserve vruntime overall.  If you give vruntime to someone, it
> > >>  comes at your own expense.  Overall vruntime is preserved.
> > >
> > >Hmm ..so I presume that this means we don't affect target thread's position in
> > >rb-tree upon donation, rather we influence its sched_period() to include
> > >donated time? IOW donation has no effect on causing the target thread to run
> > >"immediately", rather it will have the effect of causing it run "longer"
> > >whenever it runs next?
> > 
> > No.  The intent (at least mine, maybe Rik has other ideas) is to
> 
> CCing Rik now ..
> 
> > move some vruntime from current to target such that target would be
> > placed before current in the timeline.
> 
> Well ok, then this is what I had presumed earlier (about shifting target towards
> left in rb-tree).
> 
> > >Even that would require some precaution in directed yield to ensure that it
> > >doesn't unduly inflate vruntime of target, hurting fairness for other guests on
> > >same cpu as target (example guest code that can lead to this situation
> > >below):
> > >
> > >vcpu0:				vcpu1:
> > >
> > >				spinlock(A);
> > >
> > >spinlock(A);
> > >
> > >                         	while(1)
> > >				;
> > >
> > >			 	spin_unlock(A);
> > 
> > directed yield should preserve the invariant that sum(vruntime) does
> > not change.
> 
> Hmm don't think I understand this invariant sum() part. Lets take a simple
> example as below:
> 
> 
> p0	-> A0 B0 A1
> 
> p1	-> B1 C0 C1
> 
> A/B/C are VMs and A0 etc are virtual cpus. p0/1 are physical cpus
> 
> Let's say A0/A1 hit AB-BA spin-deadlock (which one can write in userspace
> delibrately). When A0 spins and exits (due to PLE) what does its directed yield
> do? Going by your statement, it can put target before current, leading to
> perhaps this arrangement in runqueue:
> 
> p0	-> A1 B0 A0
> 
> Now A1 spins and wants to do a directed yield back to A0, leading to :
> 
> p0	-> A0 B0 A1
> 
> This can go back and forth, starving B0 (iow leading to some sort of DoS
> attack).
> 
> Where does the "invariant sum" part of directed yield kick in to avoid such 
> nastiness?
> 
> - vatsa

  reply	other threads:[~2010-12-02 16:12 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-23 16:49 [PATCH] qemu-kvm: response to SIGUSR1 to start/stop a VCPU (v2) Anthony Liguori
2010-11-23 19:35 ` [Qemu-devel] " Blue Swirl
2010-11-23 21:46   ` Anthony Liguori
2010-11-23 23:43     ` Paolo Bonzini
2010-11-24  1:15       ` Anthony Liguori
2010-11-24  2:08         ` Paolo Bonzini
2010-11-24  8:18 ` Avi Kivity
2010-11-24 13:58   ` Anthony Liguori
2010-11-24 14:23     ` Avi Kivity
2010-12-01 12:37       ` Srivatsa Vaddagiri
2010-12-01 12:56         ` Avi Kivity
2010-12-01 16:12           ` Srivatsa Vaddagiri
2010-12-01 16:25             ` Peter Zijlstra
2010-12-01 17:17               ` Chris Wright
2010-12-01 17:22                 ` Peter Zijlstra
2010-12-01 17:26                   ` Rik van Riel
2010-12-01 19:07                     ` Peter Zijlstra
2010-12-01 19:24                       ` Rik van Riel
2010-12-01 19:35                         ` Peter Zijlstra
2010-12-01 19:42                           ` Rik van Riel
2010-12-01 19:47                             ` Peter Zijlstra
2010-12-02  9:07                       ` Avi Kivity
2010-12-01 17:46                   ` Chris Wright
2010-12-01 17:29               ` Srivatsa Vaddagiri
2010-12-01 17:45                 ` Peter Zijlstra
2010-12-01 18:00                   ` Srivatsa Vaddagiri
2010-12-01 19:09                     ` Peter Zijlstra
2010-12-02  9:17                       ` Avi Kivity
2010-12-02 11:47                         ` Srivatsa Vaddagiri
2010-12-02 12:22                           ` Srivatsa Vaddagiri
2010-12-02 12:41                           ` Avi Kivity
2010-12-02 13:13                             ` Srivatsa Vaddagiri
2010-12-02 13:49                               ` Avi Kivity
2010-12-02 15:27                                 ` Srivatsa Vaddagiri
2010-12-02 15:28                                   ` Srivatsa Vaddagiri [this message]
2010-12-02 15:33                                   ` Avi Kivity
2010-12-02 15:44                                     ` Srivatsa Vaddagiri
2010-12-02 12:19                         ` Srivatsa Vaddagiri
2010-12-02 12:42                           ` Avi Kivity
2010-12-02  9:14                 ` Avi Kivity

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=20101202152819.GB16411@linux.vnet.ibm.com \
    --to=vatsa@linux.vnet.ibm.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=aliguori@linux.vnet.ibm.com \
    --cc=avi@redhat.com \
    --cc=chrisw@sous-sol.org \
    --cc=efault@gmx.de \
    --cc=kvm@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=qemu-devel@nongnu.org \
    --cc=riel@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