From nobody Mon Feb 9 17:37:30 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=1568451263; cv=none; d=zoho.com; s=zohoarc; b=VkuMRaeBHGvkNGb5LUB4NtjIQGuG1xJ5nHAp4wqXqKbs6+O1GprSE/rB2mSqtHVtgDg/IeDt8Q2cpMhszIO2JRl5BEj7ef+sxZRW9SxTXslljsEDFbscbwGQnuB1L8oRLDJ0HjX398cZrEuWZmnAprjobtRWVS5BiiS53Y5EDfU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568451263; 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=RS9AJW3K/QjdZZdpBOcGnP63HJ/z0+UWqLpvC43pk9w=; b=UxMW90TrH5ODVQAMtXfAGeujE0nPTrKc/vHH8D49kaFf2iw9R2fdb34+iT0OAPXbrv2EC6tKutFveaMZJRLMrTaJR0lvQ1plAjnpZik7Vv8gzUSNe7OYjNWne7GgKnFKozyjozG0SCGEu5kweP8mO9uaS8OR8eqd5p0XUMtR5/8= 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 1568451263710217.8532868610081; Sat, 14 Sep 2019 01:54:23 -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 1i93oN-0008G3-NK; Sat, 14 Sep 2019 08:53:43 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i93oM-0008Ef-UU for xen-devel@lists.xenproject.org; Sat, 14 Sep 2019 08:53:42 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 11795d10-d6cd-11e9-a337-bc764e2007e4; Sat, 14 Sep 2019 08:53:06 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 9BE12B673; Sat, 14 Sep 2019 08:53:04 +0000 (UTC) X-Inumbo-ID: 11795d10-d6cd-11e9-a337-bc764e2007e4 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Sat, 14 Sep 2019 10:52:35 +0200 Message-Id: <20190914085251.18816-32-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190914085251.18816-1-jgross@suse.com> References: <20190914085251.18816-1-jgross@suse.com> Subject: [Xen-devel] [PATCH v3 31/47] xen/sched: modify cpupool_domain_cpumask() to be an unit mask 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 , Tim Deegan , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Dario Faggioli , Julien Grall , Jan Beulich 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" cpupool_domain_cpumask() is used by scheduling to select cpus or to iterate over cpus. In order to support scheduling units spanning multiple cpus let cpupool_domain_cpumask() return a cpumask with only one bit set per scheduling resource. Signed-off-by: Juergen Gross --- xen/common/cpupool.c | 29 ++++++++++++++++++++--------- xen/common/schedule.c | 5 +++-- xen/include/xen/sched-if.h | 5 ++++- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/xen/common/cpupool.c b/xen/common/cpupool.c index fd30040922..a5f4113915 100644 --- a/xen/common/cpupool.c +++ b/xen/common/cpupool.c @@ -36,26 +36,35 @@ static DEFINE_SPINLOCK(cpupool_lock); =20 DEFINE_PER_CPU(struct cpupool *, cpupool); =20 +static void free_cpupool_struct(struct cpupool *c) +{ + if ( c ) + { + free_cpumask_var(c->res_valid); + free_cpumask_var(c->cpu_valid); + } + xfree(c); +} + static struct cpupool *alloc_cpupool_struct(void) { struct cpupool *c =3D xzalloc(struct cpupool); =20 - if ( !c || !zalloc_cpumask_var(&c->cpu_valid) ) + if ( !c ) + return NULL; + + zalloc_cpumask_var(&c->cpu_valid); + zalloc_cpumask_var(&c->res_valid); + + if ( !c->cpu_valid || !c->res_valid ) { - xfree(c); + free_cpupool_struct(c); c =3D NULL; } =20 return c; } =20 -static void free_cpupool_struct(struct cpupool *c) -{ - if ( c ) - free_cpumask_var(c->cpu_valid); - xfree(c); -} - /* * find a cpupool by it's id. to be called with cpupool lock held * if exact is not specified, the first cpupool with an id larger or equal= to @@ -269,6 +278,7 @@ static int cpupool_assign_cpu_locked(struct cpupool *c,= unsigned int cpu) cpupool_cpu_moving =3D NULL; } cpumask_set_cpu(cpu, c->cpu_valid); + cpumask_and(c->res_valid, c->cpu_valid, sched_res_mask); =20 rcu_read_lock(&domlist_read_lock); for_each_domain_in_cpupool(d, c) @@ -361,6 +371,7 @@ static int cpupool_unassign_cpu_start(struct cpupool *c= , unsigned int cpu) atomic_inc(&c->refcnt); cpupool_cpu_moving =3D c; cpumask_clear_cpu(cpu, c->cpu_valid); + cpumask_and(c->res_valid, c->cpu_valid, sched_res_mask); =20 out: spin_unlock(&cpupool_lock); diff --git a/xen/common/schedule.c b/xen/common/schedule.c index a79065c826..87660c6978 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -57,6 +57,7 @@ integer_param("sched_ratelimit_us", sched_ratelimit_us); =20 /* Number of vcpus per struct sched_unit. */ static unsigned int __read_mostly sched_granularity =3D 1; +const cpumask_t *sched_res_mask =3D &cpumask_all; =20 /* Common lock for free cpus. */ static DEFINE_SPINLOCK(sched_free_cpu_lock); @@ -414,9 +415,9 @@ static unsigned int sched_select_initial_cpu(const stru= ct vcpu *v) cpumask_clear(cpus); for_each_node_mask ( node, d->node_affinity ) cpumask_or(cpus, cpus, &node_to_cpumask(node)); - cpumask_and(cpus, cpus, cpupool_domain_cpumask(d)); + cpumask_and(cpus, cpus, d->cpupool->cpu_valid); if ( cpumask_empty(cpus) ) - cpumask_copy(cpus, cpupool_domain_cpumask(d)); + cpumask_copy(cpus, d->cpupool->cpu_valid); =20 if ( v->vcpu_id =3D=3D 0 ) cpu_ret =3D cpumask_first(cpus); diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h index 6a4dbac935..84d0658578 100644 --- a/xen/include/xen/sched-if.h +++ b/xen/include/xen/sched-if.h @@ -22,6 +22,8 @@ extern cpumask_t cpupool_free_cpus; #define SCHED_DEFAULT_RATELIMIT_US 1000 extern int sched_ratelimit_us; =20 +/* Scheduling resource mask. */ +extern const cpumask_t *sched_res_mask; =20 /* * In order to allow a scheduler to remap the lock->cpu mapping, @@ -521,6 +523,7 @@ struct cpupool int cpupool_id; unsigned int n_dom; cpumask_var_t cpu_valid; /* all cpus assigned to pool */ + cpumask_var_t res_valid; /* all scheduling resources of pool */ struct cpupool *next; struct scheduler *sched; atomic_t refcnt; @@ -536,7 +539,7 @@ static inline cpumask_t *cpupool_domain_cpumask(const s= truct domain *d) * be interested in calling this for the idle domain. */ ASSERT(d->cpupool !=3D NULL); - return d->cpupool->cpu_valid; + return d->cpupool->res_valid; } =20 /* --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel