From patchwork Mon May 6 06:56:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 10930527 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 768B1912 for ; Mon, 6 May 2019 06:58:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6598928590 for ; Mon, 6 May 2019 06:58:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 597B32860A; Mon, 6 May 2019 06:58:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E147128627 for ; Mon, 6 May 2019 06:58:42 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYz-0002lx-1g; Mon, 06 May 2019 06:57:25 +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 1hNXYl-0002Fg-Iu for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:57:11 +0000 X-Inumbo-ID: 2712ad24-6fcc-11e9-bc56-4f907df96e70 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 2712ad24-6fcc-11e9-bc56-4f907df96e70; Mon, 06 May 2019 06:57:03 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 1961DAF40; Mon, 6 May 2019 06:56:59 +0000 (UTC) From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:37 +0200 Message-Id: <20190506065644.7415-39-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 38/45] xen/sched: modify cpupool_domain_cpumask() to be an item 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 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP cpupool_domain_cpumask() is used by scheduling to select cpus or to iterate over cpus. In order to support scheduling items 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 | 30 +++++++++++++++++++++--------- xen/common/schedule.c | 5 +++-- xen/include/xen/sched-if.h | 5 ++++- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/xen/common/cpupool.c b/xen/common/cpupool.c index 31ac323e40..ba76045937 100644 --- a/xen/common/cpupool.c +++ b/xen/common/cpupool.c @@ -38,26 +38,35 @@ DEFINE_PER_CPU(struct cpupool *, cpupool); #define cpupool_dprintk(x...) ((void)0) +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 = xzalloc(struct cpupool); - 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 = NULL; } return c; } -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 = NULL; } cpumask_set_cpu(cpu, c->cpu_valid); + cpumask_and(c->res_valid, c->cpu_valid, sched_res_mask); rcu_read_lock(&domlist_read_lock); for_each_domain_in_cpupool(d, c) @@ -393,6 +403,7 @@ static int cpupool_unassign_cpu(struct cpupool *c, unsigned int cpu) atomic_inc(&c->refcnt); cpupool_cpu_moving = c; cpumask_clear_cpu(cpu, c->cpu_valid); + cpumask_and(c->res_valid, c->cpu_valid, sched_res_mask); spin_unlock(&cpupool_lock); work_cpu = smp_processor_id(); @@ -509,6 +520,7 @@ static int cpupool_cpu_remove(unsigned int cpu) * allowed only for CPUs in pool0. */ cpumask_clear_cpu(cpu, cpupool0->cpu_valid); + cpumask_and(cpupool0->res_valid, cpupool0->cpu_valid, sched_res_mask); ret = 0; } diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 1134733314..2870e91cce 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -57,6 +57,7 @@ integer_param("sched_ratelimit_us", sched_ratelimit_us); /* Number of vcpus per struct sched_item. */ static unsigned int sched_granularity = 1; +const cpumask_t *sched_res_mask = &cpumask_all; /* Various timer handlers. */ static void s_timer_fn(void *unused); @@ -347,9 +348,9 @@ static unsigned int sched_select_initial_cpu(struct 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); if ( v->vcpu_id == 0 ) return cpumask_first(&cpus); diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h index 88fbc06860..b3921f3a41 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; +/* Scheduling resource mask. */ +extern const cpumask_t *sched_res_mask; /* * In order to allow a scheduler to remap the lock->cpu mapping, @@ -527,6 +529,7 @@ struct cpupool { int cpupool_id; cpumask_var_t cpu_valid; /* all cpus assigned to pool */ + cpumask_var_t res_valid; /* all scheduling resources of pool */ struct cpupool *next; unsigned int n_dom; struct scheduler *sched; @@ -543,7 +546,7 @@ static inline cpumask_t* cpupool_domain_cpumask(struct domain *d) * be interested in calling this for the idle domain. */ ASSERT(d->cpupool != NULL); - return d->cpupool->cpu_valid; + return d->cpupool->res_valid; } /*