From nobody Tue Nov 11 08:27:16 2025 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=1569820966; cv=none; d=zoho.com; s=zohoarc; b=G+RRm+XYuJZpDQlMB+jLWhfIh/LioCP+uawuVWeZJkh+E1t1xGztK5wtboWqP5GBcVw7Zzm7qUaMmlyLxFZpT1CjA46wvIqGrx7A92GZedMFwP5OOzF591Hm6t2B7bNs5h0p/ZAw6JRMVm5ZkYZfL7LTh6PXRRodmdqklkOA0Sw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569820966; 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=VIKzWtMA0bq1OtNZO2A3Q1Lbw8EpwqyWaV9Gm4zmJpg=; b=PATGX+RFHLqKqUPIxbBqA+DjB6ikEAibNkGaVKdMQ7tUG7Q0OaGibzUwySqTthVIsNI/LMPPSIYh9J5u3M6i7hrUu4lvwvK1UP+R6M4mZ2cRwOuJvP7BTs7Yeb5WszT57TdhcnNGosU2OTodNhT5MTZx1ysld3DJ4VIetP2FeoU= 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 1569820966716326.3652584264795; Sun, 29 Sep 2019 22:22:46 -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 1iEo80-0001ua-95; Mon, 30 Sep 2019 05:21:44 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iEo7y-0001uU-JG for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 05:21:42 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by localhost (Halon) with ESMTPS id 2e7db179-e342-11e9-96c8-12813bfff9fa; Mon, 30 Sep 2019 05:21:40 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id AA363B021; Mon, 30 Sep 2019 05:21:39 +0000 (UTC) X-Inumbo-ID: 2e7db179-e342-11e9-96c8-12813bfff9fa X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 30 Sep 2019 07:21:19 +0200 Message-Id: <20190930052135.11257-4-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190930052135.11257-1-jgross@suse.com> References: <20190930052135.11257-1-jgross@suse.com> Subject: [Xen-devel] [PATCH v5 03/19] xen/sched: add support for multiple vcpus per sched unit where missing 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 , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich , Dario Faggioli MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" In several places there is support for multiple vcpus per sched unit missing. Add that missing support (with the exception of initial allocation) and missing helpers for that. Signed-off-by: Juergen Gross Reviewed-by: Dario Faggioli Acked-by: Jan Beulich --- RFC V2: - fix vcpu_runstate_helper() V1: - add special handling for idle unit in unit_runnable() and unit_runnable_state() V2: - handle affinity_broken correctly (Jan Beulich) V3: - type for cpu ->unsigned int (Jan Beulich) --- xen/common/domain.c | 5 ++++- xen/common/schedule.c | 9 +++++---- xen/include/xen/sched-if.h | 16 +++++++++++++++- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/xen/common/domain.c b/xen/common/domain.c index a9882509ed..93aa856bcb 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -1273,7 +1273,10 @@ int vcpu_reset(struct vcpu *v) v->async_exception_mask =3D 0; memset(v->async_exception_state, 0, sizeof(v->async_exception_state)); #endif - v->affinity_broken =3D 0; + if ( v->affinity_broken & VCPU_AFFINITY_OVERRIDE ) + vcpu_temporary_affinity(v, NR_CPUS, VCPU_AFFINITY_OVERRIDE); + if ( v->affinity_broken & VCPU_AFFINITY_WAIT ) + vcpu_temporary_affinity(v, NR_CPUS, VCPU_AFFINITY_WAIT); clear_bit(_VPF_blocked, &v->pause_flags); clear_bit(_VPF_in_reset, &v->pause_flags); =20 diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 9c1b044b49..3094ff6838 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -252,8 +252,9 @@ static inline void vcpu_runstate_change( s_time_t delta; struct sched_unit *unit =3D v->sched_unit; =20 - ASSERT(v->runstate.state !=3D new_state); ASSERT(spin_is_locked(get_sched_res(v->processor)->schedule_lock)); + if ( v->runstate.state =3D=3D new_state ) + return; =20 vcpu_urgent_count_update(v); =20 @@ -1729,14 +1730,14 @@ static void sched_switch_units(struct sched_resourc= e *sr, (next->vcpu_list->runstate.state =3D=3D RUNSTATE_runnable) ? (now - next->state_entry_time) : 0, prev->next_time); =20 - ASSERT(prev->vcpu_list->runstate.state =3D=3D RUNSTATE_running); + ASSERT(unit_running(prev)); =20 TRACE_4D(TRC_SCHED_SWITCH, prev->domain->domain_id, prev->unit_id, next->domain->domain_id, next->unit_id); =20 sched_unit_runstate_change(prev, false, now); =20 - ASSERT(next->vcpu_list->runstate.state !=3D RUNSTATE_running); + ASSERT(!unit_running(next)); sched_unit_runstate_change(next, true, now); =20 /* @@ -1858,7 +1859,7 @@ void sched_context_switched(struct vcpu *vprev, struc= t vcpu *vnext) while ( atomic_read(&next->rendezvous_out_cnt) ) cpu_relax(); } - else if ( vprev !=3D vnext ) + else if ( vprev !=3D vnext && sched_granularity =3D=3D 1 ) context_saved(vprev); } =20 diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h index 7e568a9d9f..983f2ece83 100644 --- a/xen/include/xen/sched-if.h +++ b/xen/include/xen/sched-if.h @@ -81,6 +81,11 @@ static inline bool is_unit_online(const struct sched_uni= t *unit) return false; } =20 +static inline unsigned int unit_running(const struct sched_unit *unit) +{ + return unit->runstate_cnt[RUNSTATE_running]; +} + /* Returns true if at least one vcpu of the unit is runnable. */ static inline bool unit_runnable(const struct sched_unit *unit) { @@ -126,7 +131,16 @@ static inline bool unit_runnable_state(const struct sc= hed_unit *unit) static inline void sched_set_res(struct sched_unit *unit, struct sched_resource *res) { - unit->vcpu_list->processor =3D res->master_cpu; + unsigned int cpu =3D cpumask_first(res->cpus); + struct vcpu *v; + + for_each_sched_unit_vcpu ( unit, v ) + { + ASSERT(cpu < nr_cpu_ids); + v->processor =3D cpu; + cpu =3D cpumask_next(cpu, res->cpus); + } + unit->res =3D res; } =20 --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel