From nobody Fri May 3 15:42:20 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1571839243; cv=none; d=zoho.com; s=zohoarc; b=mz66BxXc809zuRLDUmg91flLIMrOJrfwuiONBm8V8gVGQbcKrUdagCLokT591LtLp2Ci31AJWu/S7y/emvVlYSl1eThaTxVgyd4TAxq5Ot6vkrKSx+lNkbgLjh2Il1p5Ciok3nCMjdpRkRAUuyfv1ekTTlplnA/zQfyS07MyuiE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571839243; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=jSeQy0DZU5p12Z5mJvD+87/p0P6DoK+CLBQuhq37oM8=; b=lXeZhpIXuqgkX1MGFHgAFdRSQJNIuOJ1kt5iz9Z7zLLr2PfpxJJn7D5J1K+8PxYLlaqxcFeLk2cHWPBrChAuaxIsHDWWdKaB+WQ7x7TAEBkjxrJlHrimcHvYZKqcc2EGjVOTe/055qCaeD1CITYX7x1nKSfucbcQAH3a1u1Umsk= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1571839243668668.0587791655562; Wed, 23 Oct 2019 07:00:43 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNHAq-0005Jo-94; Wed, 23 Oct 2019 13:59:40 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNHAo-0005JD-NT for xen-devel@lists.xenproject.org; Wed, 23 Oct 2019 13:59:38 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 59accd26-f59d-11e9-a531-bc764e2007e4; Wed, 23 Oct 2019 13:59:37 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 1A147AD29; Wed, 23 Oct 2019 13:59:37 +0000 (UTC) X-Inumbo-ID: 59accd26-f59d-11e9-a531-bc764e2007e4 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Wed, 23 Oct 2019 15:59:35 +0200 Message-Id: <20191023135935.7692-1-jgross@suse.com> X-Mailer: git-send-email 2.16.4 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2] xen/pvhsim: fix cpu onlining X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Wei Liu , George Dunlap , Andrew Cooper , Dario Faggioli , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Since commit 8d3c326f6756d1 ("xen: let vcpu_create() select processor") the initial processor for all pv-shim vcpus will be 0, as no other cpus are online when the vcpus are created. Before that commit the vcpus would have processors set not being online yet, which worked just by chance. When the pv-shim vcpu becomes active it will have a hard affinity not matching its initial processor assignment leading to failing ASSERT()s or other problems depending on the selected scheduler. Fix that by doing the affinity setting after onlining the cpu but before taking the vcpu up. For vcpu 0 this is still in sched_setup_dom0_vcpus(), for the other vcpus setting the affinity there can be dropped. Fixes: 8d3c326f6756d1 ("xen: let vcpu_create() select processor") Reported-by: Sergey Dyasli Tested-by: Sergey Dyasli Reviewed-by: Roger Pau Monn=C3=A9 Acked-by: Jan Beulich Release-acked-by: Juergen Gross Signed-off-by: Juergen Gross Acked-by: George Dunlap --- xen/arch/x86/pv/shim.c | 2 ++ xen/common/schedule.c | 16 ++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/pv/shim.c b/xen/arch/x86/pv/shim.c index 5edbcd9ac5..4329eaaefe 100644 --- a/xen/arch/x86/pv/shim.c +++ b/xen/arch/x86/pv/shim.c @@ -837,6 +837,8 @@ long pv_shim_cpu_up(void *data) v->vcpu_id, rc); return rc; } + + vcpu_set_hard_affinity(v, cpumask_of(v->vcpu_id)); } =20 wake =3D test_and_clear_bit(_VPF_down, &v->pause_flags); diff --git a/xen/common/schedule.c b/xen/common/schedule.c index c327c40b92..e70cc70a65 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -3102,13 +3102,17 @@ void __init sched_setup_dom0_vcpus(struct domain *d) for ( i =3D 1; i < d->max_vcpus; i++ ) vcpu_create(d, i); =20 - for_each_sched_unit ( d, unit ) + /* + * PV-shim: vcpus are pinned 1:1. + * Initially only 1 cpu is online, others will be dealt with when + * onlining them. This avoids pinning a vcpu to a not yet online cpu h= ere. + */ + if ( pv_shim ) + sched_set_affinity(d->vcpu[0]->sched_unit, + cpumask_of(0), cpumask_of(0)); + else { - unsigned int id =3D unit->unit_id; - - if ( pv_shim ) - sched_set_affinity(unit, cpumask_of(id), cpumask_of(id)); - else + for_each_sched_unit ( d, unit ) { if ( !opt_dom0_vcpus_pin && !dom0_affinity_relaxed ) sched_set_affinity(unit, &dom0_cpus, NULL); --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel