From nobody Mon Feb 9 09:28:42 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=1565362801; cv=none; d=zoho.com; s=zohoarc; b=KZHRgvAmTKdYupVa3tExvye3k0TzosmIn7Ka4+rYM6glsSO7d5yc2VSesY0M9A0b25iVz6A3wPZTyG41M2ie8R+hSDzdsqBNV9ao2HNTQMwc3IAxp/rZ2/l6yvRGYfaiZpK97yk29DKhlLMhWZj7g496MQk+ayGlfKiHB3gEAEQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565362801; 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=lI57QIx4Tmy8+5xFZCh0eY4h8Zr3E4Fp8Sh0kGWMcVY=; b=mjWWlkR6ngeIgnlsjYzLyfVLhbGQQpIegwOT1vfaa/iKRuSztXrrLSZ9hst0MmDCwrWXYW9XGFkfKONyc3wN8fi71NY4oWDrJwjT7/DSK2/fXjwEOaL64kqn7Epk/ZKRsrVpzqfiwX/8vZrUVQvZfQkJoxm+/XfVX29ggT9Ojiw= 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 1565362801504247.64746902539503; Fri, 9 Aug 2019 08:00:01 -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 1hw6MU-0007bC-0B; Fri, 09 Aug 2019 14:59:22 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hw6M5-0006ia-Uq for xen-devel@lists.xenproject.org; Fri, 09 Aug 2019 14:58:57 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 320972a6-bab6-11e9-8980-bc764e045a96; Fri, 09 Aug 2019 14:58:55 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 738CBB034; Fri, 9 Aug 2019 14:58:49 +0000 (UTC) X-Inumbo-ID: 320972a6-bab6-11e9-8980-bc764e045a96 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Fri, 9 Aug 2019 16:58:17 +0200 Message-Id: <20190809145833.1020-33-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190809145833.1020-1-jgross@suse.com> References: <20190809145833.1020-1-jgross@suse.com> Subject: [Xen-devel] [PATCH v2 32/48] 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 e0f8eec57b..17d671585a 100644 --- a/xen/common/cpupool.c +++ b/xen/common/cpupool.c @@ -38,26 +38,35 @@ DEFINE_PER_CPU(struct cpupool *, cpupool); =20 #define cpupool_dprintk(x...) ((void)0) =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 @@ -271,6 +280,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) @@ -365,6 +375,7 @@ static int cpupool_unassign_cpu_prologue(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 1f45fc7373..bbc9eb90e4 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); @@ -410,9 +411,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 e1d61a05b7..ae46b5395f 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, @@ -520,6 +522,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; @@ -535,7 +538,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