[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2] xen/sched: fix restore_vcpu_affinity() by removing it


  • To: Juergen Gross <jgross@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
  • Date: Fri, 21 Oct 2022 11:07:56 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1q+SXao/O4tCvCbHRfo58mEzeauQ/uzK8NowfFpLEns=; b=aiz/W5fMVbaaWb6V8IJcxvnk+s9sZ0GfaZGOHbfuLcYhbu/h6IN2sXDfHp+1P4giLvxw0BWolHxsMuLyBcz96ZRISDn143BaJwFSe/sgk8W2sMKqxoNvn+rf6c3o/9ozPK25hQkMT7rFBuMVwLhIg7es+bwO7diIFVGbOlGfNN5yFyL1f020kZ8C9+wrtBxBLyFBxRSpVFMAxtPlDwB72b1OozIMGr7bMuhOwJviZsmxv0P8CP0wKCj17aBEERFKwlBjw9zX8uabMctMkh8QvkkDN9JzOG5t8Slm9LnYztU4kUFObaHm7H/vPIqjiV5seM7WUxzM3qV5DymVEj+Z1w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h/ERgk/FasxgZcVEB+upE40um5GXefiekg/B3ZYlnIquwvGsvffRSMAvi4VlptkG4TmUrR6FSHjTYG4Y/kCNjiFHDmSSxaWcA2vJesXStho1lyG9P4nURu/71p1yFkmnlnVqBLXzPjytDFWSD+7KzliO29c0UoP9zFd4ys936qV91VKg61muoDU2JW85HoAlOIHH/pNepK0mbetBvYXffRm5WyRmR+6RghhIx8CHjmLsH5GqOSL3aGJimjgVrH0RtfkSs2IJxVbfiUi5zQBXZmTwNUnCrhYgLqhJPhFqDOMGPri75N2ijruI/BXVw0QZon+8CgG7+3pYf1T7f+lULA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Jan Beulich <jbeulich@xxxxxxxx>, Roger Pau Monne <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, George Dunlap <George.Dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Dario Faggioli <dfaggioli@xxxxxxxx>, Henry Wang <Henry.Wang@xxxxxxx>, Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Fri, 21 Oct 2022 11:08:14 +0000
  • Ironport-data: A9a23:qzwhEaAMU5XdMhVWkefolAYPlx7EJoYKDSr04L1icEF8aCcT4heQU07ArUqNFxZbRdHnUmJwcRT8AexJdDrOOQsxw/KwnzBVtY21JjzeJeG6eYGzdhbNoMhgYURaVpsw33cKaHaoaMlynJCRidbIOQfu5N3kt2qZvhJLVypltq6FC2hH7nhEi9dx9x+WE5ojWKRqpH4B5jJY6h4mzY0UBGZn/pwxs9m2z+ZQo3RRQKvgW60uC579f/57hSLsZRZULv6HhIxr7eCJhnSxC2SB7+qhAur3ncYQj8IWyMnsRQnviIhUWp/jUyRHdlicUy1vexzbVXDeL0oYObD6QGLtQ+UQIbJwJ9RaD6rxMb/Wnwc5DRpALBxO/nCkPF3LHUXTrfheoXn8ePOzwFNjmpCAdaTI4JKsRjm41WANWcEVitZLJbQmmVMVTtTc/Qfofs4t0A7N6AI7eZf78c53fYtB5fB1xVQE67XFsXCSSVsqUsSAqqYe0d+VOYpkMgfipCSqJUCm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lAAgL+i0QaMzUhHV+zDG7VV71OXPzlnL3M04gAZklsu85hah6YB0J9KTFnq4nwBbHbwaf/T5Z/jmNvT9ZM7lRUQyF+t40npJyCggaJrhBhv4i6F8l+UA/+fz3FM=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHY5TsCDBxhIyGpEE69vEHtm4vF364YsEgA
  • Thread-topic: [PATCH v2] xen/sched: fix restore_vcpu_affinity() by removing it

