From nobody Mon Feb 9 13:09:32 2026 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=1564122418; cv=none; d=zoho.com; s=zohoarc; b=gb7NArOoj9Z51stw8ZufCrZ0c1wBaXZkrSeUxlwQHAH/kmagfgCjb2nzP2/Vupj3IIsJtM+PnxoB+VIOJ5MebtZVAGiPKbJRH5DsR2fk2kJEREtcpEk4Vb5pDslZ2EHLxTsicnIqf/r8cwV2z3J7rw1dVOiBqjiqDKeXXMLo1Vk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564122418; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=L/Avbx22qE7G5slZ+2rtTpVKxlNCPuXeCZHP/RnFNK8=; b=OrqrjdHIN1mnICVvrfysSHD/1i1omCIEdb8aAbkywJ9c7oDdBrWFqcDUpXedMj6c0209fHtYZZ68vplJVG5J0LcNjUaBkUWKej8NIWs3RHDVG29yUr7LTY0iIDQUTo5UVboJfsKG0HWS3hwSrfQIRpniLsvqKnXkJyldxQOSGi8= 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 1564122418781814.4652306395029; Thu, 25 Jul 2019 23:26:58 -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 1hqtfv-00038Q-9q; Fri, 26 Jul 2019 06:25:55 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hqtft-00038K-NA for xen-devel@lists.xenproject.org; Fri, 26 Jul 2019 06:25:53 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 3730ec1e-af6e-11e9-8980-bc764e045a96; Fri, 26 Jul 2019 06:25:52 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 924C1AD31; Fri, 26 Jul 2019 06:25:51 +0000 (UTC) X-Inumbo-ID: 3730ec1e-af6e-11e9-8980-bc764e045a96 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Fri, 26 Jul 2019 08:25:51 +0200 Message-ID: <156412235104.2385.3911161728130674771.stgit@Palanthas> In-Reply-To: <156412188377.2385.12588508835559819141.stgit@Palanthas> References: <156412188377.2385.12588508835559819141.stgit@Palanthas> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 1/4] xen: sched: refector code around vcpu_deassign() in null scheduler 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: George Dunlap Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" vcpu_deassign() is called only once (in _vcpu_remove()). Let's consolidate the two functions into one. No functional change intended. Signed-off-by: Dario Faggioli Acked-by: George Dunlap --- xen/common/sched_null.c | 76 ++++++++++++++++++++++---------------------= ---- 1 file changed, 35 insertions(+), 41 deletions(-) diff --git a/xen/common/sched_null.c b/xen/common/sched_null.c index c02c1b9c1f..c47c1b5aae 100644 --- a/xen/common/sched_null.c +++ b/xen/common/sched_null.c @@ -358,9 +358,14 @@ static void vcpu_assign(struct null_private *prv, stru= ct vcpu *v, } } =20 -static void vcpu_deassign(struct null_private *prv, struct vcpu *v, - unsigned int cpu) +static void vcpu_deassign(struct null_private *prv, struct vcpu *v) { + unsigned int bs; + unsigned int cpu =3D v->processor; + struct null_vcpu *wvc; + + ASSERT(list_empty(&null_vcpu(v)->waitq_elem)); + per_cpu(npc, cpu).vcpu =3D NULL; cpumask_set_cpu(cpu, &prv->cpus_free); =20 @@ -377,6 +382,32 @@ static void vcpu_deassign(struct null_private *prv, st= ruct vcpu *v, d.cpu =3D cpu; __trace_var(TRC_SNULL_VCPU_DEASSIGN, 1, sizeof(d), &d); } + + spin_lock(&prv->waitq_lock); + + /* + * If v is assigned to a pCPU, let's see if there is someone waiting, + * suitable to be assigned to it (prioritizing vcpus that have + * soft-affinity with cpu). + */ + for_each_affinity_balance_step( bs ) + { + list_for_each_entry( wvc, &prv->waitq, waitq_elem ) + { + if ( bs =3D=3D BALANCE_SOFT_AFFINITY && !has_soft_affinity(wvc= ->vcpu) ) + continue; + + if ( vcpu_check_affinity(wvc->vcpu, cpu, bs) ) + { + list_del_init(&wvc->waitq_elem); + vcpu_assign(prv, wvc->vcpu, cpu); + cpu_raise_softirq(cpu, SCHEDULE_SOFTIRQ); + spin_unlock(&prv->waitq_lock); + return; + } + } + } + spin_unlock(&prv->waitq_lock); } =20 /* Change the scheduler of cpu to us (null). */ @@ -459,43 +490,6 @@ static void null_vcpu_insert(const struct scheduler *o= ps, struct vcpu *v) SCHED_STAT_CRANK(vcpu_insert); } =20 -static void _vcpu_remove(struct null_private *prv, struct vcpu *v) -{ - unsigned int bs; - unsigned int cpu =3D v->processor; - struct null_vcpu *wvc; - - ASSERT(list_empty(&null_vcpu(v)->waitq_elem)); - - vcpu_deassign(prv, v, cpu); - - spin_lock(&prv->waitq_lock); - - /* - * If v is assigned to a pCPU, let's see if there is someone waiting, - * suitable to be assigned to it (prioritizing vcpus that have - * soft-affinity with cpu). - */ - for_each_affinity_balance_step( bs ) - { - list_for_each_entry( wvc, &prv->waitq, waitq_elem ) - { - if ( bs =3D=3D BALANCE_SOFT_AFFINITY && !has_soft_affinity(wvc= ->vcpu) ) - continue; - - if ( vcpu_check_affinity(wvc->vcpu, cpu, bs) ) - { - list_del_init(&wvc->waitq_elem); - vcpu_assign(prv, wvc->vcpu, cpu); - cpu_raise_softirq(cpu, SCHEDULE_SOFTIRQ); - spin_unlock(&prv->waitq_lock); - return; - } - } - } - spin_unlock(&prv->waitq_lock); -} - static void null_vcpu_remove(const struct scheduler *ops, struct vcpu *v) { struct null_private *prv =3D null_priv(ops); @@ -519,7 +513,7 @@ static void null_vcpu_remove(const struct scheduler *op= s, struct vcpu *v) ASSERT(per_cpu(npc, v->processor).vcpu =3D=3D v); ASSERT(!cpumask_test_cpu(v->processor, &prv->cpus_free)); =20 - _vcpu_remove(prv, v); + vcpu_deassign(prv, v); =20 out: vcpu_schedule_unlock_irq(lock, v); @@ -605,7 +599,7 @@ static void null_vcpu_migrate(const struct scheduler *o= ps, struct vcpu *v, */ if ( likely(list_empty(&nvc->waitq_elem)) ) { - _vcpu_remove(prv, v); + vcpu_deassign(prv, v); SCHED_STAT_CRANK(migrate_running); } else _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel