From patchwork Mon Sep 19 02:08:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 9338437 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 45724601C2 for ; Mon, 19 Sep 2016 02:11:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E70A28EAD for ; Mon, 19 Sep 2016 02:11:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F70228EB0; Mon, 19 Sep 2016 02:11:51 +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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3316428EAD for ; Mon, 19 Sep 2016 02:11:50 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1blo1S-0004CS-8Y; Mon, 19 Sep 2016 02:09:30 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1blo1Q-0004CL-PL for xen-devel@lists.xen.org; Mon, 19 Sep 2016 02:09:28 +0000 Received: from [85.158.143.35] by server-2.bemta-6.messagelabs.com id 4A/9A-13744-8D84FD75; Mon, 19 Sep 2016 02:09:28 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrJIsWRWlGSWpSXmKPExsVyMfSOk+51j/v hBj+/MVss+biYxYHR4+ju30wBjFGsmXlJ+RUJrBk9uy+wFXyyqLiw6xBTA+MmnS5GLg4hgYmM EofX9zGBOCwCL1kkZsz7BOZICPSzSlzaMIm9i5ETyImR6Hz/lBnCrpI4uPQWmC0koCIxd1MPI 4Q9nUliz25tEJtNQFpiz4WljBD1GhJLj95nBRkqItDPKPHm8FxWkASzgKXE+Q0fwRYIC5hJnO 97wgRiswioSuxav4QNxOYVcJBY9OodC8QgOYnrM6eD1XAKOEpMaHjJDrHYQeLAkd/sExgFFzA yrGLUKE4tKkst0jUy1UsqykzPKMlNzMzRNTQw08tNLS5OTE/NSUwq1kvOz93ECAw6BiDYwbhq QeAhRkkOJiVR3h0l98KF+JLyUyozEosz4otKc1KLDzHKcHAoSfAedL8fLiRYlJqeWpGWmQMMf 5i0BAePkgjvTJA0b3FBYm5xZjpE6hSjJceW39fWMnFsWXADSG6bem8tkxBLXn5eqpQ4bxtIgw BIQ0ZpHtw4WIxeYpSVEuZlBDpQiKcgtSg3swRV/hWjOAejkjAvOzDihXgy80rgtr4COogJ6KD Vs26DHFSSiJCSamDkObVhieXSFz82MKqz2D9PmeV4e25nhOpubXMHlYMFL4WvcL5j8+3kd/UX 0lFaKTvRWvsWz7yDJ4+sbeP5+fPlcoEoM83QXXE5W/UNzJ8VOZ/jqWF/urfPvPC06PYD9cdFD nbav3N4dvbf3bLtuyM+5wWciM2yuDv1y0rjNec6euW1J3fan5dTYinOSDTUYi4qTgQAKkPvRc wCAAA= X-Env-Sender: van.freenix@gmail.com X-Msg-Ref: server-7.tower-21.messagelabs.com!1474250965!33895439!1 X-Originating-IP: [209.85.220.66] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 46987 invoked from network); 19 Sep 2016 02:09:26 -0000 Received: from mail-pa0-f66.google.com (HELO mail-pa0-f66.google.com) (209.85.220.66) by server-7.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 19 Sep 2016 02:09:26 -0000 Received: by mail-pa0-f66.google.com with SMTP id my20so3225459pab.3 for ; Sun, 18 Sep 2016 19:09:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nnq+8rPjcutrv1EF47+NnWwuX7rv3Z9onycJsCGcXV0=; b=aZkq97Oc+D1nweLebTOoPC22eJ/r3npbcdYQoBySAAma7w5OlZ7X6kizvWJL9RSXld /ehft9I34+zcnheYWZsjxZbnxncz6JX/CI2s2t//UpSbA4tNsGWSop88NMT12+jOTfW8 tDTlTls9TtA03w1A6LSU3Wcz3byvR49HVKiTRKqFtW671Jf8VLAcqqLjc4qm5CTPwKaw MC3Eor0C8hz5/yz+O7ImHNg7QpTCy3/hMJEgRU1XOv3w31qqVmeKyC/RllCDiT9bV0Bo O9Z8xWuLb2Gzs9I7b6+gRgxj44+mlw8Axm7G+o9/S/95NFCQqXwP5WnI3S/Roh7QJQ7Q wjpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=nnq+8rPjcutrv1EF47+NnWwuX7rv3Z9onycJsCGcXV0=; b=j68QEE8lqm4wzhV9gNdRZcRDyHXTSsdBwD5361i7opmdJo/SQzqp7Jy9rEHWtfjz/w 8369/nqWw7+hPElVQfFrPppLBmL8pSHgvsT8QMOKL70fpUhUBdU1R/FSUrUvYt7Iz/cM 3yrlAGPEfRFbAVdD862B2rYLPHmpQBiYU7cYKK3XxVa1ndNPk4ruU8kbsulSxKrCyQFD LwKw21TFXtEo7wiWyu24/lDlpEsrs323oahwWtkhRwsT2r2LBoSdo4gNOcQ27yk3IjnH uzf2eU2O0aS6dP1+rtdjNu3WLdBdprk1iHfBgoFu9IzAVYFMP+JyrZc/e2FzghIHwnk7 f8aw== X-Gm-Message-State: AE9vXwPPehE5R7VkSUKtXS/Ab1udng19h4nqHBHJpNIjeY9qiTms4ANlF4ehITYH3MEkvA== X-Received: by 10.66.148.68 with SMTP id tq4mr28679939pab.160.1474250964927; Sun, 18 Sep 2016 19:09:24 -0700 (PDT) Received: from linux-u7w5.ap.freescale.net (gate-zmy3.freescale.com. [192.88.167.1]) by smtp.gmail.com with ESMTPSA id i68sm66777180pfc.25.2016.09.18.19.09.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 18 Sep 2016 19:09:24 -0700 (PDT) From: van.freenix@gmail.com X-Google-Original-From: peng.fan@nxp.com To: julien.grall@arm.com, sstabellini@kernel.org, jbeulich@suse.com, andrew.cooper3@citrix.com, jgross@suse.com, dario.faggioli@citrix.com Date: Mon, 19 Sep 2016 10:08:54 +0800 Message-Id: <1474250936-27962-4-git-send-email-peng.fan@nxp.com> X-Mailer: git-send-email 2.6.6 In-Reply-To: <1474250936-27962-1-git-send-email-peng.fan@nxp.com> References: <1474250936-27962-1-git-send-email-peng.fan@nxp.com> Cc: Peng Fan , xen-devel@lists.xen.org Subject: [Xen-devel] [RFC 3/5] xen: cpupool: add arch cpupool hook X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Peng Fan Introduce arch_cpupool_create, arch_cpupool_cpu_add, and arch_domain_cpupool_compatible. To X86, nothing to do, just add an empty stub functions. To ARM, arch_cpupool_create initialize midr with value -1; arch_cpupool_cpu_add, if there is cpu in the cpupool or the cpu is the first one that will be added to the cpupool, assign cpu midr to cpupool midr. If the midr already initialzed and there is valid cpus in the pool, check whether the midr of cpu and cpupool is compatbile or not; arch_domain_cpupool_compatible is to check whether the domain is ok to be moved into the cpupool. Signed-off-by: Peng Fan Cc: Stefano Stabellini Cc: Julien Grall Cc: Jan Beulich Cc: Andrew Cooper Cc: Juergen Gross Cc: Dario Faggioli --- xen/arch/arm/Makefile | 1 + xen/arch/arm/cpupool.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ xen/arch/x86/cpu/Makefile | 1 + xen/arch/x86/cpu/cpupool.c | 30 ++++++++++++++++++++++++++++++ xen/common/cpupool.c | 30 ++++++++++++++++++++++++++++++ xen/include/xen/sched-if.h | 3 +++ 6 files changed, 110 insertions(+) create mode 100644 xen/arch/arm/cpupool.c create mode 100644 xen/arch/x86/cpu/cpupool.c diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile index 23aaf52..1b72f66 100644 --- a/xen/arch/arm/Makefile +++ b/xen/arch/arm/Makefile @@ -9,6 +9,7 @@ obj-y += bootfdt.o obj-y += cpu.o obj-y += cpuerrata.o obj-y += cpufeature.o +obj-y += cpupool.o obj-y += decode.o obj-y += device.o obj-y += domain.o diff --git a/xen/arch/arm/cpupool.c b/xen/arch/arm/cpupool.c new file mode 100644 index 0000000..74a5ef3 --- /dev/null +++ b/xen/arch/arm/cpupool.c @@ -0,0 +1,45 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include + +int arch_cpupool_create(struct cpupool *c) +{ + c->info.midr = -1; + + return 0; +} + +int arch_cpupool_cpu_add(struct cpupool *c, unsigned int cpu) +{ + if (( c->info.midr == -1 ) || ( cpumask_weight(c->cpu_valid) == 0 )) + { + c->info.midr = cpu_data[cpu].midr.bits; + + return 0; + } + else if (( c->info.midr == cpu_data[cpu].midr.bits )) + { + return 0; + } + else + { + return -EINVAL; + } +} + +bool_t arch_domain_cpupool_compatible(struct domain *d, struct cpupool *c) +{ + return true; +} diff --git a/xen/arch/x86/cpu/Makefile b/xen/arch/x86/cpu/Makefile index 74f23ae..0d3036e 100644 --- a/xen/arch/x86/cpu/Makefile +++ b/xen/arch/x86/cpu/Makefile @@ -4,6 +4,7 @@ subdir-y += mtrr obj-y += amd.o obj-y += centaur.o obj-y += common.o +obj-y += cpupool.o obj-y += intel.o obj-y += intel_cacheinfo.o obj-y += mwait-idle.o diff --git a/xen/arch/x86/cpu/cpupool.c b/xen/arch/x86/cpu/cpupool.c new file mode 100644 index 0000000..d897a1f --- /dev/null +++ b/xen/arch/x86/cpu/cpupool.c @@ -0,0 +1,30 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include + +int arch_cpupool_create(struct cpupool *c) +{ + return 0; +} + +int arch_cpupool_cpu_add(struct cpupool *c, unsigned int cpu) +{ + return 0; +} + +bool_t arch_domain_cpupool_compatible(struct domain *d, struct cpupool *c) +{ + return true; +} diff --git a/xen/common/cpupool.c b/xen/common/cpupool.c index 9998394..798322d 100644 --- a/xen/common/cpupool.c +++ b/xen/common/cpupool.c @@ -134,11 +134,20 @@ static struct cpupool *cpupool_create( struct cpupool *c; struct cpupool **q; int last = 0; + int ret; *perr = -ENOMEM; if ( (c = alloc_cpupool_struct()) == NULL ) return NULL; + ret = arch_cpupool_create(c); + if ( ret ) + { + *perr = ret; + free_cpupool_struct(c); + return NULL; + } + /* One reference for caller, one reference for cpupool_destroy(). */ atomic_set(&c->refcnt, 2); @@ -498,6 +507,8 @@ static int cpupool_cpu_add(unsigned int cpu) { if ( cpumask_test_cpu(cpu, (*c)->cpu_suspended ) ) { + if ( arch_cpupool_cpu_add(*c, cpu) ) + continue; ret = cpupool_assign_cpu_locked(*c, cpu); if ( ret ) goto out; @@ -516,6 +527,13 @@ static int cpupool_cpu_add(unsigned int cpu) } else { + if ( arch_cpupool_cpu_add(cpupool0, cpu) ) + { + /* No fail, just skip adding the cpu to cpupool0 */ + ret = 0; + goto out; + } + /* * If we are not resuming, we are hot-plugging cpu, and in which case * we add it to pool0, as it certainly was there when hot-unplagged @@ -657,6 +675,9 @@ int cpupool_do_sysctl(struct xen_sysctl_cpupool_op *op) ret = -ENOENT; if ( c == NULL ) goto addcpu_out; + ret = -EINVAL; + if ( arch_cpupool_cpu_add(c, cpu) ) + goto addcpu_out; ret = cpupool_assign_cpu_locked(c, cpu); addcpu_out: spin_unlock(&cpupool_lock); @@ -707,7 +728,16 @@ int cpupool_do_sysctl(struct xen_sysctl_cpupool_op *op) c = cpupool_find_by_id(op->cpupool_id); if ( (c != NULL) && cpumask_weight(c->cpu_valid) ) + { + if ( !arch_domain_cpupool_compatible (d, c) ) + { + ret = -EINVAL; + spin_unlock(&cpupool_lock); + rcu_unlock_domain(d); + break; + } ret = cpupool_move_domain_locked(d, c); + } spin_unlock(&cpupool_lock); cpupool_dprintk("cpupool move_domain(dom=%d)->pool=%d ret %d\n", diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h index eb52ac7..1b2d4bf 100644 --- a/xen/include/xen/sched-if.h +++ b/xen/include/xen/sched-if.h @@ -203,4 +203,7 @@ static inline cpumask_t* cpupool_domain_cpumask(struct domain *d) return d->cpupool->cpu_valid; } +int arch_cpupool_create(struct cpupool *c); +int arch_cpupool_cpu_add(struct cpupool *c, unsigned int cpu); +bool_t arch_domain_cpupool_compatible(struct domain *d, struct cpupool *c); #endif /* __XEN_SCHED_IF_H__ */