On 21/10/2022 11:50, Juergen Gross wrote:
> When the system is coming up after having been suspended,
> restore_vcpu_affinity() is called for each domain in order to adjust
> the vcpu's affinity settings in case a cpu didn't come to live again.
>
> The way restore_vcpu_affinity() is doing that is wrong, because the
> specific scheduler isn't being informed about a possible migration of
> the vcpu to another cpu. Additionally the migration is often even
> happening if all cpus are running again, as it is done without check
> whether it is really needed.
>
> As cpupool management is already calling cpu_disable_scheduler() for
> cpus not having come up again, and cpu_disable_scheduler() is taking
> care of eventually needed vcpu migration in the proper way, there is
> simply no need for restore_vcpu_affinity().
>
> So just remove restore_vcpu_affinity() completely, together with the
> no longer used sched_reset_affinity_broken().
>
> Fixes: 8a04eaa8ea83 ("xen/sched: move some per-vcpu items to struct 
> sched_unit")
> Reported-by: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
> Acked-by: Dario Faggioli <dfaggioli@xxxxxxxx>
> Release-acked-by: Henry Wang <Henry.Wang@xxxxxxx>
> Signed-off-by: Juergen Gross <jgross@xxxxxxxx>

For whomever commits this, Marek's T-by on v1 specifically included the
delta including in v2, and is therefore still applicable.

~Andrew

> ---
> V2:
> - also remove sched_reset_affinity_broken() (Jan Beulich)
> ---
>  xen/arch/x86/acpi/power.c |  3 --
>  xen/common/sched/core.c   | 78 ---------------------------------------
>  xen/include/xen/sched.h   |  1 -
>  3 files changed, 82 deletions(-)
>
> diff --git a/xen/arch/x86/acpi/power.c b/xen/arch/x86/acpi/power.c
> index 1bb4d78392..b76f673acb 100644
> --- a/xen/arch/x86/acpi/power.c
> +++ b/xen/arch/x86/acpi/power.c
> @@ -159,10 +159,7 @@ static void thaw_domains(void)
>  
>      rcu_read_lock(&domlist_read_lock);
>      for_each_domain ( d )
> -    {
> -        restore_vcpu_affinity(d);
>          domain_unpause(d);
> -    }
>      rcu_read_unlock(&domlist_read_lock);
>  }
>  
> diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c
> index 83455fbde1..23fa6845a8 100644
> --- a/xen/common/sched/core.c
> +++ b/xen/common/sched/core.c
> @@ -1188,84 +1188,6 @@ static bool sched_check_affinity_broken(const struct 
> sched_unit *unit)
>      return false;
>  }
>  
> -static void sched_reset_affinity_broken(const struct sched_unit *unit)
> -{
> -    struct vcpu *v;
> -
> -    for_each_sched_unit_vcpu ( unit, v )
> -        v->affinity_broken = false;
> -}
> -
> -void restore_vcpu_affinity(struct domain *d)
> -{
> -    unsigned int cpu = smp_processor_id();
> -    struct sched_unit *unit;
> -
> -    ASSERT(system_state == SYS_STATE_resume);
> -
> -    rcu_read_lock(&sched_res_rculock);
> -
> -    for_each_sched_unit ( d, unit )
> -    {
> -        spinlock_t *lock;
> -        unsigned int old_cpu = sched_unit_master(unit);
> -        struct sched_resource *res;
> -
> -        ASSERT(!unit_runnable(unit));
> -
> -        /*
> -         * Re-assign the initial processor as after resume we have no
> -         * guarantee the old processor has come back to life again.
> -         *
> -         * Therefore, here, before actually unpausing the domains, we should
> -         * set v->processor of each of their vCPUs to something that will
> -         * make sense for the scheduler of the cpupool in which they are in.
> -         */
> -        lock = unit_schedule_lock_irq(unit);
> -
> -        cpumask_and(cpumask_scratch_cpu(cpu), unit->cpu_hard_affinity,
> -                    cpupool_domain_master_cpumask(d));
> -        if ( cpumask_empty(cpumask_scratch_cpu(cpu)) )
> -        {
> -            if ( sched_check_affinity_broken(unit) )
> -            {
> -                sched_set_affinity(unit, unit->cpu_hard_affinity_saved, 
> NULL);
> -                sched_reset_affinity_broken(unit);
> -                cpumask_and(cpumask_scratch_cpu(cpu), 
> unit->cpu_hard_affinity,
> -                            cpupool_domain_master_cpumask(d));
> -            }
> -
> -            if ( cpumask_empty(cpumask_scratch_cpu(cpu)) )
> -            {
> -                /* Affinity settings of one vcpu are for the complete unit. 
> */
> -                printk(XENLOG_DEBUG "Breaking affinity for %pv\n",
> -                       unit->vcpu_list);
> -                sched_set_affinity(unit, &cpumask_all, NULL);
> -                cpumask_and(cpumask_scratch_cpu(cpu), 
> unit->cpu_hard_affinity,
> -                            cpupool_domain_master_cpumask(d));
> -            }
> -        }
> -
> -        res = get_sched_res(cpumask_any(cpumask_scratch_cpu(cpu)));
> -        sched_set_res(unit, res);
> -
> -        spin_unlock_irq(lock);
> -
> -        /* v->processor might have changed, so reacquire the lock. */
> -        lock = unit_schedule_lock_irq(unit);
> -        res = sched_pick_resource(unit_scheduler(unit), unit);
> -        sched_set_res(unit, res);
> -        spin_unlock_irq(lock);
> -
> -        if ( old_cpu != sched_unit_master(unit) )
> -            sched_move_irqs(unit);
> -    }
> -
> -    rcu_read_unlock(&sched_res_rculock);
> -
> -    domain_update_node_affinity(d);
> -}
> -
>  /*
>   * This function is used by cpu_hotplug code via cpu notifier chain
>   * and from cpupools to switch schedulers on a cpu.
> diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
> index 557b3229f6..072e4846aa 100644
> --- a/xen/include/xen/sched.h
> +++ b/xen/include/xen/sched.h
> @@ -1019,7 +1019,6 @@ void vcpu_set_periodic_timer(struct vcpu *v, s_time_t 
> value);
>  void sched_setup_dom0_vcpus(struct domain *d);
>  int vcpu_temporary_affinity(struct vcpu *v, unsigned int cpu, uint8_t 
> reason);
>  int vcpu_set_hard_affinity(struct vcpu *v, const cpumask_t *affinity);
> -void restore_vcpu_affinity(struct domain *d);
>  int vcpu_affinity_domctl(struct domain *d, uint32_t cmd,
>                           struct xen_domctl_vcpuaffinity *vcpuaff);
>  


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.