From mboxrd@z Thu Jan 1 00:00:00 1970 From: George Dunlap Subject: Re: [PATCH] xen: Always ask the scheduler to re-place the vcpu when the affinity changes Date: Mon, 4 Mar 2013 14:22:16 +0000 Message-ID: <5134AE18.3050508@eu.citrix.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Keir Fraser Cc: Dario Faggioli , Jan Beulich , "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org On 04/03/13 14:23, Keir Fraser wrote: > On 04/03/2013 14:03, "George Dunlap" wrote: > >>> But that's probably a rare enough occurrence that it's better overall >>> to take the occasional double-migrate. >> Hmm -- but thinking it further, it actually seems likely that a >> different double-migrate race will happen: >> >> 1. vcpu is running on pcpu A >> 2. pcpu B runs set_affinity, setting VPF_migrate >> 3. pcpu B calls vcpu_sleep_nosync >> 4. pcpu A wakes up and grabs the schedule lock >> 5. pcpu A notices that VPF_migrate is set, and calls vcpu_migrate() >> 6. pcpu B calls vcpu_migrate() >> >> Either that, or 6 happens before 4, but 4 still happens before pcpu B >> clears VPF_migrate. >> >> It seems like we should really only call if (!v->is_running || >> v->processor == this_cpu). > It's harmless for vcpu_migrate() to be called twice. It grabs locks then > checks it has work to do (and can do that work!). If it's calling it twice occasionally, that's fine. But if it's calling it twice most of the time (and given the context I think that's relatively likely), I think we should try to change that. However, that may require some careful reworking; Jan, are you OK with checking the current patch in as-is, and having a separate patch to try to remove the if and avoid the double call? -George