From patchwork Fri Nov 8 06:57:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juergen Gross X-Patchwork-Id: 11234137 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 9B5F51390 for ; Fri, 8 Nov 2019 06:58:57 +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 81F5B214DA for ; Fri, 8 Nov 2019 06:58:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 81F5B214DA 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 1iSyDJ-00027h-RF; Fri, 08 Nov 2019 06:57:45 +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 1iSyDI-00027Z-3w for xen-devel@lists.xenproject.org; Fri, 08 Nov 2019 06:57:44 +0000 X-Inumbo-ID: 0f7cb086-01f5-11ea-a1d0-12813bfff9fa Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 0f7cb086-01f5-11ea-a1d0-12813bfff9fa; Fri, 08 Nov 2019 06:57:43 +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 4ECABACE0; Fri, 8 Nov 2019 06:57:42 +0000 (UTC) From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Fri, 8 Nov 2019 07:57:39 +0100 Message-Id: <20191108065739.21345-1-jgross@suse.com> X-Mailer: git-send-email 2.16.4 Subject: [Xen-devel] [PATCH] xen/sched: fix a potential issue with core scheduling 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 , Stefano Stabellini , Julien Grall , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Dario Faggioli , Meng Xu , Jan Beulich MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" cpupool_online_cpumask() is used by credit and rt scheduler. It returns all the cpus of a cpupool or all online cpus in case no cpupool is specified. The "no cpupool" case can be dropped, as no scheduler other than the init scheduler will ever work on cpus not associated with any cpupool. As the individual schedulers should only ever work on scheduling resources instead of individual cpus, their cpupool_online_cpumask() use should be replaced by cpupool->res_valid. Note that only with core scheduling active this might result in potential problems, as with cpu scheduling both masks are identical. Signed-off-by: Juergen Gross Reviewed-by: Dario Faggioli --- xen/common/sched_credit.c | 3 +-- xen/common/sched_rt.c | 4 ++-- xen/include/xen/sched-if.h | 3 --- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index fbffcf3996..645cdc5e9a 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -1684,12 +1684,11 @@ csched_load_balance(struct csched_private *prv, int cpu, struct cpupool *c = get_sched_res(cpu)->cpupool; struct csched_unit *speer; cpumask_t workers; - cpumask_t *online; + cpumask_t *online = c->res_valid; int peer_cpu, first_cpu, peer_node, bstep; int node = cpu_to_node(cpu); BUG_ON(get_sched_res(cpu) != snext->unit->res); - online = cpupool_online_cpumask(c); /* * If this CPU is going offline, or is not (yet) part of any cpupool diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c index 6e93e50acb..b2b29481f3 100644 --- a/xen/common/sched_rt.c +++ b/xen/common/sched_rt.c @@ -774,8 +774,8 @@ rt_deinit_pdata(const struct scheduler *ops, void *pcpu, int cpu) if ( prv->repl_timer.cpu == cpu ) { - struct cpupool *c = get_sched_res(cpu)->cpupool; - unsigned int new_cpu = cpumask_cycle(cpu, cpupool_online_cpumask(c)); + cpumask_t *online = get_sched_res(cpu)->cpupool->res_valid; + unsigned int new_cpu = cpumask_cycle(cpu, online); /* * Make sure the timer run on one of the cpus that are still available diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h index 29715652bc..b0ac54e63d 100644 --- a/xen/include/xen/sched-if.h +++ b/xen/include/xen/sched-if.h @@ -545,9 +545,6 @@ struct cpupool enum sched_gran gran; }; -#define cpupool_online_cpumask(_pool) \ - (((_pool) == NULL) ? &cpu_online_map : (_pool)->cpu_valid) - static inline cpumask_t *cpupool_domain_master_cpumask(const struct domain *d) { /*