From patchwork Sat Sep 14 08:52:47 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: 11145647 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E18A6184E for ; Sat, 14 Sep 2019 08:55:50 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C832820717 for ; Sat, 14 Sep 2019 08:55:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C832820717 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i93or-0000gq-Ia; Sat, 14 Sep 2019 08:54:13 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i93oq-0000fY-Vc for xen-devel@lists.xenproject.org; Sat, 14 Sep 2019 08:54:13 +0000 X-Inumbo-ID: 130ac5b0-d6cd-11e9-b76c-bc764e2007e4 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 130ac5b0-d6cd-11e9-b76c-bc764e2007e4; Sat, 14 Sep 2019 08:53:09 +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 7A19EB664; Sat, 14 Sep 2019 08:53:08 +0000 (UTC) From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Sat, 14 Sep 2019 10:52:47 +0200 Message-Id: <20190914085251.18816-44-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 43/47] xen/sched: support multiple cpus per scheduling resource 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" Prepare supporting multiple cpus per scheduling resource by allocating the cpumask per resource dynamically. Modify sched_res_mask to have only one bit per scheduling resource set. Signed-off-by: Juergen Gross --- V1: new patch (carved out from other patch) --- xen/common/schedule.c | 16 ++++++++++++++-- xen/include/xen/sched-if.h | 4 ++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index c2e5a9220d..882b3baf42 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -59,7 +59,7 @@ integer_param("sched_ratelimit_us", sched_ratelimit_us); enum sched_gran __read_mostly opt_sched_granularity = SCHED_GRAN_cpu; unsigned int __read_mostly sched_granularity = 1; bool __read_mostly sched_disable_smt_switching; -const cpumask_t *sched_res_mask = &cpumask_all; +cpumask_var_t sched_res_mask; /* Common lock for free cpus. */ static DEFINE_SPINLOCK(sched_free_cpu_lock); @@ -2388,8 +2388,14 @@ static int cpu_schedule_up(unsigned int cpu) sd = xzalloc(struct sched_resource); if ( sd == NULL ) return -ENOMEM; + if ( !zalloc_cpumask_var(&sd->cpus) ) + { + xfree(sd); + return -ENOMEM; + } + sd->master_cpu = cpu; - sd->cpus = cpumask_of(cpu); + cpumask_copy(sd->cpus, cpumask_of(cpu)); set_sched_res(cpu, sd); sd->scheduler = &sched_idle_ops; @@ -2401,6 +2407,8 @@ static int cpu_schedule_up(unsigned int cpu) /* We start with cpu granularity. */ sd->granularity = 1; + cpumask_set_cpu(cpu, sched_res_mask); + /* Boot CPU is dealt with later in scheduler_init(). */ if ( cpu == 0 ) return 0; @@ -2433,6 +2441,7 @@ static void sched_res_free(struct rcu_head *head) { struct sched_resource *sd = container_of(head, struct sched_resource, rcu); + free_cpumask_var(sd->cpus); xfree(sd); } @@ -2581,6 +2590,9 @@ void __init scheduler_init(void) printk("Using '%s' (%s)\n", ops.name, ops.opt_name); } + if ( !zalloc_cpumask_var(&sched_res_mask) ) + BUG(); + if ( cpu_schedule_up(0) ) BUG(); register_cpu_notifier(&cpu_schedule_nfb); diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h index f10ed768b0..1770b9bca1 100644 --- a/xen/include/xen/sched-if.h +++ b/xen/include/xen/sched-if.h @@ -24,7 +24,7 @@ extern cpumask_t cpupool_free_cpus; extern int sched_ratelimit_us; /* Scheduling resource mask. */ -extern const cpumask_t *sched_res_mask; +extern cpumask_var_t sched_res_mask; /* Number of vcpus per struct sched_unit. */ enum sched_gran { @@ -59,7 +59,7 @@ struct sched_resource { /* Cpu with lowest id in scheduling resource. */ unsigned int master_cpu; unsigned int granularity; - const cpumask_t *cpus; /* cpus covered by this struct */ + cpumask_var_t cpus; /* cpus covered by this struct */ struct rcu_head rcu; };